Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an explainer for subresource signed exchanges #542

Merged
merged 6 commits into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 164 additions & 0 deletions explainers/signed-exchange-alternate-link-explainer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# Signed Exchange alternate link
## Introduction
We want to extend the usage of the existing [rel=alternate](https://html.spec.whatwg.org/multipage/links.html#rel-alternate) link header for signed exchange. Using this link header, the content publishers can declare that the resource is available in signed exchange format. This can be used both by the crawlers of aggregator sites (SNS, News site, search engine..) and by the UAs. The crawlers can cache and serve the signed exchange of the content in their own server. The UAs can provide the users with a way to save the page in signe exchange format. And also signed exchange alternate links can be used to recursively prefetch appropriate subresource signed exchanges while prefetching the main resource signed exchange.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We want to extend the usage of the existing [rel=alternate](https://html.spec.whatwg.org/multipage/links.html#rel-alternate) link header for signed exchange. Using this link header, the content publishers can declare that the resource is available in signed exchange format. This can be used both by the crawlers of aggregator sites (SNS, News site, search engine..) and by the UAs. The crawlers can cache and serve the signed exchange of the content in their own server. The UAs can provide the users with a way to save the page in signe exchange format. And also signed exchange alternate links can be used to recursively prefetch appropriate subresource signed exchanges while prefetching the main resource signed exchange.
We want to allow the publisher of a resource to declare that a signed exchange is available holding the content of either that resource or one of its subresources. We expect aggregator sites (SNS, News site, search engine..) to use this to cache the signed version of a resource in order to serve it to their users. We expect UAs to use this to allow users to save the page in signed exchange format. When the publisher identifies a same-origin signed exchange for a cross-origin subresource, the UA can use that information to recursively prefetch the subresource without exposing its speculative activity across origins.
[`<link rel="alternate" type="application/signed-exchange" href=...>`](https://html.spec.whatwg.org/multipage/links.html#rel-alternate) and the equivalent `Link` header are already defined to declare that the referenced document is a reformulation of the current document as a signed exchange. To offer signed exchanges for subresources, we propose to use the [`anchor` parameter](https://tools.ietf.org/html/rfc8288#section-3.2) to identify the replaced subresource. This may be the first use of the `anchor` parameter in the web platform.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you wrap lines at 80 columns?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We want to extend the usage of the existing [rel=alternate](https://html.spec.whatwg.org/multipage/links.html#rel-alternate) link header for signed exchange. Using this link header, the content publishers can declare that the resource is available in signed exchange format. This can be used both by the crawlers of aggregator sites (SNS, News site, search engine..) and by the UAs. The crawlers can cache and serve the signed exchange of the content in their own server. The UAs can provide the users with a way to save the page in signe exchange format. And also signed exchange alternate links can be used to recursively prefetch appropriate subresource signed exchanges while prefetching the main resource signed exchange.
We want to extend the usage of the existing [rel=alternate](https://html.spec.whatwg.org/multipage/links.html#rel-alternate) link header for signed exchange. Using this link header, the content publishers can declare that the resource is available in signed exchange format. This can be used both by the crawlers of aggregator sites (social networks, News site, search engine..) and by the UAs. The crawlers can cache and serve the signed exchange of the content in their own server. The UAs can provide the users with a way to save the page in signe exchange format. And also signed exchange alternate links can be used to recursively prefetch appropriate subresource signed exchanges while prefetching the main resource signed exchange.

I think SNS means "social networking service", from https://en.wikipedia.org/wiki/SNS, but I had to look it up. We should expand acronyms at least the first time we use them, but I think we can just avoid this one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We want to extend the usage of the existing [rel=alternate](https://html.spec.whatwg.org/multipage/links.html#rel-alternate) link header for signed exchange. Using this link header, the content publishers can declare that the resource is available in signed exchange format. This can be used both by the crawlers of aggregator sites (SNS, News site, search engine..) and by the UAs. The crawlers can cache and serve the signed exchange of the content in their own server. The UAs can provide the users with a way to save the page in signe exchange format. And also signed exchange alternate links can be used to recursively prefetch appropriate subresource signed exchanges while prefetching the main resource signed exchange.
We want to extend the usage of the existing [rel=alternate](https://html.spec.whatwg.org/multipage/links.html#rel-alternate) link header for signed exchange. Using this link header, the content publishers can declare that the resource is available in signed exchange format. This can be used both by the crawlers of aggregator sites (SNS, News site, search engine..) and by the UAs. The crawlers can cache and serve the signed exchange of the content in their own server. The UAs can provide the users with a way to save the page in signed exchange format. And also signed exchange alternate links can be used to recursively prefetch appropriate subresource signed exchanges while prefetching the main resource signed exchange.


## Use Cases
### Signed Exchange discovery of main resource
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Signed Exchange discovery of main resource
### Discovery of a signed exchange for the main resource

However, I'm not sure this use needs to be in an explainer at all. The "Otherwise" branch in https://html.spec.whatwg.org/multipage/links.html#rel-alternate already says that "The keyword creates a hyperlink referencing an alternate representation of the current document. The nature of the referenced document is given by the hreflang, and type attributes." There's nothing new in saying that a signed exchange can be an alternate representation of a document. So maybe delete this whole sub-section.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted this whole sub-section.

1. Content publishers can declare the URL of signed exchange format of the content using an alternate link HTTP header or using an alternate link HTML element.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Content publishers can declare the URL of signed exchange format of the content using an alternate link HTTP header or using an alternate link HTML element.
1. A publisher can offer a signed exchange version of a resource using either a `Link` header on that resource of a `<link rel="alternate">` element within the resource.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the paragraphs in this section are really an ordered list.

Suggested change
1. Content publishers can declare the URL of signed exchange format of the content using an alternate link HTTP header or using an alternate link HTML element.
Content publishers can declare the URL of signed exchange format of the content using an alternate link HTTP header or using an alternate link HTML element.

- Example of signed exchange alternate link HTTP header in the HTTP response headers of the main resource of the content (https://publisher.example/article.html):
```
Link: <https://sxg.publisher.example/article.html.sxg>;
rel="alternate";
type="application/signed-exchange;v=b3";
anchor="https://publisher.example/article.html"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omit an anchor parameter if it's the same URL as the resource it appears in.

Suggested change
anchor="https://publisher.example/article.html"

```
- Example of signed exchange alternate link HTML element in the main resource of the content (https://publisher.example/article.html):
```
<link href="https://sxg.publisher.example/article.html.sxg"
rel="alternate"
type="application/signed-exchange;v=b3"
anchor="https://publisher.example/article.html">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also omit this one.

Suggested change
anchor="https://publisher.example/article.html">
>

```
1. This signed exchange alternate link of main resource can be used both by the crawlers and the UAs.
- When the crawlers detects the signed exchange alternate link, the crawlers can fetch the signed exchange. And when a user is browsing the aggregator site (https://feed.example) and it has a link to the article, the signed exchange can be used for [privacy-preserving prefetching](https://wicg.github.io/webpackage/draft-yasskin-webpackage-use-cases.html#private-prefetch) using a prefetch `<link>` element and `<a>` link to the signed exchange .
```
<link href="https://feed.example/article.html.sxg"
rel="prefetch">
<a href="https://feed.example/article.html.sxg">feed.example</a>
```
- While the user of the UA is browsing an article (article.html), and if there is a signed exchange alternate link, the UA can provide the user with a way to save the page in signe exchange format. The saved file can be used to share with other users.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- While the user of the UA is browsing an article (article.html), and if there is a signed exchange alternate link, the UA can provide the user with a way to save the page in signe exchange format. The saved file can be used to share with other users.
- While the user of the UA is browsing an article (article.html), and if there is a signed exchange alternate link, the UA can provide the user with a way to save the page in signed exchange format. The saved file can be used to share with other users.


### Recursive subresource signed exchange prefetch
1. A crawler of an aggregator site fetches an article (https://publisher.example/article.html).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think crawlers are likely to respect subresource signed exchanges. They can just go to the original host, which can offer the signed exchange as a same-document alternative. So remove from here down to "The aggregator site will serve"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

1. There is an alternate link of signed exchange of the article in the response header:
```
Link: <https://sxg.publisher.example/article.html.sxg>;
rel="alternate";
type="application/signed-exchange;v=b3";
anchor="https://publisher.example/article.html"
```
1. The crawler fetches and verifies the signed exchange (article.html.sxg).

1. The response from the server has an alternate link of subresource signed exchange:
```
Link: <https://sxg.publisher.example/lib.js.sxg>;
rel="alternate";
type="application/signed-exchange;v=b3";
anchor="https://cdn.publisher.example/lib.js"
```
1. And the inner response of the main resource signed exchange (article.html.sxg) has a preload header and an [allowed-alt-sxg header](./signed-exchange-subresource-subtitution-explainer.md):
```
Link: <https://cdn.publisher.example/lib.js>;
rel="preload";
as="script"
Link: <https://cdn.publisher.example/lib.js>;
rel="allowed-alt-sxg";
header-integrity="sha256-XXXXXX"
```
1. The crawler fetches and verifies the subresource signed exchange (lib.js.sxg).
1. The aggregator site will serve the signed exchanges (article.html.sxg and lib.js.sxg) from their own server.

1. While a user is browsing the aggregator site (https://feed.example), a prefetch link element is inserted because the use is likely to want to read the article.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. While a user is browsing the aggregator site (https://feed.example), a prefetch link element is inserted because the use is likely to want to read the article.
While a user is browsing an aggregator site (https://feed.example), the aggregator guesses that the user is likely to want to read a particular article (https://publisher.example/article.html) and so inserts a prefetch link pointing to a signed exchange version of that article.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

```
<link rel="prefetch" href="https://feed.example/sxg.publisher.example/article.html.sxg">
```
1. The UA prefetches the signed exchange (article.html.sxg).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. The UA prefetches the signed exchange (article.html.sxg).
When the UA prefetches the signed exchange (article.html.sxg), the aggregator server includes a declaration that one of `article.html`'s subresources (https://cdn.publisher.example/lib.js) is also available from the same aggregator.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

1. The response from the server has an alternate link of subresource signed exchange:
```
Link: <https://feed.example/sxg.publisher.example/lib.js.sxg>;
rel="alternate";
type="application/signed-exchange;v=b3";
anchor="https://cdn.publisher.example/lib.js"
```
1. And the inner response of the main resource signed exchange (article.html.sxg) has a preload header and an allowed-alt-sxg header:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. And the inner response of the main resource signed exchange (article.html.sxg) has a preload header and an allowed-alt-sxg header:
To prevent an attacker from loading an incompatible version of the subresource, the resource _inside_ the signed exchange has to identify the exact version of the replacement signed exchange using a `Link: ... rel="allowed-alt-sxg"` with the hash of the signed headers (which themselves include a hash of the content).
To prevent a tracker from conveying a user ID in their choice of which subresources to prefetch, the inner resource has to preload the same subresources that the aggregator prefetches.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

```
Link: <https://cdn.publisher.example/lib.js>;
rel="preload";
as="script"
Link: <https://cdn.publisher.example/lib.js>;
rel="allowed-alt-sxg";
header-integrity="sha256-XXXXXX"
```
1. The UA recursively prefetches lib.js.sxg.
1. If the user clicks a link the article’s signed exchange, both the main resource of the article and the script are loaded from the prefetched signed exchanges.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. If the user clicks a link the article’s signed exchange, both the main resource of the article and the script are loaded from the prefetched signed exchanges.
If the user navigates to the expected article, both the main resource of the article and the script subresource are loaded from the prefetched signed exchanges.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


## Proposal
While processing preload link HTTP headers in prefetched main resource signed exchange’s inner response:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
While processing preload link HTTP headers in prefetched main resource signed exchange’s inner response:
While prefetching an HTML resource:

Then write an explicit loop that checks if every preload has a matching and allowed prefetch before deciding to use all of the prefetches.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

1. Check whether matching “allowed-alt-sxg” link HTTP header in the inner response exists or not. (Note that if the allowed-alt-sxg link HTTP header has variants and variant-key attributes, the UA must execute the algorithm written in [HTTP Representation Variants](https://httpwg.org/http-extensions/draft-ietf-httpbis-variants.html) spec to find the matching header.)
1. If exists, check whether matching “alternate” link HTTP header in the outer response exists or not.
1. If exists, prefetches the matching signed exchange instead of prefetching the original resource URL.
1. The prefetched signed exchange will be stored to the SignedExchangeCache of the Document. And it will be passed to the next Document and used while processing the preload link header. This behavior is written in [Signed Exchange subresource substitution explainer](./signed-exchange-subresource-subtitution-explainer.md).

## Detailed design discussion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably just remove this sub-header.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

### Content negotiation using Variants and Variant-Key
The **alternate** link header and **allowed-alt-sxg** link headers can have [variants and variant-key](https://httpwg.org/http-extensions/draft-ietf-httpbis-variants.html) attributes to support content negotiation (eg: [WebP support](https://developers.google.com/speed/webp/faq#server-side_content_negotiation_via_accept_headers)).

- In **outer** HTTP response of article.html.sxg from feed.example:
```
Link: <https://feed.example/publisher.example/image_jpeg.sxg>;
rel="alternate";
type="application/signed-exchange;v=b3";
variants-05="accept;image/jpeg;image/webp";
variant-key-05="image/jpeg";
anchor="https://publisher.example/image";
Link: <https://feed.example/publisher.example/image_webp.sxg>;
rel="alternate";
type="application/signed-exchange;v=b3";
variants-05="accept;image/jpeg;image/webp";
variant-key-05="image/webp";
anchor="https://publisher.example/image";
```
- In **inner** response header of article.html.sxg:
```
Link: <https://publisher.example/image>;
rel="allowed-alt-sxg";
variants-05="accept;image/jpeg;image/webp";
variant-key-05="image/jpeg";
header-integrity="sha256-AAA"
Link: <https://publisher.example/image>;
rel="allowed-alt-sxg";
variants-05="accept;image/jpeg;image/webp";
variant-key-05="image/webp";
header-integrity="sha256-BBB"
Link: <https://publisher.example/image>; rel=preload; as=image;
```
If a UA supports WebP, the UA should prefetch **image_webp.sxg** which content is WebP format. Otherwise the UA should prefetch **image_jpeg.sxg** which content is JPEG format.

## Security and Privacy Considerations
The UA must fetch the alternate signed exchange subresource (lib.js.sxg) even if there is the original subresource (lib.js) in the HTTPCache. Otherwise it leaks the state of publisher’s site to the distributor of the signed exchange.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, to prevent tracking (user ID transfer), if the aggregator failed to prefetch a subresource that the main resource preloads, the UA must drop all of the subresource prefetches. If the aggregator prefetches a superset of the preloaded subresources, the UA must drop the ones that weren't preloaded.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


## [Self-Review Questionnaire: Security and Privacy](https://www.w3.org/TR/security-privacy-questionnaire/)
1. What information might this feature expose to Web sites or other parties, and for what purposes is that exposure necessary?
- The existence of the alternative signed exchange in HTTP Cache is exposed.
1. Is this specification exposing the minimum amount of information necessary to power the feature?
- Yes.
1. How does this specification deal with personal information or personally-identifiable information or information derived thereof?
- Signed Exchange should not include personal information.
1. How does this specification deal with sensitive information?
- Signed Exchange should not include sensitive information.
horo-t marked this conversation as resolved.
Show resolved Hide resolved
1. Does this specification introduce new state for an origin that persists across browsing sessions?
- No. The prefetched signed exchange is stored to HTTPCache. But this is the existing behavior when directly prefetching the signed exchange using `<link rel=prelfetch>`.
1. What information from the underlying platform, e.g. configuration data, is exposed by this specification to an origin?
- This exposes whether the UA support this feature or not.
horo-t marked this conversation as resolved.
Show resolved Hide resolved
1. Does this specification allow an origin access to sensors on a user’s device
- No
1. What data does this specification expose to an origin? Please also document what data is identical to data exposed by other features, in the same or different contexts.
- The existence of the alternative signed exchange in HTTP Cache is exposed.
- But this is the same as the existing behavior when directly prefetching the signed exchange using `<link rel=prelfetch>`.
1. Does this specification enable new script execution/loading mechanisms?
- No
horo-t marked this conversation as resolved.
Show resolved Hide resolved
1. Does this specification allow an origin to access other devices?
- No
1. Does this specification allow an origin some measure of control over a user agent’s native UI?
- No
1. What temporary identifiers might this this specification create or expose to the web?
- No
horo-t marked this conversation as resolved.
Show resolved Hide resolved
1. How does this specification distinguish between behavior in first-party and third-party contexts?
- This feature should work well with third-party signed exchange.
- To avoid leaking the state of publisher’s site to the distributor of the signed exchange, the UA must fetch the alternate signed exchange subresource even if there is the original subresource in the HTTPCache.
1. How does this specification work in the context of a user agent’s Private \ Browsing or "incognito" mode?
- No difference while the user is browsing sites in Private mode.
1. Does this specification have a "Security Considerations" and "Privacy Considerations" section?
- Yes
1. Does this specification allow downgrading default security characteristics?
- No
horo-t marked this conversation as resolved.
Show resolved Hide resolved
Loading