Parse, validate and improve your CSP header. Two ways: manually enter a policy, or fetch directly from any live URL. Get instant security scoring, risk recommendations, and expert guidance.
CSP (Content Security Policy) is a browser security standard that mitigates cross-site scripting (XSS), data injection, clickjacking, and other code-injection attacks. By defining approved sources for resources (scripts, styles, images, fonts), CSP acts as a whitelist mechanism, drastically reducing the impact of vulnerabilities. This tool helps you accurately enforce a defense-in-depth strategy.
? Core Principle: “default-src 'self'” vs “script-src ‘unsafe-inline’”.
Modern web security standards (CSP Level 3) recommend strict-dynamic and nonce‑based policies to bypass unsafe‑inline while retaining functionality.
Our engine tokenizes the CSP string respecting quoted keywords and semicolon-separated directives. It validates each directive against the official CSP Level 3 directive set, flags unknown directives, and evaluates the security stance based on:
default-src when specific directives missing).
* or https: without host restrictions) that broadens allowlist.
base-uri, form-action, frame-ancestors.
report-uri or report-to).
The final security score (HIGH / MEDIUM / LOW) is assigned based on cumulative risk weightage, motivating hardening steps.
| Directive | Purpose | Example |
|---|---|---|
| default-src | Fallback for resource types not explicitly defined | default-src 'self' |
| script-src | Authorized JavaScript sources | script-src 'self' 'nonce-abc123' |
| style-src | CSS origins | style-src 'self' 'unsafe-inline' (discouraged) |
| object-src | Controls plugins (<object>, <embed>) | object-src 'none' |
| base-uri | Restricts <base> tag URLs | base-uri 'self' |
| form-action | Restricts form submission endpoints | form-action 'self' https://api.trusted.com |
| frame-ancestors | Prevents clickjacking (replaces X-Frame-Options) | frame-ancestors 'none' |
| upgrade-insecure-requests | Upgrades HTTP to HTTPS | upgrade-insecure-requests |
| block-all-mixed-content | (deprecated) blocks mixed passive content | — |
A global e-commerce platform used script-src 'self' https://cdn.thirdparty.com. After the CDN was compromised, attackers injected malicious scripts. Because the policy didn’t include ‘unsafe-inline’ and only allowed specific origins, the injected inline payload was blocked. This CSP saved thousands of users. However, they lacked a report-uri → they couldn’t detect the breach. Our inspector flags missing reporting directives, ensuring you receive violation alerts.
Modern CSP best practice replaces whitelists with nonces or hashes. The 'strict-dynamic' keyword allows scripts loaded by a trusted nonced script to execute while bypassing host-whitelist complexities. Use this tool to see if your current policy is ready for strict-dynamic migration.