Content Security Policy: how it works, where it fails, and how to keep it under control.
A Content Security Policy tells the browser which origins a page may load code from, and refuses everything else.1 CSP Rules covers the specification, the incidents that test it, and the practice of maintaining a policy over time. Every claim is cited.
default-src 'self';
script-src 'self' cdn.optimizely.com *.cloudfront.net static.hotjar.com; # owner: unknown · added: unknown · in use: unknown
connect-src 'self' api.stripe.com;
report-to csp-endpoint
CSP Ledger
Every source in a Content Security Policy is a trust decision. The header records what is allowed, but not who decided, why, or until when. CSP Ledger keeps that record for each source, tied to the reports that show whether it is still in use.
A record per source
Owner, requester, justification, approval, scope and review date for every source and directive.
Usage from reports
CSP reports attached to each record show whether a source is used, unused, or suddenly violated.
A change workflow
Sources are requested, reviewed and approved before the header is generated. Risky values are refused at request time.
Known scope on incident
When a vendor is compromised, its pages, owners and directives are already listed.
Why policies fail
- 94.72%
- of 26,011 distinct real-world policies could be bypassed, in a 2016 study of 1.68 million hosts. Unreviewed allowlist entries were the most common cause.2
- PCI 6.4.3
- PCI DSS v4.0.1 requires an inventory of payment-page scripts with a written justification and an authorisation for each. Mandatory since 31 March 2025.3
- ~178
- organisations served attacker code through a trusted vendor's CDN on 16 November 2026. Each had to establish, under time pressure, which pages trusted that vendor.4
OPTIMJACK. Malicious JavaScript was served from Optimizely's CDN to visitors of approximately 178 organisations.4,5 Incident analysis. Earlier incidents with the same pattern. Test a policy against it.
Reference
Policy test
Evaluates a pasted policy against each OPTIMJACK technique and lists general weaknesses. Runs locally.
IncidentsUnmaintained policies, 2018–2026
British Airways, Ticketmaster, Polyfill.io, OPTIMJACK and others, grouped by the policy failure they share.
GuideHow CSP works
Delivery, fallback rules, allowlists compared with nonces, reporting, and staged rollout.
ReferenceDirectives
Fetch, document and navigation directives, with fallback order and risk per source value.
ReferenceSending a CSP header
Tested configuration for nginx, Apache, Caddy and HAProxy, plus IIS, Cloudflare, Netlify and Vercel.
ComparisonCSP tools compared
Reporting services, client-side security platforms and plugins, from their own published descriptions.
References
- [1]Content Security Policy Level 3. W3C, Web Application Security Working Group. Working Draft. The normative definition of directives, source matching and fallback.
- [2]CSP Is Dead, Long Live CSP! On the Insecurity of Whitelists and the Future of Content Security Policy. Weichselbaum, Spagnuolo, Lekies, Janc. ACM CCS, 2016. Analysis of 26,011 unique policies from 1,680,867 hosts.
- [3]PCI DSS v4.0.1, Requirements 6.4.3 and 11.6.1. PCI Security Standards Council. Payment-page script inventory, authorization and tamper detection. Mandatory from 31 March 2025.
- [4]Optimizely supply-chain attack hits at least 178 organisations. BreachHistory, Nov 2026. Timeline, indicators of compromise and remediation steps. Cites Report URI's snippet scan.
- [5]CNN, Zoom, Fox News served visitors a crypto-stealing skimmer. Amirul Cyber, 16 Nov 2026. Original disclosure. Names the campaign OPTIMJACK.