feat(csp): promote Trusted Types from report-only to enforcing (#130)#718
feat(csp): promote Trusted Types from report-only to enforcing (#130)#718millsmillsymills wants to merge 2 commits into
Conversation
Fold `require-trusted-types-for 'script'; trusted-types default` into both enforcing CSP headers (site + webauthn policies) and drop the standalone `Content-Security-Policy-Report-Only` TT slices. The runtime is enforce-clean (#711 removed the last injection sinks); the one legitimate sink — the PoW Worker URL — is wrapped by the fail-closed `default` policy in src/scripts/util/trusted-types.ts. Updates the /security/ control entry to match. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add scripts/assert-tt-policy-names.sh: extract the policy names from the
`trusted-types` directive in infra/cloudfront.tf locals and compare them
bidirectionally against every createPolicy('<name>') call site under src/
and public/. Fails when a name is declared without a call site, or a call
site uses a name the directive does not allowlist — drift that ships green
today and throws at runtime once the CSP flips to enforce (#130/#718).
Wired into scripts/ci-local.sh and the Astro CI job in lockstep.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Soak status check — 2026-06-11Re-queried Why: 18:33 UTC ( Consequence: three reports landed at 22:53–22:54 UTC 06-09, all Since the real anchor (23:39:45 UTC): zero CSP reports of any kind in the bucket (last object 22:54:27 UTC 06-09), plus a clean Verified live: report-only header serves Revised earliest merge: ~2026-06-23 (still ≥2 weeks from 06-09; the corrected anchor is only ~5h later, so the date is unchanged). Gate unchanged otherwise: re-query at soak end, merge latest main into the branch first (#719 landed after the rebase), then mark ready → merge → deploy → |
|
Merged |
Replaces #712 (same change, rebased onto main
2fc8e5fpost-#715; the old branch could not be force-pushed under the repo's git guardrails).Promotes Trusted Types from the parallel
Content-Security-Policy-Report-Onlyheader into the enforcing CSP, closing #130:infra/cloudfront.tf: foldsrequire-trusted-types-for 'script'; trusted-types default unifi-demointolocal.html_csp; removes thehtml_tt_report_onlylocal and both-Report-Onlyheader blocks. Both allowlisted policy names survive the flip —default(site bundle,src/scripts/util/trusted-types.ts) andunifi-demo(public/apps/unifi-demo/app.js).src/data/security-controls.ts: the singletrusted-typesentry flips to "enforced", citing cloudfront.tf, trusted-types.ts, mail-pow.ts, and the unifi-demo app.src/scripts/util/trusted-types.ts: comment scoped — thedefaultpolicy defines no createHTML; the unifi-demo asset mints its markup via its own allowlisted policy.terraform fmt/validate,npm run check, and a fullnpm run buildpass.Draft until the report-only soak completes (~2026-06-23; clock started 2026-06-09 23:39:45 UTC — the #715/
2fc8e5fdeploy that shipped the fixed unifi-demoapp.js; the earlier 18:33 UTC deploy predated that fix, so the 22:53 UTC 06-09 reports are stale pre-#715 noise, not enforce-blockers — see soak-status comment). Before merging: re-querys3://millsymills.com-csp-reports/reports/and confirm zero post-soak-startrequire-trusted-types-forreports, then mark ready, merge, deploy,terraform apply.Related: #716 (CI assert coupling TT policy names between directive and createPolicy call sites).
🤖 Generated with Claude Code