Warning

The CSP allows inline scripts

The short version

Replace 'unsafe-inline' with nonces or hashes.

What it means

Your Content-Security-Policy allows 'unsafe-inline' for scripts (in script-src, or in default-src without a script-src) and has no nonce, hash or 'strict-dynamic' that would make browsers ignore it. Any inline script runs, including injected ones.

Why it matters

Cross-site scripting usually works by getting an inline <script> or an event handler such as onclick into a page. With 'unsafe-inline', the CSP doesn't stop that, so most of its protection is gone.

How to fix it

  1. Move inline scripts into files where you can, and replace onclick attributes with event listeners.
  2. For scripts that must stay inline, generate a random nonce per response and add it to the policy and the tag: script-src 'self' 'nonce-r4nd0m' and <script nonce="r4nd0m">.
  3. For fixed inline scripts, a hash works too: 'sha256-...' of the script's content.
  4. Add 'strict-dynamic' so scripts loaded by trusted scripts also run.
  5. Remove 'unsafe-inline'; browsers that understand nonces ignore it anyway.

Check it worked

Run the HTTP and security headers check again. The finding should be gone once the policy has no 'unsafe-inline' or pairs it with a nonce or hash.