DeAI Research
Source · w3c

Content Security Policy Level 3

2026

cid 8ba3da6472765547cf668fd20465bc1e3f92d2e52aa5703c3eecafe77cd5a1ac · original · open access · via w3c

Title: Content Security Policy Level 3
Authors: 
Venue: w3c
Year: 2026
Canonical: w3c:CSP3
URL: https://www.w3.org/TR/CSP3/
Collector: w3c
OA: true

ABSTRACT
Content Security Policy Level 3 Content Security Policy Level 3 W3C Working Draft, 27 October 2026 More details about this document This version: https://www.w3.org/TR/2026/WD-CSP3-20261027/ Latest published version: https://www.w3.org/TR/CSP3/ Editor's Draft: https://w3c.github.io/webappsec-csp/ Previous Versions: https://www.w3.org/TR/2026/WD-CSP3-20260916/ History: https://www.w3.org/standards/history/CSP3/ Feedback: public-webappsec@w3.org with subject line “[CSP3] … message topic …” (archives) Github Editors: Mike West (Google Inc.) Antonio Sartori (Google Inc.) Participate: File an issue (open issues) Tests: web-platform-tests content-security-policy/ (ongoing work) Copyright © 2026 World Wide Web Consortium. W3C® liability, trademark and permissive document license rules apply. Abstract This document defines a mechanism by which web developers can control the resources which a particular page can fetch or execute, as well as a number of security-relevant policy decisions. Status of this document This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index. This document was published by the Web Application Security Working Group as a Working Draft using the Recommendation track. This document is intended to become a W3C Recommendation. The (archived) public mailing list public-webappsec@w3.org (see instructions) is preferred for discussion of this specification. When sending e-mail, please put the text “CSP3” in the subject, preferably like this: “[CSP3] …summary of comment…” Publication as a Working Draft does not imply endorsement by W3C and its Members. This is a draft document and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to cite this document as other than a work in progress. This document was produced by the Web Application Security Working Group. This document was produced by a group operating under the W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent that the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy. This document is governed by the 18 August 2025 W3C Process Document. The following features are at-risk, and may be dropped during the CR period: The § 6.7.3.1 Is element nonceable? algorithm. “At-risk” is a W3C Process term-of-art, and does not necessarily imply that the feature is in danger of being dropped or delayed. It means that the WG believes the feature may have difficulty being interoperably implemented in a timely manner, and marking it as such allows the WG to drop the feature if necessary when transitioning to the Proposed Rec stage, without having to publish a new Candidate Rec without the feature first. 1. Introduction This section is not normative. This document defines Content Security Policy (CSP), a tool which developers can use to lock down their applications in various ways, mitigating the risk of content injection vulnerabilities such as cross-site scripting, and reducing the privilege with which their applications execute. CSP is not intended as a first line of defense against content injection vulnerabilities. Instead, CSP is best used as defense-in-depth. It reduces the harm that a malicious injection can cause, but it is not a replacement for careful input validation and output encoding. This document is an iteration on Content Security Policy Level 2, with the goal of more clearly explaining the interactions between CSP, HTML, and Fetch on the one hand, and providing clear hooks for modular extensibility on the other. Ideally, this will form a stable core upon which we can build new functionality. 1.1. Examples 1.1.1. Control Execution MegaCorp Inc’s developers want to protect themselves against cross-site scripting attacks. They can mitigate the risk of script injection by ensuring that their trusted CDN is the only origin from which script can load and execute. Moreover, they wish to ensure that no plugins can execute in their pages' contexts. The following policy has that effect: Content-Security-Policy: script-src https://cdn.example.com/scripts/; object-src 'none' 1.2. Goals Content Security Policy aims to do to a few related things: Mitigate the risk of content-injection attacks by giving developers fairly granular control over The resources which can be requested (and subsequently embedded or executed) on behalf of a specific Document or Worker The execution of inline script Dynamic code execution (via eval() and similar constructs) The application of inline style Mitigate the risk of attacks which require a resource to be embedded in a malicious context (the "Pixel Perfect" attack described in [TIMING], for example) by giving developers granular control over the origins which can embed a given resource. Provide a policy framework which allows developers to reduce the privilege of their applications. Provide a reporting mechanism which allows developers to detect flaws being exploited in the wild. 1.3. Changes from Level 2 This document describes an evolution of the Content Security Policy Level 2 specification [CSP2]. The following is a high-level overview of the changes: The specification has been rewritten from the ground up in terms of the [FETCH] specification, which should make it simpler to integrate CSP’s requirements and restrictions with other specifications (and with Service Workers in particular). The child-src model has been substantially altered: The frame-src directive, which was deprecated in CSP Level 2, has been undeprecated, but continues to defer to child-src if not present (which defers to default-src in turn). A worker-src directive has been added, deferring to child-src if not present (which likewise defers to script-src and eventually default-src). The URL matching algorithm now treats insecure schemes and ports as matching their secure variants. That is, the source expression http://example.com:80 will match both http://example.com:80 and https://example.com:443. Likewise, 'self' now matches https: and wss: variants of the page’s origin, even on pages whose scheme is http. Violation reports generated from inline script or style will now report "inline" as the blocked resource. Likewise, blocked eval() execution will report "eval" as the blocked resource. The manifest-src directive has been added. The report-uri directive is deprecated in favor of the new report-to directive, which relies on [REPORTING] as infrastructure. The 'strict-dynamic' source expression will now allow script which executes on a page to load more script via non-"parser-inserted" script elements. Details are in § 8.2 Usage of "'strict-dynamic'". The 'unsafe-hashes' source expression will now allow event handlers, style attributes and javascript: navigation targets to match hashes. Details in § 8.3 Usage of "'unsafe-hashes'". The source expression matching has been changed to require explicit presence of any non-HTTP(S) scheme, rather than local scheme, unless that non-HTTP(S) scheme is the same as the scheme of protected resource, as described in § 6.7.2.8 Does url match expression in origin with redirect count?. Hash-based source expressions may now match external scripts if the script element that triggers the request specifies a set of integrity metadata which is listed in the current policy. Details in § 8.4 Allowing external JavaScript via hashes. Reports generated for inline violations will contain a sample attribute if the relevant directive contains the 'report-sample' expression. 2. Framework 2.1. Infrastructure This document uses ABNF grammar to specify syntax, as defined in [RFC5234]. It also relies on the #rule ABNF extension defined in Section 5.6.1 of [RFC9110], with the modification that OWS is replaced with optional-ascii-whitespace. That is, the #rule used in this document is defined as: 1#element = element *( optional-ascii-whitespace "," optional-ascii-whitespace element ) and for n = 1 and m 1: