Why CSP exists
Without CSP, browsers follow the same-origin policy for reading cross-origin responses, yet they happily execute any inline <script> tag or third-party <script src="..."> embedded in a page’s HTML. If an attacker exploits a Cross-Site Scripting (XSS) flaw or compromises a CMS plugin to inject a payment skimmer, the browser runs the attacker’s code with full access to the DOM, checkout fields and non-HttpOnly tokens.
A strict CSP breaks that chain by requiring scripts to either match a per-request cryptographic nonce ('nonce-...'), match a SHA-256 hash, or originate from explicitly allowlisted HTTPS hosts — while blocking object-src 'none', locking base-uri 'self' and preventing clickjacking via frame-ancestors.
Check it now. The Content-Security-Policy (CSP) checker audits HTTP and meta Content-Security-Policy headers against XSS bypasses (unsafe-inline, unsafe-eval, wildcards, missing object-src/base-uri), frame-ancestors clickjacking rules and live third-party script hosts; the security headers checker reads a page’s HSTS, CSP, X-Content-Type-Options, frame protection, Referrer-Policy and Permissions-Policy. No account, and the address is not stored.
Report-Only vs Enforcing headers
Browsers support two distinct HTTP headers:
Content-Security-Policy-Report-Only: Evaluates every rule and logs violations to the browser console and an optional reporting endpoint (report-toorreport-uri) without blocking any resource. Teams use this header first in production so analytics, payment gateways and checkout widgets do not break unexpectedly.Content-Security-Policy: Actively blocks any script, style, form submission or frame that violates the declared directives.
HTML <meta http-equiv="Content-Security-Policy"> tags can enforce fetch directives like script-src, but browsers intentionally ignore frame-ancestors, report-uri and sandbox inside <meta> tags, so HTTP headers are always preferred.
What to check on a live site
Verify that an enforced HTTP Content-Security-Policy header is present over HTTPS, that script-src avoids bare 'unsafe-inline' (unless paired with a fresh nonce, hash or 'strict-dynamic'), 'unsafe-eval' and wildcard *, that object-src 'none' and base-uri are set, and that frame-ancestors protects the page from clickjacking. You can test any public page immediately in the Content-Security-Policy (CSP) checker.
Sources
Read on . Standards and vendor pages change; confirm the current text before you rely on it.
- W3C Content Security Policy Level 3 (www.w3.org)
- MDN Web Docs, Content-Security-Policy (developer.mozilla.org)