-
Notifications
You must be signed in to change notification settings - Fork 146
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
rfc6265bis empty domain attribute #1332
Comments
This test now lives at https://wpt.fyi/results/cookies/attributes/domain/domain.sub.html?label=master&label=experimental&aligned
The test works like so:
There's disagreement between Chrome (which doesn't set a cookie) and Firefox & Safari (which do) here.
It does seem a little strange that some browsers would send a cookie, I'm not sure if that could be abused though -- if you can modify a domain attribute to make it empty, you can modify it to whatever you want. Do we keep it as SHOULD? Change to MUST? Thoughts @chlily1 @englehardt? |
I believe the correct behavior (according to the SHOULD) should be to not store a cookie, since the empty domain= attribute should be ignored, leaving the last valid one (domain=sibling.example.org) which doesn't match the current host. I wouldn't mind changing this to a MUST; it seems in line with the definition of "MUST" in RFC 2119. Agreed that it's weird the Domain attribute behaves like this. In Chromium's parsing code, there's a special case for empty Domain attributes, different from all the other attributes. The value of ignoring an empty domain attribute might have been to avoid possible ambiguity in the correct behavior of an empty domain attribute? I don't like either of the alternatives suggested above. Having behavior similar to path (where an empty attribute means filling in a default, in this case the current host) might be dangerous, as it could lead to unintentionally sending the cookie to subdomains which may be less-secure origins. Invalidating the cookie entirely is inconsistent with what happens when other attributes end up with nonsensical values (see issue #933). I think the most sensible thing is to either continue to ignore empty domain attributes (and make the SHOULD a MUST), or to say that cookies with an empty domain attribute as the last domain attribute behave as host-only cookies (effectively treating |
(Do we know if Firefox/Safari treat it as a host cookie, or do they fill in some default value for the domain attribute?) |
Gah, it took me a minute to figure out what was happening, and why Firefox & Safari would send a cookie, but Chrome wouldn't. It turns out it was a typo:
There should be a semi-colon between (edit: the typo shouldn't really account for the difference here, I think?) |
I should have just looked at the source... https://source.chromium.org/chromium/chromium/src/+/main:net/cookies/parsed_cookie.cc;l=770?q=parsedcookie That check was added in 2016, to be more compatible with other UAs, in theory. From the bug:
Those results don't map to what I currently see (but IE and Edge are dead and Chromium now, respectively). For a test like, which is opened on
Safari and Firefox pass, Chrome fails. Unsure what to make of the comments from 2016, but it seems like we want an empty domain attribute to be equivalent to no domain attribute at all, i.e., a host cookie (rather than falling back to the last known parsed domain attribute value). |
Where do you see this? Both a local run and wpt.fyi show Chrome passing this test |
Sorry, I could have been more clear. |
I don't have access to a Mac so I don't know what Safari does. But I did test Chrome and Firefox Test Cases and Results(All to be run on example.com) Test case 1: If the cookie-av is ignored then we should have only the Clear all cookies on example.com then run
Test case 2: If the cookie-av is ignored then we should have only the Clear all cookies on example.com then run
Test case 3: If the cookie-av is ignored then we should have only the Clear all cookies on example.com then run
SummarySo it appears that Chrome is ignoring the cookie-av while Firefox always make the cookie host-only when it encounters |
Here's a WIP CL to update WPTs, I'll add some edit: actual CL https://chromium-review.googlesource.com/c/chromium/src/+/3203692 |
Results from Safari for the above 3 tests: TC1: |
Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. httpwg/http-extensions#1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See httpwg/http-extensions#1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754
Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. httpwg/http-extensions#1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See httpwg/http-extensions#1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754 Bug: 1255273
Thanks for removing the undefined behavior from the spec! Much appreciated. |
Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. httpwg/http-extensions#1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See httpwg/http-extensions#1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754 Bug: 1255273
Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. httpwg/http-extensions#1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See httpwg/http-extensions#1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754 Bug: 1255273
Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. httpwg/http-extensions#1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See httpwg/http-extensions#1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754 Bug: 1255273
Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. httpwg/http-extensions#1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See httpwg/http-extensions#1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754 Bug: 1255273
Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. httpwg/http-extensions#1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See httpwg/http-extensions#1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754 Bug: 1255273 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3203692 Reviewed-by: Steven Bingler <[email protected]> Commit-Queue: Mike Taylor <[email protected]> Cr-Commit-Position: refs/heads/main@{#931471}
Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. httpwg/http-extensions#1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See httpwg/http-extensions#1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754 Bug: 1255273 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3203692 Reviewed-by: Steven Bingler <[email protected]> Commit-Queue: Mike Taylor <[email protected]> Cr-Commit-Position: refs/heads/main@{#931471}
Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. httpwg/http-extensions#1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See httpwg/http-extensions#1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754 Bug: 1255273 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3203692 Reviewed-by: Steven Bingler <[email protected]> Commit-Queue: Mike Taylor <[email protected]> Cr-Commit-Position: refs/heads/main@{#931471}
…t 6265bis update., a=testonly Automatic update from web-platform-tests Update some domain tests to follow latest 6265bis update. Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. httpwg/http-extensions#1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See httpwg/http-extensions#1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754 Bug: 1255273 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3203692 Reviewed-by: Steven Bingler <[email protected]> Commit-Queue: Mike Taylor <[email protected]> Cr-Commit-Position: refs/heads/main@{#931471} -- wpt-commits: 58dba963a5607ef657943e21b16a416109e422b0 wpt-pr: 31162
…t 6265bis update., a=testonly Automatic update from web-platform-tests Update some domain tests to follow latest 6265bis update. Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. httpwg/http-extensions#1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See httpwg/http-extensions#1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754 Bug: 1255273 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3203692 Reviewed-by: Steven Bingler <[email protected]> Commit-Queue: Mike Taylor <[email protected]> Cr-Commit-Position: refs/heads/main@{#931471} -- wpt-commits: 58dba963a5607ef657943e21b16a416109e422b0 wpt-pr: 31162
Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. httpwg/http-extensions#1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See httpwg/http-extensions#1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754 Bug: 1255273 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3203692 Reviewed-by: Steven Bingler <[email protected]> Commit-Queue: Mike Taylor <[email protected]> Cr-Commit-Position: refs/heads/main@{#931471}
Also, add a few more tests inspired by bingler@'s GitHub comments. Previously, the cookie spec left an empty domain attribute as undefined behavior with SHOULD-level guidance. httpwg/http-extensions#1709 changes the spec to require handling of a cookie as a host cookie when its last domain attribute is empty. This matches the current behavior of Firefox and Safari. See httpwg/http-extensions#1332 for more discussion. Change-Id: Ibf4f243c929b11768ff406e940d6988a37434754 Bug: 1255273 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3203692 Reviewed-by: Steven Bingler <[email protected]> Commit-Queue: Mike Taylor <[email protected]> Cr-Commit-Position: refs/heads/main@{#931471} NOKEYCHECK=True GitOrigin-RevId: 3813959c16bf46f428c7691a8e1a916538793e4a
The behavior for when the domain attribute is empty is confusing when there are multiple domain attributes.
The spec says:
This means that when there's a single empty domain attribute, and the implementation follows this SHOULD, then this attribute is removed. No problem there. But when there's two attributes including an empty domain attribute, then only the empty attribute is removed. This means that the three following set-cookie headers are equivalent:
When the domain is
foo.example.org
all 3 cookies end up stored. When the domain ishome.example.org
all 3 are dropped.The first case is confusing because it is in stark contrast with the path attribute where an empty path equals
default-path
and the final path wins, so an empty final path has the effect of "resetting" the path. I would also suggest the first case is not intuitive.An implementation that does not follow the SHOULD would have undefined behavior. This is the only place in the spec where this is the case I believe. It would be good to get rid of it.
I would suggest first changing the SHOULD into a MUST so as to avoid differing behaviors. I would also suggest either having behavior similar to path, or invalidating the cookie entirely.
(This is a followup to #1136 and the relevant http-state test was as follow:)
The text was updated successfully, but these errors were encountered: