compute site-for-cookies from ancestor chain of a Frame - #3293
Merged
Conversation
nikneym
force-pushed
the
nikneym/samesite-strict-bypass
branch
4 times, most recently
from
August 27, 2026 07:03
a91443d to
dbf80e5
Compare
karlseguin
reviewed
Aug 28, 2026
karlseguin
left a comment
Collaborator
There was a problem hiding this comment.
The same logic should be applied to document.getCookies and Workers then?
nikneym
force-pushed
the
nikneym/samesite-strict-bypass
branch
from
August 28, 2026 12:47
d3c3495 to
be441b5
Compare
karlseguin
reviewed
Aug 29, 2026
karlseguin
left a comment
Collaborator
There was a problem hiding this comment.
Can be merged once the comments are corrected.
| is_navigation: bool = true, | ||
| prefix: ?[]const u8 = null, | ||
| origin_url: ?[:0]const u8 = null, | ||
| // null means there is no initiating document (a browser-initiated |
Collaborator
There was a problem hiding this comment.
but browser-initiated requests do pass a cookie_origin . This comment seems wrong then? So now I'm curious when it is/should be null?
| const origin_url = origin_url_ orelse return true; | ||
| const origin_host = URL.getHostname(origin_url); | ||
| pub fn areSameSite(maybe_origin_url: ?SiteForCookies, target_host: []const u8) bool { | ||
| // No initiating document (browser-initiated request). |
Collaborator
There was a problem hiding this comment.
Repeats a (I think wrong) comment
| // .none is the site-for-cookies of a frame whose ancestor chain contains | ||
| // a cross-site document. Even though the target here is the cookies' own | ||
| // site, the request is cross-site: Strict is withheld. (Lax still rides | ||
| // navigations; whether a subframe load should count as one is #240.) |
Collaborator
There was a problem hiding this comment.
Took me a bit to find the #240 reference. I don't think a bare hashtag to a different project is useful.
The site for cookies were computed from the immediate parent `Frame`, which would allow sending a cookie that's `SameSite=Strict` from 2 levels deep under. Directly from RFC6265bis, this PR essentially implements (except for step 4, we skip host-less ancestors):
Given a Document (document), the following algorithm returns its
"site for cookies":
1. Let top-document be the active document in document's navigable's
top-level traversable.
2. Let top-origin be the origin of top-document's URI if top-
document's sandboxed origin browsing context flag is set, and
top-document's origin otherwise.
3. Let documents be a list consisting of the active documents of
document's inclusive ancestor navigables.
4. For each item in documents:
1. Let origin be the origin of item's URI if item's sandboxed
origin browsing context flag is set, and item's origin
otherwise.
2. If origin is not same-site with top-origin, return an origin
set to an opaque origin.
5. Return top-origin.
Also updates matchCookies/onCookieChanged from the hard-coded "same-site + navigation" to areSameSite(exec.siteForCookies(), host) and is_navigation=false.
karlseguin
force-pushed
the
nikneym/samesite-strict-bypass
branch
from
September 1, 2026 23:28
be441b5 to
07198b7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The site-for-cookies were computed from the immediate parent
Frame, which allow sending a cookie that'sSameSite=Strictfrom 2 levels deep under. Directly from RFC6265bis, this PR essentially implements (except for step 4, we skip host-less ancestors):Given a Document (document), the following algorithm returns its
"site for cookies":
Let top-document be the active document in document's navigable's
top-level traversable.
Let top-origin be the origin of top-document's URI if top-
document's sandboxed origin browsing context flag is set, and
top-document's origin otherwise.
Let documents be a list consisting of the active documents of
document's inclusive ancestor navigables.
For each item in documents:
Let origin be the origin of item's URI if item's sandboxed
origin browsing context flag is set, and item's origin
otherwise.
If origin is not same-site with top-origin, return an origin
set to an opaque origin.
Return top-origin.