Changeset 239393 in webkit
- Timestamp:
- Dec 19, 2018, 2:05:29 PM (8 years ago)
- Location:
- branches/safari-606-branch
- Files:
-
- 2 added
- 11 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js-expected.txt (added)
-
LayoutTests/http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html (added)
-
LayoutTests/http/tests/cookies/resources/cookie-utilities.js (modified) (1 diff)
-
LayoutTests/platform/ios/TestExpectations (modified) (1 diff)
-
LayoutTests/platform/mac-wk2/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h (modified) (1 diff)
-
Source/WebCore/platform/network/mac/CookieJarMac.mm (modified) (2 diffs)
-
Source/WebCore/testing/Internals.cpp (modified) (2 diffs)
-
Source/WebCore/testing/Internals.h (modified) (2 diffs)
-
Source/WebCore/testing/Internals.idl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-606-branch/LayoutTests/ChangeLog
r239242 r239393 1 2018-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 1 24 2018-12-14 Alan Coon <alancoon@apple.com> 2 25 -
branches/safari-606-branch/LayoutTests/TestExpectations
r236214 r239393 151 151 http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Skip ] 152 152 http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html [ Skip ] 153 http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html [ Skip ] 153 154 154 155 # 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 238 238 return promise; 239 239 } 240 241 function 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 2823 2823 fast/events/webkit-media-key-events-constructor.html [ Failure ] 2824 2824 2825 http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html [ Pass ] 2825 2826 webkit.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 ] 2826 2827 -
branches/safari-606-branch/LayoutTests/platform/mac-wk2/TestExpectations
r238007 r239393 770 770 771 771 webkit.org/b/175341 accessibility/mac/select-element-selection-with-optgroups.html [ Pass Failure ] 772 http/tests/cookies/capped-lifetime-for-cookie-set-in-js.html [ Pass ] 772 773 773 774 webkit.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 1 2018-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 1 50 2018-12-14 Alan Coon <alancoon@apple.com> 2 51 -
branches/safari-606-branch/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h
r232642 r239393 303 303 size_t CGDisplayModeGetPixelsHigh(CGDisplayModeRef); 304 304 305 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 306 CGError CGSSetDenyWindowServerConnections(bool); 307 308 typedef int32_t CGSDisplayID; 309 CGSDisplayID CGSMainDisplayID(void); 310 311 #endif // ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 312 305 313 #endif 306 314 -
branches/safari-606-branch/Source/WebCore/platform/network/mac/CookieJarMac.mm
r230948 r239393 152 152 RetainPtr<NSMutableArray> filteredCookies = adoptNS([[NSMutableArray alloc] initWithCapacity:count]); 153 153 154 const NSTimeInterval secondsPerWeek = 7 * 24 * 60 * 60; 154 155 for (NSUInteger i = 0; i < count; ++i) { 155 156 NSHTTPCookie *cookie = (NSHTTPCookie *)[unfilteredCookies objectAtIndex:i]; … … 164 165 if ([cookie isHTTPOnly]) 165 166 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 } 166 177 167 178 [filteredCookies.get() addObject:cookie]; -
branches/safari-606-branch/Source/WebCore/testing/Internals.cpp
r238916 r239393 48 48 #include "ClientOrigin.h" 49 49 #include "ComposedTreeIterator.h" 50 #include "CookieJar.h" 50 51 #include "Cursor.h" 51 52 #include "DOMRect.h" … … 4698 4699 } 4699 4700 4701 auto 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 4700 4714 } // namespace WebCore -
branches/safari-606-branch/Source/WebCore/testing/Internals.h
r238916 r239393 29 29 #include "CSSComputedStyleDeclaration.h" 30 30 #include "ContextDestructionObserver.h" 31 #include "Cookie.h" 31 32 #include "ExceptionOr.h" 32 33 #include "JSDOMPromiseDeferred.h" … … 728 729 void setAlwaysAllowLocalWebarchive() const; 729 730 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 730 763 private: 731 764 explicit Internals(Document&); -
branches/safari-606-branch/Source/WebCore/testing/Internals.idl
r238916 r239393 125 125 [ 126 126 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, 127 142 NoInterfaceObject, 128 143 ] interface Internals { … … 667 682 668 683 void setAlwaysAllowLocalWebarchive(); 669 }; 684 685 sequence<CookieData> getCookies(); 686 };
Note:
See TracChangeset
for help on using the changeset viewer.