Content Security Policy Inspector
Preparing workspace…
A CSP checker reviews a Content Security Policy header for directive structure and selected configurations that may weaken its protections. Paste an enforced or report-only policy, or request a live page through the restricted inspection endpoint, then inspect parsed directives, duplicate names, wildcard sources, unsafe execution allowances, and missing fallback rules. The analysis describes the policy that was actually supplied or returned; it does not infer unseen headers or certify the security of a website. A meaningful CSP review also requires checking which scripts and styles the page loads and how browsers enforce the final response.
CSP Checker At a Glance
| Aspect | Details |
|---|---|
| Accepted source | Pasted header or verified restricted HTTP page response |
| Checks | Directive names, duplicates, wildcards, unsafe-inline, unsafe-eval |
| Response types | Enforced CSP and Report-Only CSP identified separately |
| Output | Parsed directive table, findings, JSON export |
| Security boundary | Static advice, not a penetration test or complete CSP assessment |
The Purpose of a Content Security Policy
Content Security Policy is a browser-enforced mechanism that lets a website restrict where certain resources may load and, depending on the directives, which script execution paths are allowed. It is often used to reduce the impact of cross-site scripting and resource injection. A policy is a collection of directives such as default-src, script-src, style-src, img-src, and object-src, each followed by source expressions or keywords. Strong protection requires more than including a header: a policy must match the site's intended resource map while refusing unsafe alternatives. An apparently long policy can still be permissive, and a compact well-designed policy can be effective for a simple page.
How to Inspect a Live Response Correctly
A live check submits the page URL to the existing restricted server endpoint. That endpoint controls which remote addresses are reachable, follows only bounded redirects, enforces robots restrictions and request limits, and returns selected response headers from the actual HTTP exchange. When a page cannot be fetched or a relevant header is absent, the inspector reports the condition instead of constructing a policy from HTML or guessing that the target is safe. Live checks inspect one retrieved representation, not every response the site might return under different cookies, languages, paths, or authentication states. Headers added by a CDN or edge cache can also vary across requests.
Enforced Headers Versus Report-Only Headers
An enforced Content-Security-Policy header participates in the browser's resource-blocking decisions. Content-Security-Policy-Report-Only allows site owners to observe likely policy violations without immediately blocking the same resources. Both are useful, but their operational meaning differs. A report-only policy with very restrictive rules does not, by itself, protect users in the same way as an enforced policy. The checker keeps the selected header type visible in the output and adds a notice when the input is report-only. During a rollout, compare enforcement failures and violation reporting with real site behavior before tightening the production header.
What default-src Does and Does Not Cover
The default-src directive supplies fallback source restrictions for several resource types when a more specific directive is absent. Its absence does not automatically mean every resource is unrestricted, because individual directives can cover those categories explicitly. Conversely, default-src does not stand in for every directive in the entire CSP specification. It is therefore important to inspect the actual set of directives rather than relying on the presence of default-src as a single pass-fail signal. The tool records an informational finding when it is missing and calls particular attention to potentially unguarded object loading, but the full consequence must be interpreted in the context of the page.
Wildcards and Their Tradeoffs
A wildcard source may allow resources from a broader set of origins than the site actually needs. This can be convenient during early integration, especially when third-party services use several hosts, but it weakens the guarantee that scripts or other content come only from reviewed locations. The checker flags a literal asterisk in a directive without claiming that every wildcard has an identical effect. Scheme-based sources, host patterns, nonces, hashes, and dynamically inserted scripts have different rules, and the same expression can be appropriate in one resource category but not another. Replace permissive sources only after identifying necessary assets and testing actual loading behavior.
Why unsafe-inline and unsafe-eval Deserve Review
The unsafe-inline keyword permits forms of inline content that CSP often aims to restrict, while unsafe-eval can allow evaluation-like JavaScript execution paths. Their risks depend on the directive and on how the rest of the policy is constructed, including hash and nonce-based exceptions. A site that depends on inline event handlers may require a refactor before a stricter script policy can be used. The inspector identifies the literal keywords in relevant directives so they are difficult to overlook during a review. It does not attempt to simulate all browser processing rules, nonce matching, or the combined effects of multiple enforced policies.
Duplicate Directives and Policy Parsing
A CSP header commonly separates directives with semicolons and separates the directive name from its source list using whitespace. Duplicate names can cause unexpected behavior because browsers generally honor the first occurrence within a policy rather than treating every repeated entry as an additional replacement rule. The parser records repeated directive names and the raw text associated with each directive, helping reviewers find a duplicate introduced during configuration merges. This review is not a full formal grammar implementation, and unusual extensions may require manual interpretation against the current CSP specification. Copy the entire original header into bug reports so the exact sequence can be reproduced.
Example: Evaluating a Policy Before Launch
Suppose a staging server returns default-src 'self'; script-src 'self' 'unsafe-inline'; object-src 'none'. The checker identifies three directives, recognizes a narrow object source, and flags the inline-script allowance for review. Removing unsafe-inline immediately could disrupt a legacy widget that depends on inline execution, so the next step is to inventory the widget's behavior and test a nonce- or hash-based alternative. If the policy is only report-only, the team should not treat a clean page load as proof the proposed restrictions are enforced. Security decisions depend on actual application behavior as well as policy syntax.
Exporting Results for Technical Review
The output table associates each directive with its listed expressions, while the findings table separates warnings from notices. Downloading the JSON preserves the source type, selected policy mode, raw header text, and analysis observations in a machine-readable form. This makes it easier to attach the review to a ticket without paraphrasing the policy inaccurately. Sensitive application details should be handled thoughtfully, since a CSP header can reveal third-party integrations and internal naming conventions. A static report should never be labeled as a vulnerability assessment or used in place of browser developer tools and independent testing.
Connecting CSP Findings to Other Page Controls
A strict policy is most valuable as one layer among correct output encoding, careful HTML handling, dependency management, and other browser protections. Review HTML language declarations when accessibility metadata is also under inspection, but keep those findings distinct from security conclusions. For assets loaded over HTTP from HTTPS pages, mixed-content restrictions influence what browsers will request, and CSP directives such as upgrade-insecure-requests can affect outcomes. Testing should include a browser network trace, actual console reports, and the exact response headers for representative production pages rather than a single policy string in isolation.
Maintaining Policies Across Deployments
A policy that works for a static page can become incomplete when a tag manager, payment widget, consent dialog, or analytics vendor is introduced. Maintain a reviewed list of required source origins for each environment and include CSP testing in the same change process as script and stylesheet deployment. When a new violation appears, identify the initiating resource and the exact directive rather than immediately broadening default-src to allow everything. If the application uses nonces, ensure they are generated appropriately for each response and not copied as fixed strings from a sample header. Policy changes should also be reviewed against browser compatibility and existing redirects, because different document responses can arrive with different headers. The inspector can preserve a useful snapshot for comparison, but ongoing enforcement confidence comes from observing actual resource decisions, checking reports, and testing the pages that execute the most sensitive workflows.
Frequently Asked Questions About Csp Checker
Does a valid CSP guarantee protection against cross-site scripting?
No. CSP is a defense-in-depth control whose effectiveness depends on the particular directives, sources, scripts, and browser behavior. A parsing check is not equivalent to a complete application security assessment.
What happens when the server returns no CSP header?
Live inspection reports that the chosen CSP header is absent from the successfully inspected response. The tool does not invent a default policy or infer how different routes might behave.
Can I inspect report-only policies?
Yes. Select the report-only header mode and review the result separately from enforced policies. Report-only directives are advisory and do not block resource loads merely by being present.
Why is unsafe-inline reported as a warning?
It can allow inline script or style behavior that a stricter CSP would prevent. Whether and how to remove it depends on the site’s code and a tested migration plan.
Does this tool evaluate nonce and hash effectiveness?
It shows directive tokens but does not prove that a nonce is random, that a hash matches deployed bytes, or that the application correctly applies CSP to all responses.
Can a single request reveal my entire site policy?
No. Policies can differ by route, response status, logged-in state, delivery network, or environment. Review representative production responses separately.