[P1][security] Host header를 canonical host 설정과 검증 #32

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

문제

crates/portal-relay/src/api/mod.rs에서 Host header를 register URI와 SIWE message domain 등에 사용하는 경로가 있습니다. Host header는 client가 임의로 설정할 수 있습니다.

위험

  • 악의적인 Host header가 registration URI/domain에 반영될 수 있음
  • reverse proxy 환경에서 canonical host와 실제 요청 host 불일치
  • SIWE domain 검증/사용자 표시 영역에 혼동 가능

제안

  • configured portal_host/root_host 또는 canonical public host와 일치하는지 검증
  • mismatch 시 400 반환
  • reverse proxy 환경은 trusted proxy 설정과 canonical host 사용을 분리
  • allowed hosts 목록 설정 지원 검토

완료 기준

  • 허용되지 않은 Host header 요청은 registration/SIWE 생성 전에 거부
  • reverse proxy 문서에 trusted/canonical host 설정 방법 명시
  • Host header mismatch 테스트 추가

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

## 문제 `crates/portal-relay/src/api/mod.rs`에서 `Host` header를 register URI와 SIWE message domain 등에 사용하는 경로가 있습니다. `Host` header는 client가 임의로 설정할 수 있습니다. ## 위험 - 악의적인 Host header가 registration URI/domain에 반영될 수 있음 - reverse proxy 환경에서 canonical host와 실제 요청 host 불일치 - SIWE domain 검증/사용자 표시 영역에 혼동 가능 ## 제안 - configured `portal_host`/`root_host` 또는 canonical public host와 일치하는지 검증 - mismatch 시 400 반환 - reverse proxy 환경은 trusted proxy 설정과 canonical host 사용을 분리 - allowed hosts 목록 설정 지원 검토 ## 완료 기준 - 허용되지 않은 Host header 요청은 registration/SIWE 생성 전에 거부 - reverse proxy 문서에 trusted/canonical host 설정 방법 명시 - Host header mismatch 테스트 추가 --- 검토 기준: 업로드된 Rust `portal-relay` 코드 정적 리뷰. 리뷰 환경에서는 `cargo check/test/clippy`를 실행하지 못했습니다.
Owner

수용했습니다. PR #62에서 Host header를 configured portal host/portal_url 기준으로 검증하고, SIWE challenge URI/domain은 client-provided Host가 아니라 canonical portal_url에서 생성하도록 변경했습니다. 검증: cargo test --locked, cargo clippy --locked --all-targets -- -D warnings.

수용했습니다. PR #62에서 Host header를 configured portal host/portal_url 기준으로 검증하고, SIWE challenge URI/domain은 client-provided Host가 아니라 canonical portal_url에서 생성하도록 변경했습니다. 검증: cargo test --locked, cargo clippy --locked --all-targets -- -D warnings.
gofix closed this issue 2026-05-03 18:58:39 +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#32
No description provided.