Tools / CSP evaluator
Content Security Policy (CSP) evaluator
Inspect the enforced CSP response header and flag common risky source expressions or missing defensive directives.
More free checks
Run a full security scan or speed test on your site, or try a related tool.
Related free tools
Common checks
- Script sources and use of
'unsafe-inline','unsafe-eval', or wildcards. object-src,base-uri,form-action, andframe-ancestors.
This is a heuristic policy review, not an XSS test or proof of security. CSP Report-Only headers are not enforced and are not treated as an active policy.
What a CSP is actually for
A Content Security Policy is a second line of defence. It does not stop an injection bug from existing; it limits what an injected payload can do once it is on the page. Treating CSP as a substitute for output encoding and input validation is the most expensive mistake you can make with it — a policy is worth having precisely because the first line will eventually fail somewhere.
That framing matters when you read a result. A page with a strict policy and an XSS hole is still vulnerable; the policy just narrows what an attacker can reach. A page with no policy and no bugs is fine today and defenceless the moment a bug appears.
Why 'unsafe-inline' undoes most of the benefit
The headline reason to deploy CSP is to stop injected <script> from
executing. script-src 'unsafe-inline' permits exactly that, which is why a policy
containing it provides very little script protection no matter how long the rest of the
header is. The same goes for 'unsafe-eval', which re-opens eval(),
new Function() and string arguments to setTimeout.
There are two supported ways out, and both require touching the application:
- Nonces. Generate a fresh random value per response, put it in the header as
'nonce-<value>'and on every legitimate inline script. A nonce reused across requests, or one that an attacker can predict or read back out of the page, is worthless — it has to be unguessable and single-use. - Hashes. Pin the SHA-256 of each inline script with
'sha256-<digest>'. Good for static markup; every edit to the script means a new digest, so it is brittle on pages that change often.
One wrinkle catches people out: in modern browsers, specifying a nonce or hash causes
'unsafe-inline' to be ignored for that directive. That is deliberate, and
it is how you keep a fallback for very old browsers without weakening current ones.
Allowlists age badly
Listing CDNs and vendor domains feels safe and usually is not. If any allowlisted host serves a JSONP endpoint, an unrestricted file upload, an old copy of AngularJS, or any library with a usable gadget, an attacker can route an injection through it and your policy approves the request. Published research has repeatedly found that a large share of real-world allowlists contain at least one bypassable host.
This is the reasoning behind strict-dynamic: trust scripts you explicitly nonce or hash, let those scripts load their own dependencies, and stop trying to enumerate hostnames. It is harder to retrofit, and it is the direction a serious policy eventually goes.
The directives people forget
object-src 'none'— blocks<object>and<embed>, legacy script-execution routes thatscript-srcdoes not cover. Cheap to set and almost never breaks anything.base-uri 'self'— without it, an injected<base>tag can repoint every relative script URL on the page at an attacker's host. This bypasses a hostname allowlist entirely, and it is the most commonly missing directive we see.form-action— restricts where forms may submit. Absent, an injected form can post your user's input anywhere.frame-ancestors— the modern replacement forX-Frame-Options, and the clickjacking control that actually supports a list of permitted parents.default-src— the fallback. Note it does not coverbase-uri,form-actionorframe-ancestors; those have to be named explicitly.
Rolling one out without breaking the site
Deploy as Content-Security-Policy-Report-Only first with a
report-uri or report-to endpoint, leave it long enough to cover real
traffic rather than your own testing, then read the reports before you enforce. Expect noise:
browser extensions generate violations you cannot fix and should not chase.
Enforce in stages. Promote the directives whose reports are clean and leave the rest reporting — a policy that is half enforced and half measured beats one that is entirely aspirational. Be aware this tool reads the enforced header only; a Report-Only policy is deliberately not counted as protection, because it blocks nothing.
Related checks: security headers analyzer and CORS policy checker. If you are introducing a policy to an application that already relies on inline script, we test the injection paths a CSP is meant to contain.
Frequently asked questions
How do I add a Content Security Policy without breaking my site?
Start with the Content-Security-Policy-Report-Only header. Browsers then report what the policy would block without blocking it. Fix or allow each legitimate source, then switch to the enforcing header.
Should I use nonces or hashes?
Nonces suit pages generated by a server: a new random value on each response, added to every <script> tag. Hashes suit static pages whose inline scripts never change. Both let you drop 'unsafe-inline'.
Can I set a CSP in a meta tag?
Yes, with <meta http-equiv="Content-Security-Policy">, but some directives — frame-ancestors, report-uri and sandbox — only work as an HTTP header. The header is the better choice whenever you control the server.
Why is my Report-Only policy not graded?
A Report-Only policy is not enforced, so it gives visitors no protection yet. The evaluator grades only the policy browsers actually apply.