The policy allows eval()
What this check looks for
The policy lets the page turn text into running code. Anything that can control that text can run code on your site.
Why it matters
eval() converts data into instructions. With it permitted, an attacker who can influence a string — a URL parameter, a stored value, a JSON response — may be able to execute code without ever injecting a <script> tag.
When the check passes, your report says: “The policy blocks eval() and other text-to-code conversion”.
What it costs your score
When this check fails it removes 8 points from your Web security score, before the status, confidence and repeat multipliers are applied. Web security carries a weight of 8 in the overall score.
It shares the web-security.csp family ceiling of 30 points: however many findings that family produces, together they cannot remove more than that from Web security. One underlying problem showing up in several places is still one problem.
- Severity
- medium
- Default confidence
- confirmed
- Status when triggered
- warn
- Deduction
- 8 points
- Family cap
- web-security.csp · 30
- Category
- Web security
- Module
- Web security headers
- Fix owned by
- user
- In the ruleset since
- 2026.09
How to fix it
Remove 'unsafe-eval' and the code that needs it.
It turns any attacker-influenced string into a potential code path.
Find what needs it: the browser console names the file when the policy blocks it.
Switch to a framework build with pre-compiled templates.
Confirm this is a production build — development builds commonly require eval.
How to confirm it worked
curl -sSI https://‹host›/ | grep -i content-security-policy
A named slot like ‹domain› — and the braces left in the configuration below — is filled in with your own values when this rule appears on a report.
Remediation by platform
add_header Content-Security-Policy "script-src 'self' 'nonce-‹random›'" always;<IfModule mod_headers.c>
Header always set Content-Security-Policy "script-src 'self' 'nonce-‹random›'"
</IfModule>header {
Content-Security-Policy "script-src 'self' 'nonce-‹random›'"
}Rules → Overview → Create rule → Response Header Transform Rule → Set static → Content-Security-Policy = script-src 'self' 'nonce-‹random›'
(Dashboard path as at 2026-09; Cloudflare reorganised these pages and may again.)The
alwaysflag matters: without it nginx omits the header on error responses, which are exactly the ones an attacker aims for. Note also that anyadd_headerin alocationblock discards everyadd_headerinherited from the server block.Shown because the response identified Apache. Put it in the virtual host rather than .htaccess: .htaccess is re-read on every request, and
Header always setthere runs too late for responses the server generates itself.A Transform Rule adds the header at Cloudflare's edge, so it applies only to responses that reach visitors through Cloudflare. An origin that is reachable directly — by IP, or through a DNS record that is not proxied — still serves the response measured here without it. Setting it at the origin covers both paths.
Technical detail
'unsafe-eval' appears in the effective script-src. It is usually required by an older framework's runtime template compiler or by a bundler's development build. Both have supported alternatives: use a framework's pre-compiled templates and a production build, and replace new Function and string setTimeout with real functions.
Standards and references
Test this on your domain
Run the check that produces this finding, on its own, against any domain.
Other web security headers checks
- No Cross-Origin-Embedder-Policy is set
- No Cross-Origin-Opener-Policy is set
- No Cross-Origin-Resource-Policy is set
- No Content Security Policy is enforced
- The policy leaves plugins or the base URL unrestricted
- The Content Security Policy is report-only
- The policy allows inline scripts or styles
- The policy allows resources from anywhere
- A security header was sent twice with different values
- HSTS max-age is shorter than six months
- HTTP Strict Transport Security is not in force
- HSTS does not cover subdomains