<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>200345</bug_id>
          
          <creation_ts>2019-08-01 08:03:00 -0700</creation_ts>
          <short_desc>SameSite cookies missing after Safari Tab recovery</short_desc>
          <delta_ts>2021-07-08 16:25:07 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Page Loading</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Chris Dumez">cdumez</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>arturoiam760</cc>
    
    <cc>beidson</cc>
    
    <cc>bradley.ayers</cc>
    
    <cc>dbates</cc>
    
    <cc>ggaren</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>xfalcox</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1557603</commentid>
    <comment_count>0</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-01 08:03:00 -0700</bug_when>
    <thetext>SameSite cookies missing after Safari Tab recovery.

Demo: https://rocky-fjord-97287.herokuapp.com

1. Load the page on iOS
2. Click the &quot;Refresh Cookie Time&quot; 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).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1557604</commentid>
    <comment_count>1</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2019-08-01 08:03:48 -0700</bug_when>
    <thetext>Service workers are involved as well. Here is the source:
https://github.com/xfalcox/safari-sw-samesite-bug</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1557605</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-08-01 08:06:28 -0700</bug_when>
    <thetext>&lt;rdar://problem/53814606&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1558090</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2019-08-02 13:32:30 -0700</bug_when>
    <thetext>*** Bug 200307 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1558887</commentid>
    <comment_count>4</comment_count>
    <who name="Rafael">xfalcox</who>
    <bug_when>2019-08-06 12:56:58 -0700</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1775856</commentid>
    <comment_count>5</comment_count>
    <who name="Bradley Ayers">bradley.ayers</who>
    <bug_when>2021-07-08 16:25:07 -0700</bug_when>
    <thetext>I&apos;ve been investigating a similar issue, but this one&apos;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 &gt; Storage &gt; Cookies, both `MyStrictCookie` and `MyLaxCookie` are visible.
    - In Network &gt; XHR, the request sends `MyStrictCookie` and `MyLaxCookie`.
    - In Network &gt; Other, the WebSocket request sends `MyStrictCookie` and `MyLaxCookie`.

3. Problematic behavior scenario:

  1. Close the window.
  2. Restore the window via History &gt; &quot;Reopen Last Closed Window&quot;.

    - In Web Inspector &gt; Storage &gt; Cookies, only `MyLaxCookie` is visible (`MyStrictCookie` is missing).
    - The Network &gt; XHR, the request sends `MyStrictCookie` and `MyLaxCookie`.
    - The Network &gt; 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 &quot;Duplicate Tab&quot; from the tab&apos;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 &gt; Storage. I&apos;d expect consistency between the two.
  - Further more, the inconsistency of having `MyStrictCookie` sent for XHR but not for WebSocket seems incorrect. I&apos;d expect it to be sent for both, or sent for neither. And playing off the previous point, given the cookie isn&apos;t visible in Web Inspector, I expected neither.
  - The tab can be &quot;fixed&quot; by focusing the location bar with the URL and pressing enter. Presumably because this causes a &quot;top level navigation&quot;, 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(&apos;site-a.com&apos;)` from a different domain. My understanding is this simply following the SameSite spec. Is it possible that tabs in a &quot;re-opened window&quot; are created using a similar mechanism, and it&apos;s for that reason that they don&apos;t satisfy the SameSite strict checks, and the tabs are tainted as &quot;not trusted&quot;.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>