Roll out a Content-Security-Policy header using report-only mode

domain: developer.mozilla.org · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Start by deploying the header as Content-Security-Policy-Report-Only with a permissive initial policy (default-src 'self') and a report-uri or report-to directive pointing to a CSP report collector endpoint you control
  2. Collect violation reports for at least one full traffic cycle; each report is a JSON object containing the blocked-uri, violated-directive, document-uri, and source-file fields
  3. Analyze the violation reports to identify legitimate sources that need to be added to the policy (CDN domains, inline script hashes or nonces, analytics endpoints) versus actual injections that should remain blocked
  4. Iteratively tighten the policy by adding specific source allowances for each directive (script-src, style-src, img-src, connect-src, frame-src, etc.) until violations from legitimate traffic cease
  5. Before switching to enforcement mode, deploy the same policy string in both Content-Security-Policy-Report-Only and Content-Security-Policy simultaneously to catch any remaining violations during the transition
  6. Switch to enforcement-only by removing the Report-Only header; keep the report-to directive in the enforced header to capture violations from new code paths going forward

Known gotchas

Related routes

Roll out a strict-dynamic Content Security Policy with nonce-based script trust and dual reporting endpoints before enforcing it
w3.org/TR/CSP3 · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans