Detector registry

Content-Security-Policy Strength: Is unsafe-inline Undoing Your CSP?

Your CSP exists, but does it restrict scripts? How LaunchTrust reads script-src for unsafe-inline, wildcards and unsafe-eval, and how to tighten it.

Updated 10 Nov 2026csp unsafe-inlineSignals, not a verdict

A Content-Security-Policy (CSP) tells the browser which scripts may run on your page. Shipping one is a good start, and the security headers check confirms it exists. But a policy that allows 'unsafe-inline' or any https: source lets an injected script run anyway, so the header is present while most of its protection is gone. This check looks at how much your policy actually restricts.

What LaunchTrust checks

LaunchTrust reads the enforced policies on your public page: the Content-Security-Policy header and any <meta http-equiv="Content-Security-Policy"> tag in the document head (browsers ignore one placed in the body). Report-only policies are not enforced, so they are not evaluated. For each policy it looks at the script sources the way browsers apply them: script elements follow script-src-elem and inline event handlers follow script-src-attr, both falling back to script-src and then default-src. eval() and new Function() follow script-src, then default-src.

  • Detected: the enforced policies together restrict scripts without the weaknesses below.
  • Not detected (low): the enforced policies together leave a weakness: no script-src or default-src, or script elements, inline event handlers or eval() left unrestricted; 'unsafe-inline' without a nonce or hash; a wildcard (*) or a whole scheme (https:, http:, data:, blob:); or 'unsafe-eval'. This is listed in the report but not counted as a gap.
  • Unable to determine: no enforced policy exists. A missing CSP is reported by the security headers check instead, so it is not counted twice.

LaunchTrust follows browser rules: when a well-formed nonce or hash (such as 'nonce-r4nd0m', not a bare 'nonce-') or 'strict-dynamic' is present, browsers ignore 'unsafe-inline', and with 'strict-dynamic' they also ignore host and scheme allowlists. Those policies are treated as restrictive. When a page has several enforced policies, a script must pass every one of them, so a weakness counts only when all of the policies allow it. The whole policy is read, however long it is.

Why it matters

  • CSP is your second line against script injection. If an attacker finds a way to inject markup, a restrictive script policy stops the injected code from running.
  • 'unsafe-inline' switches that off. Inline scripts are exactly what an injection produces, so allowing them without a nonce or hash removes most of the benefit.
  • Wildcards allow scripts from anywhere. https: lets any HTTPS site serve scripts to your page, including one the attacker controls.

A concrete example

A policy LaunchTrust reports as not detected (low):

content-security-policy: default-src 'self' 'unsafe-inline' https:

A policy it reports as detected:

content-security-policy: script-src 'nonce-r4nd0m' 'strict-dynamic'; object-src 'none'; base-uri 'none'

How to address it

  1. Start in report-only mode. Send the stricter policy as Content-Security-Policy-Report-Only first, watch the reports, then switch it to enforced.
  2. Use nonces or hashes for inline scripts. Generate a fresh nonce per response and add it to each <script> tag, or list the hashes of fixed inline scripts.
  3. Replace wildcards with exact origins. List the specific domains your scripts come from instead of https: or *.
  4. Remove 'unsafe-eval' where you can. Most modern builds do not need it; if a library does, consider replacing it.
  5. Check the result. Reload the page with developer tools open and confirm nothing is blocked that should run.

Monthly check and monitoring scope

List your app for free and LaunchTrust runs all 38 website detectors on its public website once a month, then emails you how many gaps it found. Which gaps they are, the evidence and how to close them come with paid monitoring or a one-time Launch Audit.

Paid monitoring runs all 40 detectors (38 for websites and 2 for App Store and Google Play listings) and shows each finding with its evidence. Each monitored web app is re-scanned about every 24 hours (with ±6 hours of jitter); email alerts and an optional JSON webhook POST report new gaps.

FAQ

Why is a weak CSP only low severity? A CSP is defense in depth: it limits the damage of another flaw rather than being a flaw itself. A missing CSP is the larger gap and is reported separately by the security headers check.

Does this check other directives such as frame-ancestors or object-src? No. It evaluates script sources only. Framing protection is part of the security headers check.

My CSP is report-only. Why is it not evaluated? Browsers do not enforce report-only policies, so they do not restrict scripts. Switch it to an enforced Content-Security-Policy once you are happy with the reports.

Compliance aid, not legal advice. LaunchTrust reports signals, not a verdict or certification.