Treat loads the result from location.reload() as samesite
Categories
(Core :: DOM: Security, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox61 | --- | affected |
People
(Reporter: April, Unassigned)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
(Whiteboard: [domsecurity-backlog1])
Reporter | ||
Updated•7 years ago
|
Comment 2•7 years ago
|
||
Comment 3•7 years ago
|
||
Comment 4•7 years ago
|
||
Comment 5•7 years ago
|
||
Reporter | ||
Comment 6•7 years ago
|
||
Comment 7•7 years ago
|
||
Comment 8•7 years ago
|
||
Comment 9•7 years ago
|
||
Reporter | ||
Comment 10•7 years ago
|
||
Reporter | ||
Updated•7 years ago
|
Comment 11•5 years ago
|
||
This behavior or bug (since it seems debated what it is) prevent a workaround for the following bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1599368.
If the user refreshes, I think we can assume that they mean to visit this as a first-party website.
However, if the website refreshes with location.reload() then I think we shouldn't.
I do not think a refresh initiated by a page itself should be considered cross-origin. That is no code coming from another website that initiates that additional navigation (unless the page suffers from some XSS). Treating it as cross-origin looks to me as over-interpreting what SameSite is meant for.
Of course a site doing a page refresh by itself could then enable CSRF attacks if doing it on a sensitive page, and if the browser does not behave as Firefox currently does. (So, if it does send strict cookies on refresh of a page initially loaded cross-origin). But I think that is the web site developer responsibility to be aware of the risk.
In my case, I would enable the refresh only on read-only pages. Anyway not having the cookie from the cross-site navigation already cause sensitive url to be redirected on non-sensitive url in my site case. I know some other site may instead just reply directly a 403/401 while staying on the url, causing a refresh to be potentially dangerous. But once again, that is the job of the site developers to be aware of this. If they want to be properly protected from CSRF attack only through SameSite Strict cookies, they just cannot leave the url unchanged when required cookies are missing.
Additional note on this bug/behavior: hitting F5 does exhibit it, but refreshing the page by hitting enter from the location (URL) bar does not: strict cookies are then sent, even if the page was loaded from a cross site link. From my viewpoint, that is just another way of refreshing a page. If it is wanted to not send Strict Cookies when refreshing a cross-site loaded page, then hitting the enter key without changing the url in the location bar should not send them either.
Comment 12•4 years ago
|
||
This was explored a bit further by Chrome folks here: https://github.com/httpwg/http-extensions/issues/628#issuecomment-754845672, and they've proposed new spec language here: https://github.com/httpwg/http-extensions/pull/1384.
Testing Firefox 87 manually I see the following:
- Reloads triggered by browser UI (i.e., refresh button, shift+refresh button, control+r, f5) all preserve the prior same-site state meaning if the initial load was cross-site then all of the refreshes are as well
location.reload()
will preserve the prior same-site statemeta refresh
will switch from cross-site to same-sitewindow.location = window.location;
will switch from cross-site to same-site
So we're certainly inconsistent at the moment. I suggest we align with the proposed spec language from the Chrome folks. Namely that we want to preserve the same site status on reloads triggered by a user, but allow reloads triggered by a site to become samesite. That would mean treating loads that result from location.reload() as samesite.
The alternate means locking down all self-navigations a page can perform, which seems difficult in practice. An attacker would need first-party JS access to trigger such a self-navigation, and at that point their JS also has the ability to read out non-HTTPOnly samesite=strict cookies / trigger embedded requests to any samesite endpoint with samesite=strict cookies. And even if we locked down all self-navigations, that JS could hook into the very first user click (anywhere on the page) and use it to navigate.
Comment 13•4 years ago
|
||
(In reply to Steven Englehardt [:englehardt] from comment #12)
So we're certainly inconsistent at the moment. I suggest we align with the proposed spec language from the Chrome folks. Namely that we want to preserve the same site status on reloads triggered by a user, but allow reloads triggered by a site to become samesite. That would mean treating loads that result from location.reload() as samesite.
I agree that consistency is key
- I am fine with updating our implementation to match the proposed algorithm. Ideally we have web-platform tests for all the scenarios mentioned above. This way we not only agree in the spec but also ensure we are all actually follow the spec.
Updated•4 years ago
|
Comment 14•4 years ago
|
||
Hi everybody, we stumbled upon this behaviour while trying to understand the reason the login window of OpenMediaVault project didn't work sometime (landing from a different origin, we discovered). Please see the detailed analysis at the bottom of this issue: https://github.com/openmediavault/openmediavault/issues/926#issuecomment-761558724
The login procedure uses an XHR POST to login and receives a "logged in" SameSite=strict cookie in the response, that is stored but not passed back at the next refresh of the page (even when opening the login page coming from a different origin). The subsequent refresh doesn't contain the cookie because of what discussed so far.
Note that the XHR seems to pass (previously-set) SameSite=strict cookies, so it seems XHR doesn't follow the same rule of refresh / F5. It seems that the browser is in "same-site" mode for XHR, but not for the refresh. Please keep XHR into account in this discussion.
Thanks.
Updated•4 years ago
|
Updated•2 years ago
|
Comment 15•1 year ago
|
||
(In reply to Steven Englehardt [:englehardt] from comment #12)
[...]
Testing Firefox 87 manually I see the following:
- Reloads triggered by browser UI (i.e., refresh button, shift+refresh button, control+r, f5) all preserve the prior same-site state meaning if the initial load was cross-site then all of the refreshes are as well
location.reload()
will preserve the prior same-site statemeta refresh
will switch from cross-site to same-sitewindow.location = window.location;
will switch from cross-site to same-site[...]
The methods meta refresh
and window.location = window.location
behave identically when it comes to switching from cross-site to same-site (in Firefox). But in the Chrome browser, they differ when it comes to caching. A refresh via window.location = window.location
caches the response. The next refresh with window.location = window.location
then loads the response from the cache. With meta refresh
, however, the response is neither cached nor loaded from the cache.
This difference was relevant for me when solving a specific problem. So I like to add this here.
I'm testing wich Chrome in version 120.0.6099.225.
Btw. The behavior described by [:englehardt] still applies to Firefox in version 115.7.0esr.
Description
•