Restrict where scripts can load from on Cloudflare
Why it matters
The policy sets neither script-src nor default-src, so it does nothing against injected scripts, the main thing a CSP is for. Add a script-src that lists only your own origin and the services you use, or that uses nonces.
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 (Rules, Overview, Create rule) with Set static, header Content-Security-Policy-Report-Only, value script-src 'self'; object-src 'none'; base-uri 'self'. It does not touch your enforced policy.
- Stage 2: once only legitimate sources remain, add the directives to wherever your enforced Content-Security-Policy is set 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
- 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
- Fix the Content-Security-Policy syntax
Scan your domain to see whether this applies to you.