1. Introduction
This section is not normative.
1.1. Recommended readings
-
The [explainer] for Document-Isolation-Policy.
-
The [Spectre] vulnerability.
-
The Cross-Origin-Opener-Policy (COOP) section of the HTML spec.
-
The Cross-Origin-Embedder-Policy (COEP) section of the HTML spec.
-
How and why Cross-Origin-Opener-Policy (COOP) and Cross-Origin-Embedder-Policy (COEP) are granting the crossOriginIsolated capability. See [WhyCoopCoep].
2. Integration with HMTL
This section defines a monkey-patch over [HTML].
2.1. Supporting concepts when loading web pages
2.1.1. Cross-origin-opener-policies
Modify the definition of "same-origin-plus-coep":
This behaves the same as "same-origin", with the addition that it sets the (new) top-level browsing context's group's agent cluster cross-origin isolation key's cross-origin isolation mode to one of "logical" or "concrete".
2.1.1.1. Browsing context group switches due to cross-origin opener policy
Modify step 4 of the obtain a browsing context to use for a navigation response algorithm:
-
If navigationCOOP's value is "same-origin-plus-COEP", then:
-
Let crossOriginIsolationMode be either "logical" or "concrete". The choice of which is implementation-defined.
-
Set newBrowsingContext's group's agent cluster cross-origin isolation key to {coopEnforcementResult's origin, crossOriginIsolationMode}.
-
2.1.2. Document Isolation Policies
Add a new subsection to the loading web pages supporting concepts section of the HTML spec.
A document isolation policy value is one of three strings that controls agent cluster allocation and the fetching of cross-origin resources without explicit permission from resource owners.
-
"none": This is the default value. When this value is used, cross-origin resources can be fetched without giving explicit permission through the CORS protocol or the 'Cross-Origin-Resource-Policy' header. The document is assigned to a non cross-origin isolated agent cluster.
-
"isolate-and-require-corp": When this value is used, fetching cross-origin resources requires the server’s explicit permission through the CORS protocol or the 'Cross-Origin-Resource-Policy' header. The document is also assigned to a cross-origin isolated agent cluster.
-
"isolate-and-credentialless": When this value is used, fetching cross-origin no-CORS resources omits credentials. In exchange, an explicit 'Cross-Origin-Resource-Policy' header is not required. Other requests sent with credentials require the server’s explicit permission through the CORS protocol or the 'Cross-Origin-Resource-Policy' header. The document is also assigned to a cross-origin isolated agent cluster.
A document isolation policy consists of:
-
A value, which is a document isolation policy value, initially "none.
-
A reporting endpoint, initially the empty string.
-
A report-only value, which is a document isolation policy value, initially "none.
-
A report-only reporting endpoint, initially the empty string.
To obtain a cross-origin agent cluster isolation key given null or a document isolation policy documentIsolationPolicy and an origin origin:
-
If documentIsolationPolicy is null, return null.
-
If documentIsolationPolicy's value is "none", then return null.
-
Let crossOriginIsolationMode be either "logical" or "concrete". The choice of which is implementation-defined.
-
Let crossOriginIsolationKey be a new agent cluster cross-origin isolation key.
-
Set crossOriginIsolationKey to {origin, crossOriginIsolationMode}.
-
Return crossOriginIsolationKey.
2.1.2.1. The headers
The 'Document-Isolation-Policy' and 'Document-Isolation-Policy-Report-Only' HTTP response headers allow a server to declare a document isolation policy for a document. These headers are structured headers whose values must be token.
The valid token values are the document isolation policy values. The token may also have attached parameters; of these, the "report-to" parameter can have a valid URL string identifying an appropriate reporting endpoint.
To obtain a document isolation policy given a response response and an environment environment:
-
Let policy be a new document isolation policy.
-
If environment is a non-secure context, then return policy.
-
Let parsedItem be the result of getting a structured field value with
Document-Isolation-Policy
and "item" from response's header list. -
If parsedItem is non-null:
-
If parsedItem[0] is "isolate-and-require-corp" or "isolate-and-credentialless", set policy's value to parsedItem[0].
-
If parsedItem[1]["report-to"] exists, then set policy's reporting endpoint to parsedItem[1]["report-to"].
-
-
Set parsedItem be the result of getting a structured field value with
Document-Isolation-Policyi-Report-Only
and "item" from response's header list. -
If parsedItem is non-null:
-
If parsedItem[0] is "isolate-and-require-corp" or "isolate-and-credentialless", set policy's report-only value to parsedItem[0].
-
If parsedItem[1]["report-to"] exists, then set policy's report-only reporting endpoint to parsedItem[1]["report-to"].
-
-
Return policy.
2.1.3. Policy containers
Add the following members to the policy container struct:
-
A document isolation policy, which is a document isolation policy. It is initially a new document isolation policy.
-
An agent cluster cross-origin isolation key, which is null or an agent cluster cross-origin isolation key. It is initially null. This agent cluster cross-origin isolation key is based on the document isolation policy of the document. It overrides the agent cluster cross-origin isolation key stored in the browsing context group.
Add step 5 and 6 to the clone a policy container algorithm:
-
Set clone's document isolation policy to a copy of policyContainer's document isolation policy.
-
Set clone's agent cluster cross-origin isolation key to a copy of policyContainer's agent cluster cross-origin isolation key.
Add step 6 and 7 to the create a policy container from a fetch response :
-
If environment is non-null, then set result's document isolation policy to the result of obatining a document isolation policy given response and environment.
-
Set result's agent cluster cross-origin isolation key to the result of obtaining a cross-origin isolation key given result's document isolation policy and response's URL's origin.
2.2. Browsing contexts
2.2.1. Browsing contexts
Add a step 5 to the create a new browsing context and document algorithm:
-
Let creatorAgentClusterCOIKey be null.
Add a step 5.4 to the create a new browsing context and document algorithm:
5.4 Set creatorAgentClusterCOIKey to creator's policy container's agent cluster cross-origin isolation key.
Modify step 9 of the create a new browsing context and document algorithm:
-
Let agent be the result of obtaining a similar-origin window agent given origin, group, false, and creatorAgentClusterCOIKey.
2.2.2. Grouping of browsing contexts
Remove the following line:
A browsing context group has a cross-origin isolation mode, which is a cross-origin isolation mode. It is initially "none".
Add the following line:
A browsing context group has an agent cluster cross-origin isolation key, which is null or an agent cluster cross-origin isolation key . It is initially null. It is set by Cross-Origin-Opener-Policy, and is the default agent cluster cross-origin isolation key for documents inside the browsing context group. However, it can be overriden by the policy container’s agent cluster cross-origin isolation key when a document has a document isolation policy.
2.3. Document lifecycle
2.3.1. Shared document creation infrastructure
Modify step 8.4 of the create and initialize a Document object algorithm:
Let agent be the result of obtaining a similar-origin window agent given navigationParams's origin, browsingContext's group, requestsOAC, and navigationParams's policy container's agent cluster cross-origin isolation key.
2.4. Agents and agent clusters
Add the following to the Integration with the JavaScript agent cluster formalism:
An agent cluster cross-origin isolation key is a tuple of an origin and a cross-origin isolation mode.
Change the definition of the agent cluster key:
An agent cluster key is either a site, or a tuple origin, or a tuple of a tuple origin and an agent cluster cross-origin isolation key.
Modify the obtain a similar-origin window agent algorithm definition:
To obtain a similar-origin window agent, given an origin origin, a browsing context group group, a boolean requestsOAC, and null or an agent cluster cross-origin isolation key agentClusterCOIKey, run these steps:
Modify step 3 of the obtain a similar-origin window agent algorithm:
-
If agentClusterCOIKey is not null, then set key to {origin, agentClusterCOIKey}.
-
Otherwise, if group’s agent cluster cross-origin isolation key is not null, then set key to {origin, group’s [=bcg-coi=key|agent cluster cross-origin isolation key=]}.
Modify steps 6.2 and 6.3 of the obtain a similar-origin window agent algorithm:
6.2 If key has an agent cluster cross-origin isolation key, set agentCluster's cross-origin isolation mode to key's agent cluster cross-origin isolation key's cross-origin isolation mode.
6.3 Set agentCluster's is origin-keyed to false if key equals site; otherwise true.
3. Integration with Fetch
This section defines a monkey-patch over [Fetch].
3.1. Requests
Add a new algorithm to the Requests part of Fetch:
To check if Document-Isolation-Policy allows credentials, given a request request, run these steps:
-
If request’s mode is not "no-cors", then return true.
-
If request’s client is null, then return true.
-
If request’s client’s policy container’s document-isolation-policy’s value is not "isolate-and-credentialless", then return true.
-
If request’s origin is same origin with request’s current URL’s origin and request does not have a redirect-tainted origin, then return true.
-
Return false.
3.2. 'Cross-Origin-Resource-Policy' header
Add a new enum definition to the Cross-Origin-Resource-Policy section of Fetch:
A cross-origin resource policy internal check result is one of five values:
-
"allowed"
-
"blocked"
-
"blocked-by-coep"
-
"blocked-by-dip"
-
"blocked-by-coep-and-dip"
Modify the cross-origin resource policy check algorithm:
-
Let documentIsolationPolicy be settingsObject’s policy container’s document-isolation-policy.
-
Let reportOnlyCheck be the the result of the cross-origin resource policy internal check with origin, embedderPolicy’s report only value, documentIsolationPolicy’s report only value, response, and forNavigation.
-
If reportOnlyCheck is "blocked-by-coep" or "blocked-by-coep-and-dip", then queue a cross-origin embedder policy CORP violation report with response, settingsObject, destination, and true.
-
If reportOnlyCheck is "blocked-by-dip" or "blocked-by-coep-and-dip", then queue a document isolation policy CORP violation report with response, settingsObject, destination, and true.
-
Let check be the the result of the cross-origin resource policy internal check with origin, embedderPolicy’s value, documentIsolationPolicy’s report value, response, and forNavigation.
-
If check is "allowed", then return allowed.
-
If check is "blocked-by-coep" or "blocked-by-coep-and-dip", then queue a cross-origin embedder policy CORP violation report with response, settingsObject, destination, and false.
-
If reportOnlyCheck is "blocked-by-dip" or "blocked-by-coep-and-dip", then queue a document isolation policy CORP violation report with response, settingsObject, destination, and false.
-
Return blocked.
Modify the cross-origin resource policy internal check algorithm definition:
To perform a cross-origin resource policy internal check, given an origin origin, an embedder policy value embedderPolicyValue, a document isolation policy value documentIsolationPolicyValue, a response response, and a boolean forNavigation, run these steps:
Modify the cross-origin resource policy internal check algorithm:
-
Let checkResult be a cross-origin resource policy internal check result with value "blocked".
-
If policy is null, then:
-
Let upgradeDueToCOEP be false.
-
Let upgradeDueToDIP be false.
-
Switch on embedderPolicyValue:
-
-
Do nothing.
-
-
-
Set upgradeDueToCOEP to true if:
-
response’s request-includes-credentials is true, or
-
forNavigation is true.
-
-
-
-
Set upgradeDueToCOEP to true.
-
-
-
Switch on documentIsolationPolicyValue:
-
"dip-none"
-
Do nothing.
-
-
-
Set upgradeDueToDIP to true if response’s request-includes-credentials is true.
-
-
-
Set upgradeDueToDIP to true.
-
-
-
If upgradeDueToCOEP or upgradeDueToDIP is true, set policy to 'same-origin'.
-
If upgradeDueToCOEP is true, then:
-
If upgradeDueToDIP is true, then set checkResult to "blocked-by-coep-and-dip".
-
Otherwise, set checkResult to "blocked-by-coep".
-
-
Otherwise, if upgradeDueToDIP is true, then set checkResult to "blocked-by-dip".
-
-
Switch on policy:
-
null
-
cross-origin
-
Set checkResult to "allowed".
-
-
same-origin
-
If origin is same origin with response’s URL’s origin, then set checkResult to "allowed".
-
-
same-site
-
-
Return checkResult.
Add a new algorithm to the Cross-Origin-Resource-Policy section of Fetch:
To queue a document isolation policy CORP violation report, given a response response, an environment settings object settingsObject, a string destination, and a boolean reportOnly, run these steps:
-
Let endpoint be settingsObject’s policy container’s document-isolation-policy’s report only reporting endpoint if reportOnly is true and settingsObject’s policy container’s document-isolation-policy’s reporting endpoint otherwise.
-
Let serializedURL be the result of serializing a response URL for reporting with response.
-
Let disposition be "reporting" if reportOnly is true; otherwise "enforce".
-
Let body be a new object containing the following properties:
"type" "corp" "blockedURL" serializedURL "destination" destination "disposition" disposition -
Generate and queue a report for settingsObject’s global object given the "dip", endpoint, and body.
3.3. HTTP-network-or-cache fetch
Add a step 8.5 to the HTTP-network-or-cache fetch algorithm:
-
If Document-Isolation-Policy allows credentials with request returns false, then set includeCredentials to false.
4. Security considerations
This section is not normative.
Document-Isolation-Policy is a security API whose goal is to give access to potentially dangerous APIs (like Shared Array Buffers) in a safe manner. In order to do so, Document-Isolation-Policy relies on the user agent backing the agent cluster separation with effective process separation. If the user agent is not able to do so (e.g. it cannot support Out-of-Process Iframes), the user agent should set a cross-origin isolation mode of "logical" for documents with Document-Isolation-Policy. This will prevent the document from getting access to the dangerous APIs gated behind cross-origin isolation.
This choice of cross-origin isolation mode should be a static choice made for all origins on a user’s machine, to avoid leaking the state of other documents on the user’s machine.
For a longer discussion of the threat model this API adresses, please refer to the [explainer].
5. Privacy considerations
This section is not normative.
No additional privacy concerns beyond the risks mentionned in the security considerations section.