Apex Flow Shield Free scan
Menu

What is a Content Security Policy?

A Content Security Policy (CSP) is a set of rules that tells the browser what a page may load and run: scripts, styles, images, frames and more. Websites usually send it in a Content-Security-Policy response header. A well-built, enforced policy can stop injected scripts from running, an attack called cross-site scripting (XSS), because the browser runs only the scripts the policy allows. It is the largest single item in the Shield scan: 20 of 100 points.

What the Shield scan checks

Content Security Policy, worth 20 of 100 points. Shield requests your HTTPS home page, follows up to four HTTPS redirects and reads the headers of the final response. The check passes when the Content-Security-Policy header contains the text script-src or default-src, in any letter case. Shield does not judge how strict or correct the policy is, and a policy set only in a meta tag earns no points.

If the check fails, the scan tells you: Send a Content-Security-Policy that limits where scripts can load from.

What a policy looks like

A basic example for a simple HTTPS site that loads its resources from its own origin. It blocks scripts and other resources loaded from other origins, plus inline scripts and styles. It has no form-action rule, so HTML forms could still submit to an outside service; add form-action to restrict that.

Content-Security-Policy: default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'

How to add one without breaking your site

  1. Open the Network panel in your browser's developer tools, reload the page, and test checkout, login, forms, analytics and chat. Note which services the browser contacts during each test.
  2. Send the draft policy as Content-Security-Policy-Report-Only first and look in the console for its violations. The draft only reports; any policy you already enforce still applies.
  3. Avoid relying on 'unsafe-inline' for scripts: when the browser honors it, injected inline code can run. Move inline code into files, or allow a specific inline script with a nonce (a fresh random value generated for each response that sends the policy) or a hash (a fingerprint of that exact script). OWASP's strict policy section covers this for developers.
  4. Repeat the checkout, login and other key tests with the draft active, then with the policy enforced on a test copy of the site. When everything works, send the same policy as Content-Security-Policy on the live site.
  5. Test again whenever you add a new third-party tool.

Common mistakes

This website's own policy

On 27 November 2026, Shield's policy allowed scripts only from its own origin (script-src 'self'), blocked all framing (frame-ancestors 'none') and disallowed HTML form submissions (form-action 'none'). The Proof page shows how to read the full policy in your browser.

Check your Content Security Policy now

Type your website address to run the free scan. It checks this and the other 10 items. No account, no email.

The interactive scan needs JavaScript. See the checks you can run yourself.

Questions

Does a Content Security Policy stop all cross-site scripting?

No. It limits what injected code can do, which is why OWASP describes it as defense in depth. You still need to fix the bugs that let code be injected in the first place.

What is Content-Security-Policy-Report-Only?

A header for testing. The browser records violations of that policy without enforcing it: they appear in the browser console and can be sent to a reporting address. Any enforced policy you also send still applies.

Can I set a Content Security Policy in a meta tag?

Browsers accept most of a policy in a meta tag, but not frame-ancestors, report-uri or sandbox. The Shield scan reads the response header, so a policy set only in a meta tag earns no points.

Why did my policy break my analytics or chat widget?

A third-party tool may load a script, an image or a frame, or send data to its own service, and your policy can block any of these requests. Open the browser console to see which request was blocked, then allow just what that tool needs in the matching rule: script-src for scripts, img-src for images, frame-src for embedded frames or connect-src for data requests such as fetch or WebSocket calls.

Sources

Written by Apex Flow Labs LLC for Apex Flow Shield. A score of 100 means the responses Shield received passed all 11 of its checks. It does not prove each setting is configured well, and no scan can show that a website cannot be attacked.

All website security guides