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

Changeset 239393 in webkit


Ignore:
Timestamp:
Dec 19, 2018, 2:05:29 PM (8 years ago)
Author:
Kocsen Chung
Message:

Apply patch. rdar://problem/46848447

Location:
branches/safari-606-branch
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-606-branch/LayoutTests/ChangeLog

    r239242 r239393  
     12018-12-19  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Apply patch. rdar://problem/46848447
     4
     5    2018-12-19  John Wilander  <wilander@apple.com>
     6
     7            Cap lifetime of persistent cookies created client-side through document.cookie
     8            https://bugs.webkit.org/show_bug.cgi?id=189933
     9            <rdar://problem/44741888>
     10
     11            Reviewed by Chris Dumez.
     12
     13            * TestExpectations:
     14                Skipped the new test by default since the behavior change is for
     15                Cocoa platforms only.
     16            * http/tests/cookies/capped-lifetime-for-cookie-set-in-js-expected.txt: Added.
     17            * http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html: Added.
     18            * http/tests/cookies/resources/cookie-utilities.js:
     19            * platform/ios/TestExpectations:
     20                Marked the new test as [ Pass ].
     21            * platform/mac-wk2/TestExpectations:
     22                Marked the new test as [ Pass ].
     23
    1242018-12-14  Alan Coon  <alancoon@apple.com>
    225
  • branches/safari-606-branch/LayoutTests/TestExpectations

    r236214 r239393  
    151151http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Skip ]
    152152http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html [ Skip ]
     153http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html [ Skip ]
    153154
    154155# ApplePay is only available on iOS (greater than iOS 10) and macOS (greater than macOS 10.12) and only for WebKit2.
  • branches/safari-606-branch/LayoutTests/http/tests/cookies/resources/cookie-utilities.js

    r233830 r239393  
    238238    return promise;
    239239}
     240
     241function createExpiresDateFromMaxAge(maxAgeInSeconds)
     242{
     243    let date = new Date();
     244    date.setTime(date.getTime() + (maxAgeInSeconds * 1000));
     245    return date.toUTCString();
     246}
  • branches/safari-606-branch/LayoutTests/platform/ios/TestExpectations

    r235726 r239393  
    28232823fast/events/webkit-media-key-events-constructor.html [ Failure ]
    28242824
     2825http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html [ Pass ]
    28252826webkit.org/b/161143 imported/w3c/web-platform-tests/html/browsers/browsing-the-web/history-traversal/persisted-user-state-restoration/scroll-restoration-fragment-scrolling-samedoc.html [ Pass Failure ]
    28262827
  • branches/safari-606-branch/LayoutTests/platform/mac-wk2/TestExpectations

    r238007 r239393  
    770770
    771771webkit.org/b/175341 accessibility/mac/select-element-selection-with-optgroups.html [ Pass Failure ]
     772http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html [ Pass ]
    772773
    773774webkit.org/b/172044 [ Debug ] imported/w3c/web-platform-tests/IndexedDB/open-request-queue.html [ Pass Timeout ]
  • branches/safari-606-branch/Source/WebCore/ChangeLog

    r239242 r239393  
     12018-12-19  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Apply patch. rdar://problem/46848447
     4
     5    2018-12-19  John Wilander  <wilander@apple.com>
     6
     7            Cap lifetime of persistent cookies created client-side through document.cookie
     8            https://bugs.webkit.org/show_bug.cgi?id=189933
     9            <rdar://problem/44741888>
     10
     11            Reviewed by Chris Dumez.
     12
     13            Test: http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html
     14
     15            As pointed out in https://github.com/mikewest/http-state-tokens:
     16
     17            1) Cookies are available to JavaScript by default via document.cookie, which
     18            enables a smooth upgrade from one-time XSS to theft of persistent credentials
     19            and also makes cookies available to Spectre-like attacks on memory.
     20
     21            2) Though the HttpOnly attribute was introduced well over a decade ago, only
     22            ~8.31% of Set-Cookie operations use it today (stats from Chrome). We need
     23            developer incentives to put proper protections in place.
     24
     25            3) The median (uncompressed) Cookie request header is 409 bytes, while the 90th
     26            percentile is 1,589 bytes, the 95th 2,549 bytes, the 99th 4,601 bytes, and
     27            ~0.1% of Cookie headers are over 10kB (stats from Chrome). This is bad for load
     28            performance.
     29
     30            In addition to this, third-party scripts running in first-party contexts can
     31            read user data through document.cookie and even store cross-site tracking data
     32            in them.
     33
     34            Authentication cookies should be HttpOnly and thus not be affected by
     35            restrictions to document.cookie. Cookies that persist for a long time should
     36            be Secure, HttpOnly, and SameSite to provide good security and privacy.
     37
     38            By capping the lifetime of persistent cookies set through document.cookie we
     39            embark on a journey towards better cookie management on the web.
     40
     41            * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
     42            (WebCore::filterCookies):
     43                Now caps the life time of persistent cookies to one week (seven days).
     44            * testing/Internals.cpp:
     45            (WebCore::Internals::getCookies const):
     46                New test function to get to cookie meta data such as expiry.
     47            * testing/Internals.h:
     48            * testing/Internals.idl:
     49
    1502018-12-14  Alan Coon  <alancoon@apple.com>
    251
  • branches/safari-606-branch/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h

    r232642 r239393  
    303303size_t CGDisplayModeGetPixelsHigh(CGDisplayModeRef);
    304304
     305#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
     306CGError CGSSetDenyWindowServerConnections(bool);
     307
     308typedef int32_t CGSDisplayID;
     309CGSDisplayID CGSMainDisplayID(void);
     310
     311#endif // ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
     312
    305313#endif
    306314
  • branches/safari-606-branch/Source/WebCore/platform/network/mac/CookieJarMac.mm

    r230948 r239393  
    152152    RetainPtr<NSMutableArray> filteredCookies = adoptNS([[NSMutableArray alloc] initWithCapacity:count]);
    153153
     154    const NSTimeInterval secondsPerWeek = 7 * 24 * 60 * 60;
    154155    for (NSUInteger i = 0; i < count; ++i) {
    155156        NSHTTPCookie *cookie = (NSHTTPCookie *)[unfilteredCookies objectAtIndex:i];
    … …  
    164165        if ([cookie isHTTPOnly])
    165166            continue;
     167
     168        // Cap lifetime of persistent, client-side cookies to a week.
     169        if (![cookie isSessionOnly]) {
     170            if (!cookie.expiresDate || cookie.expiresDate.timeIntervalSinceNow > secondsPerWeek) {
     171                RetainPtr<NSMutableDictionary<NSHTTPCookiePropertyKey, id>> properties = adoptNS([[cookie properties] mutableCopy]);
     172                RetainPtr<NSDate> dateInAWeek = adoptNS([[NSDate alloc] initWithTimeIntervalSinceNow:secondsPerWeek]);
     173                [properties setObject:dateInAWeek.get() forKey:NSHTTPCookieExpires];
     174                cookie = [NSHTTPCookie cookieWithProperties:properties.get()];
     175            }
     176        }
    166177
    167178        [filteredCookies.get() addObject:cookie];
  • branches/safari-606-branch/Source/WebCore/testing/Internals.cpp

    r238916 r239393  
    4848#include "ClientOrigin.h"
    4949#include "ComposedTreeIterator.h"
     50#include "CookieJar.h"
    5051#include "Cursor.h"
    5152#include "DOMRect.h"
    … …  
    46984699}
    46994700
     4701auto Internals::getCookies() const -> Vector<CookieData>
     4702{
     4703    auto* document = contextDocument();
     4704    if (!document)
     4705        return { };
     4706
     4707    Vector<Cookie> cookies;
     4708    getRawCookies(*document, document->cookieURL(), cookies);
     4709    return WTF::map(cookies, [](auto& cookie) {
     4710        return CookieData { cookie };
     4711    });
     4712}
     4713
    47004714} // namespace WebCore
  • branches/safari-606-branch/Source/WebCore/testing/Internals.h

    r238916 r239393  
    2929#include "CSSComputedStyleDeclaration.h"
    3030#include "ContextDestructionObserver.h"
     31#include "Cookie.h"
    3132#include "ExceptionOr.h"
    3233#include "JSDOMPromiseDeferred.h"
    … …  
    728729    void setAlwaysAllowLocalWebarchive() const;
    729730
     731    struct CookieData {
     732        String name;
     733        String value;
     734        String domain;
     735        // Expiration dates are expressed as milliseconds since the UNIX epoch.
     736        double expires { 0 };
     737        bool isHttpOnly { false };
     738        bool isSecure { false };
     739        bool isSession { false };
     740        bool isSameSiteLax { false };
     741        bool isSameSiteStrict { false };
     742
     743        CookieData(Cookie cookie)
     744            : name(cookie.name)
     745            , value(cookie.value)
     746            , domain(cookie.domain)
     747            , expires(cookie.expires)
     748            , isHttpOnly(cookie.httpOnly)
     749            , isSecure(cookie.secure)
     750            , isSession(cookie.session)
     751            , isSameSiteLax(cookie.sameSite == Cookie::SameSitePolicy::Lax)
     752            , isSameSiteStrict(cookie.sameSite == Cookie::SameSitePolicy::Strict)
     753        {
     754            ASSERT(!(isSameSiteLax && isSameSiteStrict));
     755        }
     756
     757        CookieData()
     758        {
     759        }
     760    };
     761    Vector<CookieData> getCookies() const;
     762
    730763private:
    731764    explicit Internals(Document&);
  • branches/safari-606-branch/Source/WebCore/testing/Internals.idl

    r238916 r239393  
    125125[
    126126    ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
     127    JSGenerateToJSObject,
     128] dictionary CookieData {
     129    DOMString name;
     130    DOMString value;
     131    DOMString domain;
     132    double expires;
     133    boolean isHttpOnly;
     134    boolean isSecure;
     135    boolean isSession;
     136    boolean isSameSiteLax;
     137    boolean isSameSiteStrict;
     138};
     139
     140[
     141    ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
    127142    NoInterfaceObject,
    128143] interface Internals {
    … …  
    667682
    668683    void setAlwaysAllowLocalWebarchive();
    669 };
     684
     685    sequence<CookieData> getCookies();
     686};
Note: See TracChangeset for help on using the changeset viewer.