Content Security Policies (CSPs)
Last updated Apr 20, 2026 A Content Security Policy (CSP) is an added layer of security that helps detect and mitigate certain types of attacks, including:
- Content/code injection
- Cross-site scripting (XSS)
- Embedding malicious resources
- Malicious iframes (clickjacking)
To learn more about configuring a CSP in general, refer to the Mozilla documentation ↗︎.
Using a CSP with Cloudflare
Cloudflare's CDN is compatible with CSP.
Cloudflare does not:
- Modify CSP headers from the origin web server (except when using Zaraz, to ensure the Zaraz script is always running ↗︎).
- Require changes to acceptable sources for first or third-party content.
- Modify URLs (besides adding the
/cdn-cgi/endpoint and Cloudflare Fonts that rewrites Google Fonts urls). - Interfere with locations specified in your CSP.
If you require the CSP headers to be changed or added, you can change them using some Cloudflare products:
- If your website is proxied through Cloudflare, you can use a response header transform rule to replace or add CSP headers.
- If your website is hosted using Cloudflare Pages, you can set a
_headers fileto modify or add CSP headers.
Product requirements
To use certain Cloudflare features, however, you may need to update the headers in your CSP:
| Feature(s) | Updated headers |
|---|---|
| Rocket Loader | script-src 'self' ajax.cloudflare.com; |
| Scrape Shield | script-src 'self' 'unsafe-inline' |
| Web Analytics | script-src static.cloudflareinsights.com; connect-src cloudflareinsights.com |
| Bot products | Refer to JavaScript detections and CSPs. |
| Client-side security (formerly Page Shield) | Refer to CSP header format. |
| Zaraz | No updates required (details ↗︎). |
| Turnstile | Refer to Turnstile CSP. |
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/fundamentals/reference/policies-compliances/content-security-policies/#page","headline":"Content Security Policies (CSPs)","description":"Understand how Cloudflare interacts with Content Security Policies (CSPs) and which headers to update for specific Cloudflare features.","url":"https://developers.cloudflare.com/fundamentals/reference/policies-compliances/content-security-policies/","inLanguage":"en","image":"https://developers.cloudflare.com/fundamentals/reference/policies-compliances/content-security-policies/og.png?v=2ed3c96d7367cd26","dateModified":"2026-04-20","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Project Cybersafe Schools provides eligible schools with free Cloudflare Email Security and Gateway products to meet CIPA requirements. title: Project Cybersafe Schools image: https://developers.cloudflare.com/fundamentals/reference/policies-compliances/cybersafe/og.png?v=8540bc2067b87ea8
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/fundamentals/llms.txt
Use this file to discover all available pages before exploring further.
Docs