Beamfar

What is Content-Security-Policy (CSP)?

Content-Security-Policy (CSP) is an HTTP response header sent by a web server or CDN that instructs the visitor’s browser which origins are permitted to load and execute JavaScript, stylesheets, fonts, images, API requests and frames on that page.

Definition
Content-Security-Policy (CSP)
An HTTP response header that restricts which scripts, styles, connections and frame ancestors a browser allows on a webpage, reducing XSS and skimmer impact.

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-to or report-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.

Guides that use this term

  • HSTSHSTS is a response header telling browsers to use only HTTPS for a site. What max-age and includeSubDomains do, and why an expired certificate then hurts.
  • TLS certificateA TLS certificate proves a website holds the name in the address bar and enables HTTPS. What it contains, how long it lasts, what expiry breaks.

Try it on your own sites.

Add your sites: checking starts as soon as you do.

No card for the Free plan.