document.cookie is not updated for explicit 'path=' cookies when using history.pushState |
|||||||
Issue description
Chrome Version : 62.0.3202.89
OS Version:
URLs (if applicable) :
Other browsers tested:
Add OK or FAIL after other browsers where you have tested this issue:
Safari 5:
Firefox 4.x:
IE 7/8/9:
What steps will reproduce the problem?
1. navigate to a site on /
2. in console, run document.cookie = 'foo=bar;path=/test'
3. read document.cookie and notice foo is absent (good)
3. navigate to /test, read document.cookie and notice foo is present (good)
4. navigate to /, run window.history.pushState('','','/test'), read document.cookie and notice foo is absent (bad)
What is the expected result?
Since document.location and location.href both believe you are at /test, the foo cookie should be available.
What happens instead of that?
foo cookie is not present in document.cookie
UserAgentString: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36
,
Nov 8 2017
fiala@ - Thanks for filing the issue...!! Could you please provide a sample test file to test the issue from TE-end. If possible please provide a sample screen cast or screenshot of issue. This will help us in triaging the issue further. Thanks...!!
,
Nov 8 2017
Hi, Please see: https://jsfiddle.net/davidfiala/6dcsho4w/1/
,
Nov 8 2017
Thank you for providing more feedback. Adding requester "krajshree@chromium.org" to the cc list and removing "Needs-Feedback" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Nov 11 2017
I tried in Safari 10.1, Firefox 56, and Edge 16. None of them show a foo cookie using the jsfiddle steps either. document.cookie returns the "cookie-string for the document's URL" https://html.spec.whatwg.org/multipage/dom.html#dom-document-cookie And document.pushState() changes the document's URL: https://html.spec.whatwg.org/multipage/history.html#dom-history-replacestate ... so the reporter's intuition that the reported cookies would change is reasonable. On the other hand, knowing how browsers are implemented, I'd be surprised if this behaved that way. :) Similarly, I would not expect the controlling Service Worker to change if the document's URL is modified. bsittler@, mkwst@ - any idea if this behavior is specified anywhere? File a bug against HTML?
,
Nov 11 2017
I don't know about standardization, but I certainly wouldn't want us to change this behavior without careful thought. I certainly would not expect pushState to change the view of the cookie jar, no more than I would expect setting document.domain to do so.
,
Dec 5 2017
mkwst@: Assigning to you for security expertise. Please assign back to me if you'd like us (OWP Storage) to track & implement the resolution, once we have it. Intuitively, I agree with #6 -- being able to get cookies for different directories via pushState seems to defeat the point of scoping. On the flip side, given that no other storage APIs I'm aware of has path scoping (the principal is the origin), I could accept the perspective that paths are only used as a query filter (on the cookie store), and don't provide any security guarantees. Which perspective is right?
,
Dec 5 2017
I agree with the existing behavior in browsers. Conceptually, I don't think `pushState` _really_ change the document's URL. It just pretends to. The comparison to `document.domain` is apt. +Anne for a perspective from HTML, perhaps he disagrees with me?
,
Dec 5 2017
I think the HTML Standard needs to define something like "cookie URL" (also to make about:blank and such clearer); there's an open issue somewhere. We wouldn't update the "cookie URL" for pushState(). (Currently cookies have all kinds of issues, see https://github.com/whatwg/html/labels/topic%3A%20cookie.)
,
Dec 6 2017
I filed https://github.com/whatwg/html/issues/3274 to track the spec change. It seems like we won't be changing our behavior, so I'm closing this bug. I'll be watch the spec issue, but please don't hesitate to file a bug should we need to change our implementation. |
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by manoranj...@chromium.org
, Nov 7 2017