From 16570ff808267383a393064ff951b764911be78f Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Thu, 1 Sep 2022 23:38:21 -0400 Subject: [PATCH] Support same-site cross-origin prerendering This includes our first formal spec for Supports-Loading-Mode, and an update to its explainer to reflect what we're most immediately looking to ship. --- README.md | 6 +- opt-in.md | 155 +++++++++--------- ...ss-origin.md => prerendering-cross-site.md | 16 +- ...ame-origin.md => prerendering-same-site.md | 50 ++++-- prerendering-state.md | 2 +- prerendering.bs | 42 ++++- same-origin-chrome-origin-trial.md | 2 +- same-origin-security-privacy-questionnaire.md | 10 +- speculation-rules.bs | 2 +- 9 files changed, 175 insertions(+), 110 deletions(-) rename prerendering-cross-origin.md => prerendering-cross-site.md (86%) rename prerendering-same-origin.md => prerendering-same-site.md (81%) diff --git a/README.md b/README.md index ff94728..b86c851 100644 --- a/README.md +++ b/README.md @@ -21,20 +21,20 @@ See [the full explainer](./triggers.md) for more. Prerendering is more complex than prefetching, as it involves running the target page's scripts and loading its subresources. We've produced a couple of relevant explainers: -* [Same-origin prerendering](./prerendering-same-origin.md), discusses what we believe to be solid so far: user agent-triggered and same-origin-triggered prerendering. +* [Same-site prerendering](./prerendering-same-site.md), discusses what we believe to be solid so far: user agent-triggered and same-site-triggered prerendering. * [Prerendering state APIs](./prerendering-state.md), discussing the new `document.prerendering` API and its associated event in more detail. ## Cross-origin and cross-site concerns Much of the complexity of preloading comes in when dealing with site that is cross-origin or cross-site. Origins are the web's security boundary, and sites are its privacy boundary, so any preloading across these boundaries needs to preserve the relevant properties. -Our current proposals are focused around allowing cross-origin/site prefetching. We also have some early thoughts on cross-origin/site prerendering, but have not yet committed to them. The following explainers are relevant: +Our current proposals are focused around allowing cross-origin/site prefetching, and cross-origin but same-site prerendering. We also have some early thoughts on cross-site prerendering, but have not yet committed to them. The following explainers are relevant: * [Cross-site preloading fetching modes](./fetch.md), discussing how to perform the fetch of the main content and any subresources while doing cross-site preloading. * [`Supports-Loading-Mode`](./opt-in.md), a new header which allows target pages to opt in to being loaded in an uncredentialed mode, with the understanding that they will upgrade their content later upon activation. * [``](https://github.com/WICG/nav-speculation/blob/main/meta-processing.md), an extension to the header definition that uses a HTML preparsing pass to allow it to appear in-document. * [Client IP anonymization](./anonymous-client-ip.md), an extension to prefetching (and maybe one day prerendering?) to require using an anonymizing proxy to hide the user's IP address. -* [Cross-origin prerendering](./cross-origin-prerendering.md), containing what we've brainstormed so far about how cross-origin prerendering could work in the future. +* [Cross-site prerendering](./cross-site-prerendering.md), containing what we've brainstormed so far about how cross-site prerendering could work in the future. ## Portals diff --git a/opt-in.md b/opt-in.md index 79e440a..6109ff0 100644 --- a/opt-in.md +++ b/opt-in.md @@ -1,84 +1,103 @@ -# Prerendering opt-in +# Loading mode support -Because [prerendering fetching modes](./fetch.md) intentionally obscure the user's identity, the response document cannot be personalized for the user. If it is used when the user navigates, the user will notice that they are not logged in (even if they should be), and other surprising behavior. +Several subtypes of preloading introduce novel ways of loading content, which the destination site might not be prepared for. In such cases, we require that the response signal that they support the given loading mode, via the `Supports-Loading-Mode` header proposed here. -Similarly, prerendering browsing contexts allow HTML parsing, subresource fetching, and script execution, but such actions are restricted to avoid identifying the user or causing user-visible annoyance. + + +## Table of contents -Pages designed with these restrictions in mind can "upgrade" themselves when they load, by personalizing based on data in unpartitioned storage and by fetching personalized content from the server. But existing web pages are unlikely to behave well with these restrictions today. (And, it is impractical for user agents to distinguish such pages.) +- [HTTP header declaration](#http-header-declaration) +- [Use cases](#use-cases) + - [Uncredentialed preloading](#uncredentialed-preloading) + - [Cross-origin same-site prerendering](#cross-origin-same-site-prerendering) + - [Non-preloading cases](#non-preloading-cases) +- [Future extensions](#future-extensions) + - [An in-markup version](#an-in-markup-version) + - [Application to subframes while prerendering](#application-to-subframes-while-prerendering) +- [Redirect handling](#redirect-handling) +- [Alternatives considered](#alternatives-considered) + - [No declaration](#no-declaration) + - [Opt-out only](#opt-out-only) + - [Document policy](#document-policy) +- [Acknowledgments](#acknowledgments) -As such, we propose a lightweight way for a page to declare that it is prepared for such prerendering, and will, if necessary, upgrade itself when it gains access to unpartitioned storage and other privileges. + -There has been previous discussion along these lines in [w3c/resource-hints#82](https://github.com/w3c/resource-hints/issues/82#issuecomment-536492276). (It also proposes a new `prenavigate` hint; defining triggers for these loading modes is not yet part of this proposal.) +## HTTP header declaration -## Table of contents +```http +Supports-Loading-Mode: uncredentialed-prefetch, uncredentialed-prerender +``` -- [Declaration](#declaration) -- [Request header](#request-header) -- [Risks](#risks) -- [Alternatives considered](#alternatives-considered) +This is an [HTTP structured header][http-structured-header] which lists tokens indicating the loading modes the content is ready for. The tokens we so far envision are: -## Declaration +* `uncredentialed-prefetch` +* `uncredentialed-prerender` +* `credentialed-prerender` -``` -// HTTP response header -Supports-Loading-Mode: uncredentialed-prefetch, uncredentialed-prerender +## Use cases -// HTML meta tag - -``` +### Uncredentialed preloading + +Cross-site preloads intentionally obscure the user's identity, to avoid leaking it to sites that the user has not yet affirmatively indicated an intent to visit. See the [Cross-site preloading fetching modes](./fetch.md) document for more details. Because of this, the resulting responses cannot be personalized for the user. If such responses are directly shown to the user upon activation, the user will notice that they are not logged in (even if they should be), and other surprising behavior. + +Pages designed with these restrictions in mind can "upgrade" themselves when they are activated, by personalizing based on data in unpartitioned storage and by fetching personalized content from the server. But existing web pages are unlikely to behave well with these restrictions today. (And, it is impractical for user agents to distinguish such pages.) + +To resolve this problem, user agents must only preload pages which either: -This is an [HTTP structured header][http-structured-header] which lists tokens indicating the loading modes the content is ready for. They have the following proposed meaning: +* Have no stored credentials (for prefetch) or storage of any kind (for prerender); or +* Indicate that they are prepared to perform this sort of upgrade, by sending the appropriate `Supports-Loading-Mode` header value: either `uncredentialed-prefetch`, `uncredentialed-prerender`, or both. -
-
default
-
Implied, even if not listed. Baseline standard behavior.
+_Note: these values are not currently implemented in Chromium._ -
uncredentialed-prefetch
-
The resource is suitable for any user who meets the cache conditions. Either it is not personalized, or it includes script to modify the document to reflect credentialed state (e.g., to show the user's logged-in state). However, access to credentials will be available when the document loads and script executes.
+### Cross-origin same-site prerendering -
uncredentialed-prerender
-
Implies uncredentialed-prefetch. The resource can be loaded without access to its credentials and storage. Access to certain other APIs may be limited in this state. Either it is not personalized based on credentials, or it includes script to modify the document when the loading state changes to permit it.
-
+For prerendering, there is an additional complication when dealing with cross-origin destinations. Because the web's privacy boundary is site, we can send credentials and give storage access to such pages before activation. However, the web's _security_ boundary is the origin, not the site. So we need to ensure that pages cannot use prerendering to attack other origins—even same-site ones. -The `` tag is processed only if it appears within the `` element and no `