Bug 200345
Summary: | SameSite cookies missing after Safari Tab recovery | ||
---|---|---|---|
Product: | WebKit | Reporter: | Chris Dumez <cdumez> |
Component: | Page Loading | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | achristensen, arturoiam760, beidson, bradley.ayers, dbates, ggaren, webkit-bug-importer, xfalcox, youennf |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Chris Dumez
SameSite cookies missing after Safari Tab recovery.
Demo: https://rocky-fjord-97287.herokuapp.com
1. Load the page on iOS
2. Click the "Refresh Cookie Time" button
3. Reload the page a couple times and notice that the cookie time is there and does not change (cookie is served)
4. Kill MobileSafari
5. Relaunch MobileSafari
6. Reload the tab a couple times and notice that the cookie is nil for every reload (cookie is no longer served).
Reported on Twitter by Rafael Silva (@Rafael_falco).
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Chris Dumez
Service workers are involved as well. Here is the source:
https://github.com/xfalcox/safari-sw-samesite-bug
Radar WebKit Bug Importer
<rdar://problem/53814606>
Alexey Proskuryakov
*** Bug 200307 has been marked as a duplicate of this bug. ***
Rafael
I can repro this bug on latest Mac OS Safari (12.1.1) if you enable the feature to re-open the last tabs on app start.
So this seems to affect both Mac OS and iOS on both current and next Safari.
Bradley Ayers
I've been investigating a similar issue, but this one's related to SameSite strict and WebSockets.
Reproduction steps:
1. Given a site (e.g. site-a.com) with page that:
- sets a SameSite strict cookie (`MyStrictCookie`).
- sets a SameSite lax cookie (`MyLaxCookie`).
- makes an XHR request to the same domain (e.g. `/api`).
- makes a WebSocket request to the same domain (e.g. `/ws`).
2. Expected behavior scenario:
1. Load the page by typing in the URL and pressing Enter.
- In Web Inspector > Storage > Cookies, both `MyStrictCookie` and `MyLaxCookie` are visible.
- In Network > XHR, the request sends `MyStrictCookie` and `MyLaxCookie`.
- In Network > Other, the WebSocket request sends `MyStrictCookie` and `MyLaxCookie`.
3. Problematic behavior scenario:
1. Close the window.
2. Restore the window via History > "Reopen Last Closed Window".
- In Web Inspector > Storage > Cookies, only `MyLaxCookie` is visible (`MyStrictCookie` is missing).
- The Network > XHR, the request sends `MyStrictCookie` and `MyLaxCookie`.
- The Network > WebSocket, the WebSocket request only sends `MyLaxCookie` (`MyStrictCookie` is missing).
Other notes worth mentioning:
- This behavior affects all tabs in a re-opened window. However new tabs created in that window are not affected.
- If you "Duplicate Tab" from the tab's context menu, the new tab will exhibit the same behavior as the duplicated tab (i.e. it inherits some security tainting).
- It seems incorrect that the XHR request sends `MyStrictCookie`, yet the cookie is not visible in Web Inspector > Storage. I'd expect consistency between the two.
- Further more, the inconsistency of having `MyStrictCookie` sent for XHR but not for WebSocket seems incorrect. I'd expect it to be sent for both, or sent for neither. And playing off the previous point, given the cookie isn't visible in Web Inspector, I expected neither.
- The tab can be "fixed" by focusing the location bar with the URL and pressing enter. Presumably because this causes a "top level navigation", and pages loaded via top level navigation always have access to SameSite strict cookies.
- The tab behavior can be reproduced by creating a tab via `window.open('site-a.com')` from a different domain. My understanding is this simply following the SameSite spec. Is it possible that tabs in a "re-opened window" are created using a similar mechanism, and it's for that reason that they don't satisfy the SameSite strict checks, and the tabs are tainted as "not trusted".