Files
clean-architecture-frontend…/docs/security/browser-boundary.md
T
DongHyeonka afcd248780
frontend-quality-gates / merge / tests (pull_request) Canceled after 0s
frontend-quality-gates / merge / browser tests (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Canceled after 0s
frontend-quality-gates / external-vulnerability-provider (pull_request) Canceled after 0s
frontend-quality-gates / external-provenance-provider (pull_request) Canceled after 0s
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Canceled after 0s
frontend-quality-gates / deploy-promoted-release (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Canceled after 0s
frontend-quality-gates / main / checker self-tests (pull_request) Canceled after 0s
frontend-quality-gates / merge / static checks (pull_request) Canceled after 51s
fix(security): CSP 검사가 브라우저처럼 읽고 hosting fixture가 선언을 복사하지 않는다
앞 커밋 뒤 확인 리뷰가 셋을 찾았다.

- 같은 지시어가 두 번이면 검사는 뒤 값을, 브라우저는 앞 값을 쓴다(CSP3).
  키워드도 대소문자를 가려 비교한다. 그래서 `script-src 'self' 'unsafe-inline';
  script-src 'self'`와 `'Unsafe-Inline'`이 통과한다.
- 0929/13-04 완료 기준 「CSP를 바꿀 때 한 파일만 고친다」가 안 됐다. hosting
  fixture가 선언한 보안 header 일곱을 표면 넷에 그대로 복사한다.
- check:browser-security가 검사를 부르는 연결을 지키는 시험이 없다.

고른 방법: 지시어는 첫 것만, 이름과 키워드는 소문자로 읽는다. 선언 문서를
읽는 declaredCspProblems를 두고 check:browser-security가 그것을 부른다.
check:security:fixtures(FE-GATE-029)가 거절 fixture(대소문자를 바꾼
'unsafe-inline'이 앞 script-src에 있음)를 거절하고 선언을 받는지 본다. hosting
fixture에서 보안 header를 지우고, verify-hosting-headers의 fixture 모드는
보안 header가 필요한 표면에 선언을 답으로 채운다. fixture가 적은 값은 그대로
host의 답으로 비교한다. 버린 대안: fixture를 선언에서 생성하는 스크립트(생성물이
하나 더 생기고 대조할 것은 같다).

위험·한계: fixture 모드의 보안 header 비교는 선언끼리의 비교가 된다. 전에도
fixture 모드는 UNVERIFIED였다(live 모드만 host를 본다).

검증: csp-policy.test.ts 새 시험(브라우저처럼 읽기 다섯, 뒤 지시어 무시,
declaredCspProblems 넷)과 hosting-probe.test.ts 새 시험 둘(선언만 바꾼 뒤
fixture 통과, fixture가 적은 header는 비교)을 고치기 전 코드에서 RED로 보고
desktop에서 GREEN·FE-GATE-029를 돌린다(PR 본문).

Refs: 0929/13-04
2026-11-13 00:12:23 +09:00

2.6 KiB

브라우저 보안 경계

브라우저 bundle은 공개된다. 그래서 다음은 기본으로 금지한다: 비밀값, 토큰 수명 주기 관리, raw HTML 주입, 동적 코드 실행, 믿을 수 없는 script URL, 공개된 production source map.

선언된 header 집합은 config/hosting/security-headers.json이다. hosting 검증은 이 선언과 실제 응답을 비교한다. CSP는 일부러 unsafe-inline과 unsafe-eval을 뺀다. production 코드와 빌드된 asset은 이 기준선에서도 동작해야 한다. check:browser-security(FE-GATE-013)는 선언한 CSP가 'unsafe-inline', 'unsafe-eval', *, script의 scheme 통째 허용(https:)을 담으면 실패한다. 브라우저처럼 같은 지시어가 두 번이면 앞의 것을 읽고, 키워드의 대소문자를 가리지 않는다(scripts/lib/csp-policy.ts). hosting fixture (tests/fixtures/hosting/response-headers.json)는 이 header를 복사하지 않는다. fixture 모드는 선언을 그대로 답으로 쓰므로 CSP를 바꿀 때 선언 파일 하나만 고친다. tests/e2e/production-csp.spec.ts(test:e2e의 일부, FE-GATE-008)는 이 header로 빌드를 서빙한다. 그리고 securitypolicyviolation 이벤트나 console 오류가 나면 실패한다(리뷰 13-08). zod는 첫 object schema에서 Function("")을 시험 삼아 실행한다. 그러면 정책이 부트할 때마다 이것을 위반으로 보고한다. src/contracts/zod.ts는 jitless를 켜서 이 시험을 건너뛴다. schema를 만드는 모든 모듈은 z를 그 파일에서 import한다. 그래서 bundler가 chunk를 어떤 순서로 평가하든 이 설정이 첫 schema보다 먼저 적용된다. entry 모듈에서 z.config를 부르면 너무 늦다. 새 schema 코드에서는 z를 zod가 아니라 src/contracts/zod.ts에서 import한다. 기본으로 꺼진 기능은 프로젝트가 그 기능을 고를 때 CSP에 항목을 더해야 한다. 선택형 adapter recipe의 9단계를 본다. connect-src 'self' https:는 script가 모든 HTTPS origin에 닿게 둔다. 이것을 runtime config의 API_BASE_URL과 TELEMETRY_ENDPOINT origin으로 좁히려면 배포할 때 환경마다 header를 만들어야 한다. 그 값들은 배포마다 정해지기 때문이다(scripts/generate-runtime-config.ts). 그런 header 생성기는 아직 없다. 배포하는 프로젝트는 provider adapter를 만들 때 함께 더해야 한다.

route guard는 UX 힌트일 뿐이다. 클라이언트 검증은 백엔드의 인가(authorization)나 검증을 대신하지 않는다.