What is CSP (Content Security Policy) Evaluator?
CSP Evaluator analyzes a Content Security Policy header value for security weaknesses, bypass vectors, and common misconfigurations. Paste a CSP header value to get a detailed security report: which directives are present, which are missing, which allow unsafe patterns (unsafe-inline, unsafe-eval, wildcard sources), and practical recommendations to tighten the policy without breaking your site.
Content Security Policy (CSP) is an HTTP response header that tells browsers which sources of content (scripts, styles, images, fonts, frames) are allowed to load on a page. It's the primary defense against Cross-Site Scripting (XSS) — an attacker who injects a script tag still can't execute arbitrary code if the CSP blocks inline scripts and restricts script sources. A strict CSP is one of the most impactful security headers you can implement.
A typical CSP directive: script-src 'self' https://cdn.example.com 'nonce-{random}' — allows scripts from the same origin, from cdn.example.com, and inline scripts with the matching nonce. Nonces (one-time random values) allow specific inline scripts while blocking injected ones. Hashes are an alternative to nonces for static inline scripts. default-src is the fallback for directives not specified. Missing directives that should be set: frame-ancestors (clickjacking), upgrade-insecure-requests, and base-uri.
How to Use
- Paste the Content-Security-Policy header value (not including the header name) into the input.
- Read the security report: each directive is analyzed with a safety rating (safe, caution, unsafe).
- Click on any issue to see a detailed explanation and the specific bypass vector it enables.
- Use the 'Suggested CSP' panel to see a tightened version of your policy.
- Click 'Test report-only' to get a Content-Security-Policy-Report-Only header for non-blocking monitoring.
Examples
Basic CSP analysis
Result: script-src 'self' 'unsafe-inline' → UNSAFE: unsafe-inline allows XSS; use nonces instead
Detect wildcard bypass
Result: script-src *; → CRITICAL: wildcard allows loading scripts from any domain
Check for clickjacking protection
Result: Missing frame-ancestors → WARNING: add 'frame-ancestors none' or 'frame-ancestors self'
Frequently Asked Questions
What is unsafe-inline and why is it dangerous?
unsafe-inline allows execution of inline JavaScript () and inline event handlers (onclick='code'). This completely defeats CSP's XSS protection — an attacker who injects a . Only scripts with the matching nonce execute. Since the nonce is random and changes each request, an attacker can't predict it even if they can inject HTML. For nonces to work, the nonce must be cryptographically random (not derived from user input or the URL).
What does 'report-only' mode do?
Content-Security-Policy-Report-Only sends the same header but the browser only logs violations — it doesn't block them. Use this to test a new CSP on a production site without breaking anything. Configure report-to to send violation reports to your monitoring service (report-uri.com, Sentry, or your own endpoint). After confirming no legitimate violations, switch to the enforcing Content-Security-Policy header.
What is frame-ancestors and how is it different from X-Frame-Options?
frame-ancestors is a CSP directive that controls which origins can embed your page in ,
What is the minimum effective CSP?
A minimum useful CSP that protects against XSS: default-src 'self'; script-src 'self' 'nonce-{random}'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'. object-src 'none' blocks plugins (Flash, Java applets — attack vectors). base-uri 'self' prevents base tag injection (attackers can't change the base URL to redirect all relative URLs). For sites with no inline scripts, removing 'nonce-{random}' gives the strongest protection.
Related Tools