Strict Content Security Policy: Nonces, strict-dynamic, Report-Only and Trusted Types Against XSS
A practical guide to building a strict CSP that actually stops XSS: why host allowlists fail, per-response nonces and strict-dynamic, a safe Report-Only rollout with a report receiver, refactoring inline handlers and eval, Trusted Types for DOM-based XSS, CI tests with Playwright, common pitfalls and a checklist. With code in Node.js, Python, JavaScript and TypeScript. Expanded edition of October 17, 2026: the CSP3 evaluation model (nonce, hash, strict-dynamic and the per-browser fallback), hashes and SRI for static HTML with a build script, the complete directive map, nonces in Next.js, Express with Helmet, Django and Cloudflare Workers, third parties with a nonced loader and sandboxed iframes, fingerprint-aggregated reports in PostgreSQL, Trusted Types in depth with a default policy and migration plan, real bypasses (dangling markup, gadgets, DOM clobbering), sibling headers, a five-week case study, percentage rollout, runbook, metrics, route-wide tests, service workers and WebAssembly, FAQ and glossary.
Verificando acceso...