Fix the Content-Security-Policy syntax on Cloudflare
Why it matters
Browsers skip directives they do not know and read unquoted keywords as host names, so parts of the policy silently do nothing. The finding's details list what was ignored.
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
- Stage 1: add a Response Header Transform Rule with Set static, header Content-Security-Policy-Report-Only and the corrected policy, and check the reports.
- Stage 2: put the corrected value into wherever the enforced policy is set (the rule or the origin) and delete the report-only rule.
Related
- Reported by the Content-Security-Policy check
- Add a Content-Security-Policy
- Enforce the report-only Content-Security-Policy
- Send the Content-Security-Policy as an HTTP header
- Restrict where scripts can load from
- Replace 'unsafe-inline' scripts with nonces or hashes
- Remove 'unsafe-eval' from script-src
- Remove wildcard sources from script-src
- Set object-src to 'none'
- Add base-uri to the Content-Security-Policy
- Reduce reliance on inline styles
Scan your domain to see whether this applies to you.