Loading...
Loading...
Validate your CSP in one scan - catches the mistakes linters miss.
Hands off to the full WebShield scanner, which covers this check alongside every other header, DNS and email auth probe.
A Content-Security-Policy header is only useful if it actually constrains what your browser will execute. Most real-world CSPs drift into permissive territory - a forgotten `unsafe-inline`, a wildcard `*.cloudfront.net` that swallows half the internet, or a missing `frame-ancestors` that leaves the door open for clickjacking. WebShield's CSP checker parses the header straight off your live response, flags every directive that weakens the policy, and hands you a tightened version.
CSP is the single most effective browser-side mitigation for XSS, data exfiltration and clickjacking. A tight policy downgrades a critical XSS to a noisy console error. A sloppy policy is security theatre - it looks like a header, but every attacker vector you cared about is still wide open.
WebShield fetches your target URL, reads the Content-Security-Policy response header (or the meta equivalent), tokenises each directive, and scores it against the Google CSP Evaluator ruleset plus the OWASP recommendations. The scanner does not execute JavaScript on your page - it inspects headers and reports.
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'nonce-{{RANDOM}}' 'strict-dynamic'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; form-action 'self';" always;Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'strict-dynamic' 'nonce-{{RANDOM}}'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; form-action 'self';"{
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "Content-Security-Policy",
"value": "default-src 'self'; script-src 'self' 'strict-dynamic' 'nonce-{{RANDOM}}'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; form-action 'self';"
}
]
}
]
}// Cloudflare Worker / Transform Rule
response.headers.set(
"Content-Security-Policy",
"default-src 'self'; script-src 'self' 'strict-dynamic' 'nonce-{{RANDOM}}'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; form-action 'self';"
);Begin with Content-Security-Policy-Report-Only so violations are logged but nothing is blocked. A sensible baseline is default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none';. Add script-src and style-src using nonces or hashes once you know what your pages legitimately load.
'unsafe-inline' lets any inline <script> or onclick= attribute execute - which is exactly what reflected and stored XSS payloads inject. The whole point of CSP is to refuse unauthorised code, and unsafe-inline disables that protection.
Yes, for any browser that supports CSP level 2+. frame-ancestors is strictly more expressive: it allows multiple origins, wildcards per path, and source expressions. Modern guidance is to set frame-ancestors and keep X-Frame-Options: DENY only as a belt-and-braces fallback for legacy proxies.
strict-dynamic tells the browser to trust scripts that are loaded by an already-trusted (nonced or hashed) script. This lets you retire host allowlists - which are trivial to bypass - and rely on nonces instead, which is the Google-recommended modern pattern.