[P0][security] lease TTL 및 hop route TTL 상한 적용 #23

Closed
opened 2026-05-02 04:34:04 +00:00 by boxqkrtm · 1 comment

문제

crates/portal-relay/src/relay/leases.rs의 lease TTL 계산은 양수 값을 사실상 그대로 사용하는 구조입니다. RegisterChallengeRequest.ttl, RenewRequest.ttl, hop route expires_at 계열도 client가 과도하게 긴 값을 줄 수 있습니다.

위험

  • 사실상 영구 lease 생성 가능
  • token 유효기간 장기화
  • admin approval/deny/ban 정책의 운영 통제 약화
  • stale hop route 누적 및 상태 관리 부담 증가

제안

  • DEFAULT_LEASE_TTL_SECS, MAX_LEASE_TTL_SECS 도입
  • register/renew/challenge TTL을 max로 clamp 또는 초과 시 400 처리
  • hop route에도 MAX_HOP_ROUTE_TTL 적용
  • 설정 파일에서 max TTL을 조정할 수 있게 하되 안전한 기본값 제공

예시 방향:

const DEFAULT_LEASE_TTL_SECS: i64 = 30;
const MAX_LEASE_TTL_SECS: i64 = 10 * 60;

fn lease_ttl(seconds: i64) -> chrono::Duration {
    let seconds = if seconds > 0 {
        seconds.min(MAX_LEASE_TTL_SECS)
    } else {
        DEFAULT_LEASE_TTL_SECS
    };
    chrono::Duration::seconds(seconds)
}

완료 기준

  • 과도한 TTL 요청이 cap되거나 명확히 거부됨
  • 발급 token/lease/hop route 만료 시간이 max TTL을 넘지 않음
  • lease TTL cap 및 hop route TTL cap 테스트 추가

검토 기준: 업로드된 Rust portal-relay 코드 정적 리뷰. 리뷰 환경에서는 cargo check/test/clippy를 실행하지 못했습니다.

## 문제 `crates/portal-relay/src/relay/leases.rs`의 lease TTL 계산은 양수 값을 사실상 그대로 사용하는 구조입니다. `RegisterChallengeRequest.ttl`, `RenewRequest.ttl`, hop route `expires_at` 계열도 client가 과도하게 긴 값을 줄 수 있습니다. ## 위험 - 사실상 영구 lease 생성 가능 - token 유효기간 장기화 - admin approval/deny/ban 정책의 운영 통제 약화 - stale hop route 누적 및 상태 관리 부담 증가 ## 제안 - `DEFAULT_LEASE_TTL_SECS`, `MAX_LEASE_TTL_SECS` 도입 - register/renew/challenge TTL을 max로 clamp 또는 초과 시 400 처리 - hop route에도 `MAX_HOP_ROUTE_TTL` 적용 - 설정 파일에서 max TTL을 조정할 수 있게 하되 안전한 기본값 제공 예시 방향: ```rust const DEFAULT_LEASE_TTL_SECS: i64 = 30; const MAX_LEASE_TTL_SECS: i64 = 10 * 60; fn lease_ttl(seconds: i64) -> chrono::Duration { let seconds = if seconds > 0 { seconds.min(MAX_LEASE_TTL_SECS) } else { DEFAULT_LEASE_TTL_SECS }; chrono::Duration::seconds(seconds) } ``` ## 완료 기준 - 과도한 TTL 요청이 cap되거나 명확히 거부됨 - 발급 token/lease/hop route 만료 시간이 max TTL을 넘지 않음 - lease TTL cap 및 hop route TTL cap 테스트 추가 --- 검토 기준: 업로드된 Rust `portal-relay` 코드 정적 리뷰. 리뷰 환경에서는 `cargo check/test/clippy`를 실행하지 못했습니다.
Owner

수용했습니다. PR #62에서 lease TTL과 hop route TTL 상한을 적용하고 TTL cap 테스트를 추가했습니다. 검증: cargo test --locked, cargo clippy --locked --all-targets -- -D warnings.

수용했습니다. PR #62에서 lease TTL과 hop route TTL 상한을 적용하고 TTL cap 테스트를 추가했습니다. 검증: cargo test --locked, cargo clippy --locked --all-targets -- -D warnings.
gofix closed this issue 2026-05-03 18:58:36 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gofix/portal-tunnel-rs#23
No description provided.