Generated by GPT-5-mini| Content Security Policy | |
|---|---|
| Name | Content Security Policy |
| Acronym | CSP |
| Developer | W3C, World Wide Web Consortium |
| First published | 2012 |
| Latest release | CSP Level 3 |
| Type | Web security standard |
Content Security Policy Content Security Policy is a web-standard mechanism that enables site operators to control resource loading and script execution in web documents. It reduces attack surface for Cross-site scripting, Clickjacking, and injection attacks by declaring allowed origins and behaviors. Major stakeholders in its development and adoption include W3C, Mozilla Foundation, Google, Microsoft, Apple Inc., and large platform operators such as Cloudflare and Akamai Technologies.
CSP provides a declarative HTTP header or HTML meta element that lists source expressions and policy directives used by browsers such as Mozilla Firefox, Google Chrome, Microsoft Edge, and Apple Safari. Operators author policies to restrict scripts, styles, images, fonts, frames, and worker scripts, referencing origins like Amazon Web Services, Google Cloud Platform, or self-hosted domains. As a mitigation technique CSP complements other standards and defenses including Same-origin policy, Subresource Integrity, and Transport Layer Security deployments by corporate entities such as DigiCert and Let's Encrypt.
Work on the specification began within browser vendors and security teams at organizations like Mozilla Corporation, Google LLC, and Microsoft Corporation responding to high-profile incidents such as breaches reported by Yahoo! and Equifax. Initial drafts were coordinated through the W3C's Web Application Security Working Group and later matured into formal recommendations influenced by engineering teams from Facebook, Twitter, GitHub, and cloud providers including Microsoft Azure. Subsequent iterations—CSP Level 1, Level 2, and Level 3—incorporated feedback from standards bodies and implementers at IETF, ECMA International, and browser vendors.
Directives such as default-src, script-src, style-src, img-src, font-src, connect-src, frame-src, child-src, worker-src, and form-action specify permitted origins or resources, using hostnames, schemes, and keywords like 'self' and 'none'. Nonces and hashes for scripts and styles were introduced to allow inline execution without enabling unsafe-inline, a change driven by engineering teams at Google Project Zero and security researchers affiliated with CERT Coordination Center and SANS Institute. The syntax supports Content-Security-Policy and Content-Security-Policy-Report-Only headers, token semantics that mirror HTTP header grammar found in RFC 7230 and interaction patterns with HTML5 parsing rules developed by WHATWG contributors.
Deployment typically occurs at web servers and content delivery networks run by operators like NGINX, Apache HTTP Server, Amazon CloudFront, and Fastly. Major web platforms—WordPress, Drupal, Joomla!, Shopify, and Magento—offer plugins or configuration options to inject policies. Enterprise security appliances from F5 Networks and Palo Alto Networks can insert or modify CSP headers at the edge, while platform teams at LinkedIn, Netflix, Spotify, and Dropbox have published case studies describing staged rollouts using Report-Only mode and CSP linting tools such as those developed by Mozilla Developer Network contributors.
CSP significantly mitigates client-side injection classes exploited in incidents involving Equifax and Target by restricting execution contexts and external resource loading. It raises the bar for attackers leveraging third-party widgets from vendors like Google Analytics, Facebook Pixel, or Twitter Widgets. However, CSP is not a panacea: misconfigurations, permissive wildcards, and continued reliance on unsafe-inline reduce effectiveness; similarly, advanced techniques such as DOM-based Cross-site scripting and supply-chain compromises at providers like npm or PyPI can circumvent policies. Security teams at enterprises such as Adobe and Cisco Systems recommend combined use of CSP, robust input validation, and software composition analysis.
CSP supports a report-uri/report-to mechanism that ships violation reports to collectors managed by services like Sentry, Datadog, New Relic, and self-hosted endpoints. Aggregation across incidents can be analyzed alongside telemetry from Google Analytics, observability platforms run by Elastic, and security information event management systems from Splunk. Organizations such as OWASP and NIST provide guidance on incident response workflows when CSP reports reveal attempted exploitation patterns.
Browser implementation varies: Google Chrome and Mozilla Firefox historically led feature adoption, while Microsoft Edge and Apple Safari implemented different subsets, prompting cross-vendor coordination through W3C test suites and conformance reports. Compatibility concerns arise around legacy user agents and intermediaries such as corporate proxies from Blue Coat Systems and Zscaler that may strip or alter headers. Web developers often use feature detection and progressive enhancement patterns championed by communities around MDN Web Docs and Stack Overflow to ensure graceful degradation.
Category:Web security standards