{ CSP Policy Analyzer }

// break down csp directives and flag risks instantly

Analyze Content Security Policy headers instantly. Break down CSP directives, flag missing protections, and detect overly permissive values that risk XSS attacks.

Paste the full Content-Security-Policy value (without the header name itself)
Try an example:
🛡️

Ready to analyze

Paste your CSP header and click Analyze

HOW TO USE

  1. 01
    Get Your CSP

    Open DevTools → Network → click any request → Response Headers → copy the Content-Security-Policy value.

  2. 02
    Paste & Analyze

    Paste the policy string (just the value, not the header name) and click Analyze CSP.

  3. 03
    Review & Harden

    Read the score, critical issues, warnings, and missing directives. Use the recommendations to tighten your policy.

FEATURES

Directive Parser Risk Detection Security Score Missing Checks Nonce/Hash Support Wildcard Flags

USE CASES

  • 🔧 Audit CSP before production deploy
  • 🔧 Debug CSP violations in the browser
  • 🔧 Validate policy in security reviews
  • 🔧 Learn CSP directives interactively
  • 🔧 Check third-party CMS CSP headers

WHAT IS THIS?

This tool parses Content-Security-Policy header values and breaks every directive down to show exactly which sources are allowed. It flags dangerous values like 'unsafe-inline' and 'unsafe-eval', highlights wildcards, detects missing critical directives like frame-ancestors, and gives your overall policy a strength score from 0 to 100. All processing is done entirely in your browser — nothing is sent to a server.

RELATED TOOLS

FREQUENTLY ASKED QUESTIONS

What is a Content Security Policy (CSP)?

A Content Security Policy is an HTTP response header that instructs browsers which resources a page may load. It is a layered defense against XSS attacks — even if an attacker injects a script tag, CSP can prevent it from executing if the source is not whitelisted.

Why is 'unsafe-inline' flagged as a critical issue?

'unsafe-inline' in script-src allows any inline script to execute — including scripts injected by an attacker. This nullifies the primary XSS protection CSP provides. Use nonces ('nonce-abc123') or hashes ('sha256-…') to allow specific inline blocks safely.

What does 'unsafe-eval' allow?

'unsafe-eval' permits JavaScript's eval(), new Function(), and setTimeout/setInterval with string arguments. If user input ever reaches these functions, code injection is possible. Remove it and refactor to avoid dynamic code evaluation.

Is the wildcard (*) always dangerous?

A wildcard in script-src is extremely dangerous — it allows scripts from any domain including attacker-controlled ones. In other directives like img-src * the risk is lower but still broad. Replace wildcards with specific trusted domains wherever possible.

What is 'strict-dynamic' and should I use it?

'strict-dynamic' allows scripts trusted via a nonce to load additional scripts without those needing to be whitelisted. This simplifies policies for apps that load scripts dynamically. Use it paired with a per-request nonce for the strongest modern CSP approach.

Why does frame-ancestors matter?

frame-ancestors controls which origins can embed your page in an iframe. Setting it to 'none' or 'self' prevents clickjacking attacks — it is the modern replacement for the X-Frame-Options header and should always be set explicitly.

What is report-uri and why should I use it?

report-uri (or the newer report-to) sends CSP violation reports to an endpoint you control. This lets you monitor violations without breaking the site — invaluable for tuning policies and detecting real attacks in production without enforcement risk.

Is my CSP data sent to any server?

No. All analysis is performed entirely in your browser using JavaScript. Your CSP string never leaves your machine. The tool is 100% client-side and private — safe to use with production CSP values.

What Is a CSP Policy Analyzer?

A CSP Policy Analyzer is a developer tool that parses the value of a Content-Security-Policy HTTP header and breaks it into its individual directives. It shows you exactly which sources are allowed for scripts, styles, images, fonts, frames, and other resource types, then flags dangerous patterns, highlights missing protections, and scores your policy's overall security strength.

💡 Looking for premium web development assets? MonsterONE offers unlimited downloads of templates, UI kits, and security-conscious themes — worth checking out.

Why Content Security Policy Matters

Cross-Site Scripting (XSS) consistently ranks among the most critical web vulnerabilities. Despite decades of awareness, XSS remains rampant because it is easy to introduce through template rendering, third-party widgets, or improperly sanitized user input. Content Security Policy is the browser-enforced mechanism that limits the damage a successful injection can cause.

When implemented correctly, CSP prevents injected scripts from executing, stops sensitive data from being exfiltrated to attacker-controlled domains, and blocks clickjacking through the frame-ancestors directive. However, CSP is notoriously easy to misconfigure — a single overly permissive value can render the entire policy ineffective while giving developers a false sense of security.

Core CSP Directives You Should Know

Every CSP is composed of directives, each governing a specific resource category:

What Makes a CSP Weak?

Several patterns consistently make CSP policies ineffective. The most dangerous is 'unsafe-inline' in script-src — this single value allows any inline script tag to execute, including those injected by attackers. Similarly, 'unsafe-eval' enables dynamic code execution through eval() which can be exploited if user input reaches it.

Wildcard sources (*) in script-src are equally damaging — they allow scripts from any domain on the internet including attacker-controlled servers. Missing directives like frame-ancestors leave clickjacking protections absent. Omitting object-src without a default-src fallback can enable Flash-based exploitation on older browsers.

Building a Modern Strict CSP

The recommended approach for modern web applications combines nonces with 'strict-dynamic'. Each page request generates a cryptographically random nonce. The server adds this nonce as an attribute to trusted script tags and includes it in the CSP header. 'strict-dynamic' then allows those nonce-bearing scripts to load additional scripts without needing to whitelist every CDN domain explicitly.

A strong modern policy for a typical SPA might look like this:

default-src 'self';
script-src 'nonce-{random}' 'strict-dynamic';
style-src 'self' 'nonce-{random}';
img-src 'self' data: https:;
font-src 'self' https://fonts.gstatic.com;
connect-src 'self' https://api.yourdomain.com;
frame-ancestors 'none';
object-src 'none';
base-uri 'self';
form-action 'self';
upgrade-insecure-requests;
report-uri https://csp.yourdomain.com/report;

Testing and Deploying CSP Safely

Never deploy a new CSP directly in enforcement mode on a production site without testing. Use Content-Security-Policy-Report-Only first — this sends violation reports to your report-uri endpoint without actually blocking anything. Collect data for one to two weeks, analyze the violations, add necessary sources, then switch to enforcement. This prevents unexpected breakage from third-party scripts, analytics, or embedded content you may have overlooked.