New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 782310 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner:
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 3
Type: Bug



Sign in to add a comment

document.cookie is not updated for explicit 'path=' cookies when using history.pushState

Project Member Reported by fiala@google.com, Nov 7 2017

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



 
Labels: Needs-Triage-M62 Hotlist-Google
Cc: krajshree@chromium.org
Labels: Needs-Feedback
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...!!

Comment 3 by fiala@google.com, Nov 8 2017

Hi,

Please see: https://jsfiddle.net/davidfiala/6dcsho4w/1/



Project Member

Comment 4 by sheriffbot@chromium.org, Nov 8 2017

Labels: -Needs-Feedback
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

Comment 5 by jsb...@chromium.org, Nov 11 2017

Cc: bsittler@chromium.org mkwst@chromium.org
Status: Untriaged (was: Unconfirmed)
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?

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.

Comment 7 by costan@google.com, Dec 5 2017

Cc: -mkwst@chromium.org pwnall@chromium.org
Owner: mkwst@chromium.org
Status: Assigned (was: Untriaged)
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?

Comment 8 by mkwst@chromium.org, Dec 5 2017

Cc: annevank...@gmail.com
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?
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.)

Comment 10 by costan@google.com, Dec 6 2017

Cc: -pwnall@chromium.org mkwst@chromium.org
Owner: pwnall@chromium.org
Status: WontFix (was: Assigned)
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