Document-Isolation-Policy

Draft Community Group Report,

This version:
https://github.com/WICG/document-isolation-policy
Issue Tracking:
GitHub
Editor:
(Google)

Abstract

This proposal explores a new header, "Document-Isolation-Policy", that enables crossOriginIsolation for the document, without relying on COOP and COEP. In turns, this gives access to COI-gated APIs such as SharedArrayBuffers.

Status of this document

This specification was published by the Web Platform Incubator Community Group. It is not a W3C Standard nor is it on the W3C Standards Track. Please note that under the W3C Community Contributor License Agreement (CLA) there is a limited opt-out and other conditions apply. Learn more about W3C Community and Business Groups.

1. Introduction

This section is not normative.

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:

  1. If navigationCOOP's value is "same-origin-plus-COEP", then:

    1. Let crossOriginIsolationMode be either "logical" or "concrete". The choice of which is implementation-defined.

    2. 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.

A document isolation policy consists of:

To obtain a cross-origin agent cluster isolation key given null or a document isolation policy documentIsolationPolicy and an origin origin:

  1. If documentIsolationPolicy is null, return null.

  2. If documentIsolationPolicy's value is "none", then return null.

  3. Let crossOriginIsolationMode be either "logical" or "concrete". The choice of which is implementation-defined.

  4. Let crossOriginIsolationKey be a new agent cluster cross-origin isolation key.

  5. Set crossOriginIsolationKey to {origin, crossOriginIsolationMode}.

  6. 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:

  1. Let policy be a new document isolation policy.

  2. If environment is a non-secure context, then return policy.

  3. Let parsedItem be the result of getting a structured field value with Document-Isolation-Policy and "item" from response's header list.

  4. If parsedItem is non-null:

    1. If parsedItem[0] is "isolate-and-require-corp" or "isolate-and-credentialless", set policy's value to parsedItem[0].

    2. If parsedItem[1]["report-to"] exists, then set policy's reporting endpoint to parsedItem[1]["report-to"].

  5. Set parsedItem be the result of getting a structured field value with Document-Isolation-Policyi-Report-Only and "item" from response's header list.

  6. If parsedItem is non-null:

    1. If parsedItem[0] is "isolate-and-require-corp" or "isolate-and-credentialless", set policy's report-only value to parsedItem[0].

    2. If parsedItem[1]["report-to"] exists, then set policy's report-only reporting endpoint to parsedItem[1]["report-to"].

  7. Return policy.

2.1.3. Policy containers

Add the following members to the policy container struct:

Add step 5 and 6 to the clone a policy container algorithm:

  1. Set clone's document isolation policy to a copy of policyContainer's document isolation policy.

  2. 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 :

  1. 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.

  2. 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:

  1. 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:

  1. 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:

  1. If agentClusterCOIKey is not null, then set key to {origin, agentClusterCOIKey}.

  2. 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:

  1. If request’s mode is not "no-cors", then return true.

  2. If request’s client is null, then return true.

  3. If request’s client’s policy container’s document-isolation-policy’s value is not "isolate-and-credentialless", then return true.

  4. 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.

  5. 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:

Modify the cross-origin resource policy check algorithm:

  1. Let documentIsolationPolicy be settingsObject’s policy container’s document-isolation-policy.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. If check is "allowed", then return allowed.

  7. 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.

  8. 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.

  9. 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:

  1. Let checkResult be a cross-origin resource policy internal check result with value "blocked".

  2. If policy is null, then:

    1. Let upgradeDueToCOEP be false.

    2. Let upgradeDueToDIP be false.

    3. Switch on embedderPolicyValue:

    4. Switch on documentIsolationPolicyValue:

    5. If upgradeDueToCOEP or upgradeDueToDIP is true, set policy to 'same-origin'.

    6. If upgradeDueToCOEP is true, then:

      1. If upgradeDueToDIP is true, then set checkResult to "blocked-by-coep-and-dip".

      2. Otherwise, set checkResult to "blocked-by-coep".

    7. Otherwise, if upgradeDueToDIP is true, then set checkResult to "blocked-by-dip".

  3. Switch on policy:

  4. 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:

  1. 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.

  2. Let serializedURL be the result of serializing a response URL for reporting with response.

  3. Let disposition be "reporting" if reportOnly is true; otherwise "enforce".

  4. Let body be a new object containing the following properties:

    "type" "corp"
    "blockedURL" serializedURL
    "destination" destination
    "disposition" disposition
  5. 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:

  1. 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.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[DOM]
Anne van Kesteren. DOM Standard. Living Standard. URL: https://dom.spec.whatwg.org/
[ECMASCRIPT]
ECMAScript Language Specification. URL: https://tc39.es/ecma262/multipage/
[Fetch]
Anne van Kesteren. Fetch Standard. Living Standard. URL: https://fetch.spec.whatwg.org/
[HTML]
Anne van Kesteren; et al. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/
[INFRA]
Anne van Kesteren; Domenic Denicola. Infra Standard. Living Standard. URL: https://infra.spec.whatwg.org/
[MIMESNIFF]
Gordon P. Hemsley. MIME Sniffing Standard. Living Standard. URL: https://mimesniff.spec.whatwg.org/
[REPORTING-1]
Douglas Creager; Ian Clelland; Mike West. Reporting API. URL: https://w3c.github.io/reporting/
[URL]
Anne van Kesteren. URL Standard. Living Standard. URL: https://url.spec.whatwg.org/

Informative References

[EXPLAINER]
Camille Lamy. Document-Isolation-Policy explainer. URL: https://github.com/WICG/document-isolation-policy
[Spectre]
Paul Kocher; et al. Spectre Attacks: Exploiting Speculative Execution. URL: https://spectreattack.com/spectre.pdf
[WhyCoopCoep]
Eiji Kitamura; Demenic Denicola. Why you need "cross-origin isolated" for powerful features. URL: https://web.dev/why-coop-coep/