What it means
Your Content-Security-Policy includes 'unsafe-eval', which lets scripts turn text into code with
eval(), new Function() or string arguments to setTimeout.
Why it matters
If an attacker can get text into a value your scripts later evaluate, 'unsafe-eval' lets it run
as code. It is mostly needed by old libraries and some template engines that compile in the browser. Removing it is often the last step before a CSP gives real protection against
injected code.
How to fix it
- Remove
'unsafe-eval'from the policy in report-only mode first and watch the console for errors. - Replace
eval()andnew Function()with normal code orJSON.parse()for data. - Pass functions, not strings, to
setTimeoutandsetInterval. - Update libraries; most current versions of template engines precompile templates at build time.
- If one library still needs it, consider loading that feature in a separate page or sandboxed frame.
Check it worked
Run the HTTP and security headers check again. The finding should be gone once 'unsafe-eval' is
no longer in the policy.