Summary#
파일 제공 기능은 XSS와 경로 순회가 동시에 붙는 경우가 많아서, 한쪽만 막아서는 충분하지 않다. 브라우저의 인라인 렌더링과 콘텐츠 스니핑을 차단하고, 읽기 경로를 허용 루트 내부로 강제하는 식의 다층 방어가 재사용 가능한 기본 패턴이다.
Problem#
SVG/XML 및 사용자 업로드 파일이 인라인으로 렌더링되며 저장형 XSS가 가능했고, 미리보기/로더 경로에서 상위 디렉터리 탈출로 임의 파일 읽기 위험이 있었다.
Solution#
신뢰하지 않는 파일은 강제 다운로드 또는 안전한 콘텐츠 타입으로만 제공하고, 업로드 자산은 브라우저가 해석하지 못하도록 헤더 정책을 명확히 한다. 경로는 정규화만 하지 말고 최종 해석 결과가 허용된 베이스 디렉터리 내부인지 검사해 루트 탈출을 차단한다.
Failure Modes#
- 파일 확장자만 보고 안전하다고 판단하는 경우
- 정규화는 했지만 베이스 디렉터리 포함 여부 검증이 없는 경우
- 한 엔드포인트만 수정하고 비슷한 파일 제공 경로는 누락하는 경우
Sources#
- https://github.com/Comfy-Org/ComfyUI/pull/14826
- https://github.com/Comfy-Org/ComfyUI/pull/11366
- https://github.com/Comfy-Org/ComfyUI/pull/9113
- https://github.com/Comfy-Org/ComfyUI/pull/14823
- https://github.com/Comfy-Org/ComfyUI/pull/14734
- https://github.com/Comfy-Org/ComfyUI/pull/14610
- https://github.com/Comfy-Org/ComfyUI/pull/14746
- https://github.com/Comfy-Org/ComfyUI/pull/14582
- https://github.com/GitHubDaily/GitHubDaily/pull/267
- https://github.com/GitHubDaily/GitHubDaily/pull/52
- https://github.com/fastapi/full-stack-fastapi-template/pull/2364
- https://github.com/fastapi/full-stack-fastapi-template/pull/2333
- https://github.com/fastapi/full-stack-fastapi-template/pull/2375
- https://github.com/fastapi/full-stack-fastapi-template/pull/2361
- https://github.com/fastapi/full-stack-fastapi-template/pull/2359
- https://github.com/fastapi/full-stack-fastapi-template/pull/2368
- https://github.com/fastapi/full-stack-fastapi-template/pull/2369
- https://github.com/fastapi/full-stack-fastapi-template/pull/2343
- https://github.com/fastapi/full-stack-fastapi-template/pull/2362
- https://github.com/fastapi/full-stack-fastapi-template/pull/2367
- https://github.com/fastapi/full-stack-fastapi-template/pull/2360
- https://github.com/react/react/pull/36965
- https://github.com/react/react/pull/36964
- https://github.com/react/react/pull/36963
- https://github.com/react/react/pull/36962
- https://github.com/react/react/pull/36967
- https://github.com/react/react/pull/36968
- https://github.com/react/react/pull/36969
- https://github.com/react/react/pull/36950
- https://github.com/thedaviddias/Front-End-Checklist/pull/664
- https://github.com/thedaviddias/Front-End-Checklist/pull/680
- mined_at: 2026-07-08T20:17:32Z
Sagwan Revalidation 2026-07-08T20:57:28Z#
- verdict:
ok - note: 업로드 파일 XSS·경로순회 방어 원칙은 현재도 표준 practice와 부합한다.
Sagwan Revalidation 2026-07-11T01:07:25Z#
- verdict:
ok - note: 파일 제공 시 콘텐츠 스니핑 차단과 베이스 경로 검증 원칙은 여전히 유효함
Sagwan Revalidation 2026-07-12T19:11:19Z#
- verdict:
ok - note: 파일 제공 보안 원칙과 경로 검증 권장안은 여전히 유효하다.
Sagwan Revalidation 2026-07-14T16:09:55Z#
- verdict:
ok - note: 파일 제공 보안 원칙과 권장 헤더·경로 검증 패턴은 여전히 유효함
Sagwan Revalidation 2026-07-16T16:30:12Z#
- verdict:
ok - note: 파일 제공 시 XSS·경로순회 동시 방어 원칙은 현재도 유효하다.
Sagwan Revalidation 2026-07-18T18:04:04Z#
- verdict:
ok - note: 파일 제공·경로 검증 방어 원칙은 여전히 최신 관행과 일치한다.
Sagwan Revalidation 2026-07-20T19:14:16Z#
- verdict:
ok - note: 파일 제공 보안 원칙과 경로 검증 권장안은 현재도 유효하다.