⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 245441 in webkit


Ignore:
Timestamp:
May 17, 2019, 3:14:50 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r241918 - Same Site Lax cookies are not sent with cross-site redirect from client-initiated load
https://bugs.webkit.org/show_bug.cgi?id=194906
<rdar://problem/44305947>

Reviewed by Brent Fulgham.

Source/WebCore:

Ensure that a request for a top-level navigation is annotated as such regardless of whether
the request has a computed Same Site policy.

"New loads" initiated by a the client (Safari) either by API or a human either explicitly
typing a URL in the address bar or Command + clicking a hyperlink to open it in a new window/tab
are always considered Same Site. This is by definition from the spec. [1] as we aren't navigating
from an existing page. (Command + click should be thought of as a convenience to the user from
having to copy the hyperlink's URL, create a new window, and paste the URL into the address bar).
Currently the frame loader marks a request as a top-level navigation if and only if the request
does not have a pre-computed Same Site policy. However, "New loads" have a pre-computed Same Site
policy. So, these loads would never be marked as a top-level navigation by the frame loading code.
Therefore, if the "new load" turned out to be a cross-site redirect then WebKit would incorrectly
tell the networking stack that the load was a cross-site, non-top-level navigation, and per the
Same Site spec [2], the networking stack would not send Same Site Lax cookies. Instead,
WebKit should unconditionally ensure that requests are marked as a top-level navigation, if applicable.

[1] See Note for (1) in <https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-02#section-5.2>
[2] <https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-02#section-5.3.7.1>

Test: http/tests/cookies/same-site/user-load-cross-site-redirect.php

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::addExtraFieldsToRequest): Unconditionally update the request's top-
level navigation bit.

  • platform/network/ResourceRequestBase.cpp:

(WebCore::ResourceRequestBase::setAsIsolatedCopy): Unconditionally copy a request's top-
level navigation bit.

LayoutTests:

Add a test that is representative of a user loading a cross-site page that redirects
to a page that expects Same Site Lax cookies.

  • http/tests/cookies/same-site/user-load-cross-site-redirect-expected.txt: Added.
  • http/tests/cookies/same-site/user-load-cross-site-redirect.php: Added.
Location:
releases/WebKitGTK/webkit-2.24
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.24/LayoutTests/ChangeLog

    r245440 r245441  
     12019-02-21  Daniel Bates  <dabates@apple.com>
     2
     3        Same Site Lax cookies are not sent with cross-site redirect from client-initiated load
     4        https://bugs.webkit.org/show_bug.cgi?id=194906
     5        <rdar://problem/44305947>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Add a test that is representative of a user loading a cross-site page that redirects
     10        to a page that expects Same Site Lax cookies.
     11
     12        * http/tests/cookies/same-site/user-load-cross-site-redirect-expected.txt: Added.
     13        * http/tests/cookies/same-site/user-load-cross-site-redirect.php: Added.
     14
    1152019-04-03  Myles C. Maxfield  <mmaxfield@apple.com>
    216
  • releases/WebKitGTK/webkit-2.24/Source/WebCore/ChangeLog

    r245440 r245441  
     12019-02-21  Daniel Bates  <dabates@apple.com>
     2
     3        Same Site Lax cookies are not sent with cross-site redirect from client-initiated load
     4        https://bugs.webkit.org/show_bug.cgi?id=194906
     5        <rdar://problem/44305947>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Ensure that a request for a top-level navigation is annotated as such regardless of whether
     10        the request has a computed Same Site policy.
     11
     12        "New loads" initiated by a the client (Safari) either by API or a human either explicitly
     13        typing a URL in the address bar or Command + clicking a hyperlink to open it in a new window/tab
     14        are always considered Same Site. This is by definition from the spec. [1] as we aren't navigating
     15        from an existing page. (Command + click should be thought of as a convenience to the user from
     16        having to copy the hyperlink's URL, create a new window, and paste the URL into the address bar).
     17        Currently the frame loader marks a request as a top-level navigation if and only if the request
     18        does not have a pre-computed Same Site policy. However, "New loads" have a pre-computed Same Site
     19        policy. So, these loads would never be marked as a top-level navigation by the frame loading code.
     20        Therefore, if the "new load" turned out to be a cross-site redirect then WebKit would incorrectly
     21        tell the networking stack that the load was a cross-site, non-top-level navigation, and per the
     22        Same Site spec [2], the networking stack would not send Same Site Lax cookies. Instead,
     23        WebKit should unconditionally ensure that requests are marked as a top-level navigation, if applicable.
     24
     25        [1] See Note for (1) in  <https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-02#section-5.2>
     26        [2] <https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-02#section-5.3.7.1>
     27
     28        Test: http/tests/cookies/same-site/user-load-cross-site-redirect.php
     29
     30        * loader/FrameLoader.cpp:
     31        (WebCore::FrameLoader::addExtraFieldsToRequest): Unconditionally update the request's top-
     32        level navigation bit.
     33        * platform/network/ResourceRequestBase.cpp:
     34        (WebCore::ResourceRequestBase::setAsIsolatedCopy): Unconditionally copy a request's top-
     35        level navigation bit.
     36
    1372019-04-03  Myles C. Maxfield  <mmaxfield@apple.com>
    238
  • releases/WebKitGTK/webkit-2.24/Source/WebCore/loader/FrameLoader.cpp

    r241808 r245441  
    28682868    // Don't set the cookie policy URL if it's already been set.
    28692869    // But make sure to set it on all requests regardless of protocol, as it has significance beyond the cookie policy (<rdar://problem/6616664>).
     2870    bool isMainFrameMainResource = isMainResource && m_frame.isMainFrame();
    28702871    if (request.firstPartyForCookies().isEmpty()) {
    2871         if (isMainResource && m_frame.isMainFrame())
     2872        if (isMainFrameMainResource)
    28722873            request.setFirstPartyForCookies(request.url());
    28732874        else if (Document* document = m_frame.document())
     
    28862887        }
    28872888        addSameSiteInfoToRequestIfNeeded(request, initiator);
    2888         request.setIsTopSite(isMainResource && m_frame.isMainFrame());
    2889     }
     2889    }
     2890    request.setIsTopSite(isMainFrameMainResource);
    28902891
    28912892    Page* page = frame().page();
  • releases/WebKitGTK/webkit-2.24/Source/WebCore/platform/network/ResourceRequestBase.cpp

    r238771 r245441  
    7171        setInspectorInitiatorNodeIdentifier(*inspectorInitiatorNodeIdentifier);
    7272
    73     if (!other.isSameSiteUnspecified()) {
     73    if (!other.isSameSiteUnspecified())
    7474        setIsSameSite(other.isSameSite());
    75         setIsTopSite(other.isTopSite());
    76     }
     75    setIsTopSite(other.isTopSite());
    7776
    7877    updateResourceRequest();
Note: See TracChangeset for help on using the changeset viewer.