webzod
account

Remove 'unsafe-eval' from script-src on Cloudflare

headers.csp.script_unsafe_eval · effort: a project

Why it matters

'unsafe-eval' lets text be run as code through eval() and similar functions, which turns many injection bugs into code execution. Most current libraries no longer need it.

Staged change. Do this in stages and check each one before the next, so a mistake does not break your site or your mail.

The fix

  1. Stage 1: add a Response Header Transform Rule with Set static, header Content-Security-Policy-Report-Only and your current policy without 'unsafe-eval', then check the reports.
  2. Stage 2: after replacing the eval uses, remove 'unsafe-eval' from wherever the enforced policy is set and delete the report-only rule.

Read the documentation (opens in a new tab)

Scan your domain to see whether this applies to you.