Content-Security-Policy analyzer
Related tools
Validators and utilities that complement Content-Security-Policy analyzer — same session, no sign-up.
Ctrl+Enter (or ⌘+Enter) to analyze.
Split CSP into directives and surface common risk tokens (unsafe-inline, unsafe-eval, frame-ancestors *). Not a substitute for browser CSP violation reports.
Paste the raw Content-Security-Policy header value (or meta http-equiv content). Semicolon-split directives; heuristic warnings only.
How to use this tool
- Paste your sample in the input (or fetch from URL if this tool supports it).
- Run the main action on the page to execute Content-Security-Policy analyzer.
- Read the result, fix the source data or config, and re-run if needed.
What this check helps you catch
- Split CSP into directives and surface common risk tokens (unsafe-inline, unsafe-eval, frame-ancestors *). Not a substitute for browser CSP violation reports.
- Limits called out in the description (what this tool does not verify — e.g. live network reachability, issuer databases, or strict schema contracts unless stated).
- Structural or syntax mistakes that would break parsers, serializers, or the next step in your workflow.
FAQ
- What does Content-Security-Policy analyzer do?
- Split CSP into directives and surface common risk tokens (unsafe-inline, unsafe-eval, frame-ancestors *). Not a substitute for browser CSP violation reports. Use the form above, then see “How to use” and “What this check helps you catch” for behavior detail.
- Is this a substitute for server-side validation?
- No. Use it for manual checks and triage; production systems should still validate and authorize on the server.
- Where does processing happen?
- Most validators here run in your browser. If a tool calls an API, that is stated on the page. See the site privacy policy for data handling.
The Content-Security-Policy Analyzer helps you inspect a CSP header, understand how each directive is configured, and identify common weak patterns that can reduce browser-side protection. It is useful for developers, security engineers, and site owners who want to review policy strength before deployment or after a change. The tool breaks down directives such as default-src, script-src, object-src, and frame-ancestors, then highlights risky values like unsafe-inline, unsafe-eval, and wildcard sources. This makes it easier to spot misconfigurations, compare environments, and improve content security posture without manually parsing header syntax.
How This Validator Works
This analyzer reads a Content-Security-Policy header and parses it into individual directives and source expressions. It then checks for patterns that are commonly considered weak or overly permissive, such as broad wildcards, inline script allowances, or unrestricted framing rules. The goal is not to replace a full security review, but to provide a fast, structured breakdown that helps you understand what the policy is allowing and where the most obvious gaps may be.
- Splits the CSP string into directives and values
- Identifies source expressions and keywords
- Flags common weak patterns like unsafe-inline and unsafe-eval
- Highlights potentially risky framing settings such as frame-ancestors *
- Supports quick review of policy structure and coverage
Common Validation Errors
Content-Security-Policy issues often come from syntax mistakes, overly broad allowances, or directives that do not match the intended deployment. Some problems are functional, while others are security-related. A policy may parse successfully but still be weak in practice if it allows too many sources or leaves important directives unset.
- Unsafe inline scripts:
unsafe-inlinecan weaken script protection. - Unsafe dynamic evaluation:
unsafe-evalmay allow code execution patterns that are harder to control. - Wildcard sources:
*can permit broad loading behavior. - Overly permissive framing:
frame-ancestors *may allow embedding by any site. - Missing directives: important controls like
object-srcorbase-urimay be absent. - Malformed syntax: typos, missing semicolons, or invalid source tokens can break parsing.
Where This Validator Is Commonly Used
CSP analysis is commonly used during frontend development, security hardening, release validation, and incident response. Teams often run checks before deploying a new policy, after adding third-party scripts, or when reviewing a site that has been migrated to a new framework or CDN. It is also useful for audits of web application security headers and for comparing policies across staging and production environments.
- Web application security reviews
- Frontend and platform engineering workflows
- Security header audits
- Staging-to-production validation
- Third-party script and embed reviews
- Compliance and hardening checklists
Why Validation Matters
Content Security Policy is one of the browser-level controls used to reduce exposure to script injection, clickjacking-related embedding issues, and unintended resource loading. A well-formed policy can help constrain what a page is allowed to execute or display, but the protection depends on the exact directives and source expressions used. Validation matters because small configuration choices can significantly change the effective security posture of a site.
Even when a CSP is present, it should be reviewed for scope, compatibility, and operational fit. A policy that is too strict may break legitimate functionality, while one that is too loose may offer limited practical protection. Careful validation helps teams balance security and usability.
Technical Details
Content-Security-Policy is an HTTP response header defined for browsers to control resource loading and execution behavior. It uses directive-based syntax, where each directive can define allowed sources for scripts, styles, images, frames, connections, and other resource types. Common directives include default-src, script-src, style-src, img-src, connect-src, object-src, base-uri, and frame-ancestors.
| Directive | Purpose |
|---|---|
| default-src | Fallback source list for many resource types |
| script-src | Controls which script sources may run |
| style-src | Controls allowed stylesheet sources |
| object-src | Restricts plugins and embedded objects |
| frame-ancestors | Controls which sites may embed the page |
| base-uri | Restricts allowed base URL declarations |
When reviewing a policy, it is important to distinguish between syntax validity and security strength. A CSP can be syntactically correct while still allowing broad or unnecessary access.
FAQ
What does a Content-Security-Policy Analyzer check?
It checks the structure of a CSP header, breaks it into directives, and highlights values that may be too permissive or commonly associated with weaker protection. This includes broad wildcards, inline script allowances, and framing rules that may permit unwanted embedding. It is a review tool for understanding policy behavior, not a guarantee of security.
Does a valid CSP automatically mean the site is secure?
No. A CSP can be valid from a syntax perspective and still be weak in practice. For example, a policy that includes unsafe-inline or broad wildcard sources may offer limited protection against injection risks. Validation helps identify these issues, but the overall security posture depends on the full application design and other controls.
Why is unsafe-inline considered risky?
unsafe-inline allows inline scripts or styles in contexts where they would otherwise be restricted. That can reduce the effectiveness of CSP against certain injection patterns. It is sometimes used for compatibility, but security teams often prefer alternatives such as nonces or hashes when feasible.
What does frame-ancestors control?
frame-ancestors defines which origins are allowed to embed the page in a frame, iframe, object, or similar context. It is commonly used to reduce clickjacking risk and control where content can be displayed. A wildcard value like * is usually broader than necessary and should be reviewed carefully.
Can this tool detect every CSP problem?
No. It can identify common weak patterns and help you understand the policy structure, but it cannot fully assess application-specific behavior, browser compatibility, or all security implications. A complete review may also require testing, code inspection, and knowledge of how the site loads scripts and resources.
What is the difference between default-src and script-src?
default-src acts as a fallback for many resource types when a more specific directive is not present. script-src specifically governs script loading and execution. In practice, script-src is often one of the most important directives because it directly affects script injection exposure and third-party script control.
Why are wildcard sources like * often flagged?
Wildcard sources can allow content to load from many origins, which may be broader than intended. In a CSP context, that can reduce the value of source restrictions and make it harder to reason about trust boundaries. Some use cases require broad allowances, but they should be intentional and documented.
Should every site use a CSP?
Most modern web applications benefit from a CSP, especially those that render dynamic content or depend on third-party scripts. However, the policy should be designed around the application’s actual needs. A poorly configured CSP can create maintenance issues or provide a false sense of security, so it should be tested and reviewed carefully.
Related Validators & Checkers
- HTTP Header Validator
- Security Headers Checker
- URL Validator
- JSON Validator
- XML Validator
- Metadata Validator