-
Notifications
You must be signed in to change notification settings - Fork 15
Update explainer to unify storage access permissions and replace CORS with storage access headers #50
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
base: main
Are you sure you want to change the base?
Conversation
Update explainer to unify top-level-storage-access permission with storage-access permission by changing language that references different permissions. Update explainer to replace CORS with storage-access-headers
Remove reference to cors in the example code.
Update link to also have acronym
johannhof
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, had a couple of thoughts / questions :)
| let img = document.createElement('img'); | ||
| // CORS would be required for the SameSite=None cookies to be attached. | ||
| // SAH would be required for the SameSite=None cookies to be attached. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth spelling out Storage Access Headers here, even if it breaks the line.
| 1. Request permission via the permissions API. | ||
| 1. This would allow implementation-defined acceptance or rejection steps; if any are triggered, reject the requestStorageAccessFor call or skip to the permission-saving step. | ||
| 1. If acceptance is returned, save a permission for the pair `{top-level site, requested origin}`. Note that the permission would be separate from the permission granted by `requestStorageAccess`. | ||
| 1. If acceptance is returned, save a permission for the pair `{top-level site, requested origin}`. Note that the permission would be the same permission granted by `requestStorageAccess`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I wonder if we even need this proposed draft spec section anymore, now that we have the actual spec. I think I'd be okay with removing it.
@cfredric any strong opinions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, IMO we should defer to the real spec now that there is one. (On that note, should this PR also modify the spec, so that the spec and explainer stay in sync with each other?)
Similarly, I don't think we need the section below which discusses under which circumstances to attach cookies (and how to modify Fetch), since the Storage Access Headers spec already defines those details in its spec.
| Other potential embeddee opt-in mechanisms, especially for those user agents that do not support Related Website Sets, could include: | ||
|
|
||
| * Specification of a `.well-known` configuration that can be checked to ensure embeddee opt-in. | ||
| * Specification of a `.well-known` configuration or API that can be checked to ensure embeddee opt-in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm what do you mean here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the possible solutions that was brought up at TPAC was allowing a site to use an API instead of (or in addition to) a .well-known file. Adding it to the explainer for more visibility.
| * For nested resource loads, [a variant of the site for cookies algorithm](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-10#section-5.2.1) could be used to avoid unrelated iframes from using a grant, potentially with a permission policy opt-out, as suggested in [a recent security analysis](https://github.com/privacycg/storage-access/issues/113). | ||
| * Another alternative would be requiring explicit per-frame opt-in via normal `requestStorageAccess` call; see below. | ||
| * `SameSite=None` cookies granted via `requestStorageAccessFor` on subresources should only be attached on CORS-enabled requests. For example, an `<img>` without a [`crossorigin` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) set to `use-credentials` would not have `SameSite=None` cookies attached, even with a valid grant. This ensures the server is aware of the caller and can react accordingly; because the response must have the appropriate header to be read by the embedder, this ensures the embeddee has opted in. Note that CORS is not possible on navigations; this requirement is not intended to protect `<iframe>` elements. | ||
| * `SameSite=None` cookies granted via `requestStorageAccessFor` on subresources should only be attached on requests that include the header `Sec-Fetch-Storage-Access: active`. For example, an `<img>` without a [`crossorigin` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) set to `use-credentials` would not have `SameSite=None` cookies attached, even with a valid grant. This ensures the server is aware of the caller and can react accordingly; because the response must have the appropriate header to be read by the embedder, this ensures the embeddee has opted in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'd need to change more of this sentence, the <img> example now also seems unrelated.
I kind of feel like we could remove a lot here and mostly point to the existing security protections for the storage access API, given that this would reuse its permission.
| #### CSRF Considerations | ||
|
|
||
| A side effect of disabling `SameSite=None` cookies is that attacks like CSRF become significantly harder to carry out. While the existing `requestStorageAccess` API already allows a mechanism to opt a specific frame out of this protection, `requestStorageAccessFor` could be used more broadly due to its relaxation of the `<iframe>` requirement. Additionally, `requestStorageAccessFor` is invoked by the embedder, as opposed to the embedded origin which gets access to cross-site cookies. This makes additional opt-in requirements for embedded resources, like those described above, more attractive. Note that the suggested CORS requirement would not block cookies from being sent other than on pre-flighted requests, though causing such cookies to be sent could also potentially be done via opening popups or triggering other navigations, reducing the concern. | ||
| A side effect of disabling `SameSite=None` cookies is that attacks like CSRF become significantly harder to carry out. While the existing `requestStorageAccess` API already allows a mechanism to opt a specific frame out of this protection, `requestStorageAccessFor` could be used more broadly due to its relaxation of the `<iframe>` requirement. Additionally, `requestStorageAccessFor` is invoked by the embedder, as opposed to the embedded origin which gets access to cross-site cookies. This makes additional opt-in requirements for embedded resources, like those described above, more attractive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole section can probably be removed?
Co-authored-by: Johann Hofmann <mail@johann-hofmann.com>
Co-authored-by: Johann Hofmann <mail@johann-hofmann.com>
Update explainer to describe the unification of the
top-level-storage-accessandstorage-accesspermissions and the replacement of CORS with Storage Access Headers as the security mechanism for the API.