Diff
Modified: trunk/LayoutTests/ChangeLog (228238 => 228239)
--- trunk/LayoutTests/ChangeLog 2018-02-07 19:52:45 UTC (rev 228238)
+++ trunk/LayoutTests/ChangeLog 2018-02-07 20:09:51 UTC (rev 228239)
@@ -1,3 +1,31 @@
+2018-02-07 John Wilander <[email protected]>
+
+ Restrict Referer to just the origin for third parties in private mode and third parties ITP blocks cookies for in regular mode
+ https://bugs.webkit.org/show_bug.cgi?id=182559
+ <rdar://problem/36990337>
+
+ Reviewed by Andy Estes.
+
+ * TestExpectations:
+ New tests marked as [ Skip ]. The change only applies to iOS and Mac.
+ * http/tests/resourceLoadStatistics/resources/echo-referrer.php: Added.
+ * http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects-expected.txt: Added.
+ * http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html: Added.
+ * http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests-expected.txt: Added.
+ * http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html: Added.
+ * http/tests/security/resources/echo-referrer.php: Added.
+ * http/tests/security/resources/redirect.php: Added.
+ * http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode-expected.txt: Added.
+ * http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html: Added.
+ * http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode-expected.txt: Added.
+ * http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html: Added.
+ * platform/ios/TestExpectations:
+ New tests marked as [ Pass ].
+ * platform/mac-wk2/TestExpectations:
+ New tests marked as [ Pass ].
+ * platform/wk2/TestExpectations:
+ New tests marked as [ Skip ].
+
2018-02-07 Matt Lewis <[email protected]>
Adjusted test expectations for storage/indexeddb/modern/idbtransaction-objectstore-failures.html.
Modified: trunk/LayoutTests/TestExpectations (228238 => 228239)
--- trunk/LayoutTests/TestExpectations 2018-02-07 19:52:45 UTC (rev 228238)
+++ trunk/LayoutTests/TestExpectations 2018-02-07 20:09:51 UTC (rev 228239)
@@ -128,6 +128,8 @@
fast/media/mq-monochrome-live-update.html [ Skip ]
fast/media/mq-prefers-reduced-motion-live-update.html [ Skip ]
http/tests/loading/basic-auth-remove-credentials.html [ Skip ]
+http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Skip ]
+http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html [ Skip ]
# ApplePay is only available on iOS (greater than iOS 10) and macOS (greater than macOS 10.12) and only for WebKit2.
http/tests/ssl/applepay/ [ Skip ]
Added: trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/echo-referrer.php (0 => 228239)
--- trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/echo-referrer.php (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/echo-referrer.php 2018-02-07 20:09:51 UTC (rev 228239)
@@ -0,0 +1,4 @@
+<?php
+header("Access-Control-Allow-Origin: http://127.0.0.1:8000");
+echo $_SERVER['HTTP_REFERER'];
+?>
\ No newline at end of file
Added: trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects-expected.txt (0 => 228239)
--- trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects-expected.txt 2018-02-07 20:09:51 UTC (rev 228239)
@@ -0,0 +1,15 @@
+Tests that only the origin is sent as referrer in redirects to prevalent resources without user interaction.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS referrer is "http://127.0.0.1:8000/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+http://127.0.0.1:8000/
Added: trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html (0 => 228239)
--- trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html 2018-02-07 20:09:51 UTC (rev 228239)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+<script>
+ description("Tests that only the origin is sent as referrer in redirects to prevalent resources without user interaction.");
+ jsTestIsAsync = true;
+ testRunner.dumpChildFramesAsText();
+
+ function setEnableFeature(enable) {
+ if (!enable)
+ testRunner.statisticsResetToConsistentState();
+ internals.setResourceLoadStatisticsEnabled(enable);
+ testRunner.setCookieStoragePartitioningEnabled(enable);
+ }
+
+ function openIframe(url, onLoadHandler) {
+ const element = document.createElement("iframe");
+ element.src = ""
+ if (onLoadHandler) {
+ element._onload_ = onLoadHandler;
+ }
+ document.body.appendChild(element);
+ }
+
+ setEnableFeature(true);
+ if (testRunner.isStatisticsPrevalentResource("http://localhost"))
+ testFailed("Localhost was classified as prevalent resource before the test started.");
+
+ var referrer;
+ fetch("resources/echo-referrer.php").then(function(response) {
+ return response.text();
+ }).then(function(data) {
+ referrer = data;
+ shouldBeEqualToString("referrer", "http://127.0.0.1:8000/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html");
+
+ testRunner.setStatisticsPrevalentResource("http://localhost", true);
+ if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
+ testFailed("Host did not get set as prevalent resource.");
+
+ testRunner.statisticsUpdateCookiePartitioning(function() {
+ openIframe("resources/redirect.php?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php", finishJSTest);
+ });
+
+ }).catch(function(error) {
+ console.log(error.message);
+ finishJSTest();
+ });
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests-expected.txt (0 => 228239)
--- trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests-expected.txt 2018-02-07 20:09:51 UTC (rev 228239)
@@ -0,0 +1,16 @@
+Tests that only the origin is sent as referrer for prevalent resources without user interaction.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS referrer is "http://127.0.0.1:8000/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html"
+PASS referrer is "http://127.0.0.1:8000/"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+http://127.0.0.1:8000/
Added: trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html (0 => 228239)
--- trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html 2018-02-07 20:09:51 UTC (rev 228239)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+<script>
+ description("Tests that only the origin is sent as referrer for prevalent resources without user interaction.");
+ jsTestIsAsync = true;
+ testRunner.dumpChildFramesAsText();
+
+ function setEnableFeature(enable) {
+ if (!enable)
+ testRunner.statisticsResetToConsistentState();
+ internals.setResourceLoadStatisticsEnabled(enable);
+ testRunner.setCookieStoragePartitioningEnabled(enable);
+ }
+
+ function openIframe(url, onLoadHandler) {
+ const element = document.createElement("iframe");
+ element.src = ""
+ if (onLoadHandler) {
+ element._onload_ = onLoadHandler;
+ }
+ document.body.appendChild(element);
+ }
+
+ setEnableFeature(true);
+ if (testRunner.isStatisticsPrevalentResource("http://localhost"))
+ testFailed("Localhost was classified as prevalent resource before the test started.");
+
+ var referrer;
+ fetch("resources/echo-referrer.php").then(function(response) {
+ return response.text();
+ }).then(function(data) {
+ referrer = data;
+ shouldBeEqualToString("referrer", "http://127.0.0.1:8000/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html");
+
+ testRunner.setStatisticsPrevalentResource("http://localhost", true);
+ if (!testRunner.isStatisticsPrevalentResource("http://localhost"))
+ testFailed("Host did not get set as prevalent resource.");
+
+ testRunner.statisticsUpdateCookiePartitioning(function() {
+ fetch("http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php").then(function(response) {
+ return response.text();
+ }).then(function(data) {
+ referrer = data;
+ shouldBeEqualToString("referrer", "http://127.0.0.1:8000/");
+
+ openIframe("resources/redirect.php?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/echo-referrer.php", finishJSTest);
+
+ }).catch(function(error) {
+ console.log(error.message);
+ finishJSTest();
+ });
+ });
+
+ }).catch(function(error) {
+ console.log(error.message);
+ finishJSTest();
+ });
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/security/resources/echo-referrer.php (0 => 228239)
--- trunk/LayoutTests/http/tests/security/resources/echo-referrer.php (rev 0)
+++ trunk/LayoutTests/http/tests/security/resources/echo-referrer.php 2018-02-07 20:09:51 UTC (rev 228239)
@@ -0,0 +1,4 @@
+<?php
+header("Access-Control-Allow-Origin: http://127.0.0.1:8000");
+echo $_SERVER['HTTP_REFERER'];
+?>
\ No newline at end of file
Added: trunk/LayoutTests/http/tests/security/resources/redirect.php (0 => 228239)
--- trunk/LayoutTests/http/tests/security/resources/redirect.php (rev 0)
+++ trunk/LayoutTests/http/tests/security/resources/redirect.php 2018-02-07 20:09:51 UTC (rev 228239)
@@ -0,0 +1,14 @@
+<?php
+$redirectURL = $_GET["redirectTo"];
+if (isset($_GET["name2"])) {
+ $redirectURL = $redirectURL . "&name2=" . $_GET["name2"];
+}
+if (isset($_GET["name3"])) {
+ $redirectURL = $redirectURL . "&name3=" . $_GET["name3"];
+}
+if (isset($_GET["message"])) {
+ $redirectURL = $redirectURL . "&message=" . $_GET["message"];
+}
+header('Location: ' . $redirectURL);
+die();
+?>
Added: trunk/LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode-expected.txt (0 => 228239)
--- trunk/LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode-expected.txt 2018-02-07 20:09:51 UTC (rev 228239)
@@ -0,0 +1,15 @@
+Tests that only the origin is sent as referrer for third-party redirects in private browsing mode.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS referrer is "http://127.0.0.1:8000/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+http://127.0.0.1:8000/
Added: trunk/LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html (0 => 228239)
--- trunk/LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html (rev 0)
+++ trunk/LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html 2018-02-07 20:09:51 UTC (rev 228239)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+<script>
+ description("Tests that only the origin is sent as referrer for third-party redirects in private browsing mode.");
+ jsTestIsAsync = true;
+
+ testRunner.setPrivateBrowsingEnabled(true);
+ testRunner.dumpChildFramesAsText();
+
+ function openIframe(url, onLoadHandler) {
+ const element = document.createElement("iframe");
+ element.src = ""
+ if (onLoadHandler) {
+ element._onload_ = onLoadHandler;
+ }
+ document.body.appendChild(element);
+ }
+
+ var referrer;
+ fetch("resources/echo-referrer.php").then(function(response) {
+ return response.text();
+ }).then(function(data) {
+ referrer = data;
+ shouldBeEqualToString("referrer", "http://127.0.0.1:8000/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html");
+
+ openIframe("resources/redirect.php?redirectTo=http://localhost:8000/security/resources/echo-referrer.php", finishJSTest);
+
+ }).catch(function(error) {
+ console.log(error.message);
+ finishJSTest();
+ });
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode-expected.txt (0 => 228239)
--- trunk/LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode-expected.txt 2018-02-07 20:09:51 UTC (rev 228239)
@@ -0,0 +1,16 @@
+Tests that only the origin is sent as referrer for third-party resources in private browsing mode.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS referrer is "http://127.0.0.1:8000/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html"
+PASS referrer is "http://127.0.0.1:8000/"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+http://127.0.0.1:8000/
Added: trunk/LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html (0 => 228239)
--- trunk/LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html (rev 0)
+++ trunk/LayoutTests/http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html 2018-02-07 20:09:51 UTC (rev 228239)
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+<script>
+ description("Tests that only the origin is sent as referrer for third-party resources in private browsing mode.");
+ jsTestIsAsync = true;
+
+ testRunner.setPrivateBrowsingEnabled(true);
+ testRunner.dumpChildFramesAsText();
+
+ function openIframe(url, onLoadHandler) {
+ const element = document.createElement("iframe");
+ element.src = ""
+ if (onLoadHandler) {
+ element._onload_ = onLoadHandler;
+ }
+ document.body.appendChild(element);
+ }
+
+ var referrer;
+ fetch("resources/echo-referrer.php").then(function(response) {
+ return response.text();
+ }).then(function(data) {
+ referrer = data;
+ shouldBeEqualToString("referrer", "http://127.0.0.1:8000/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html");
+
+ fetch("http://localhost:8000/security/resources/echo-referrer.php").then(function(response) {
+ return response.text();
+ }).then(function(data) {
+ referrer = data;
+ shouldBeEqualToString("referrer", "http://127.0.0.1:8000/");
+ openIframe("http://localhost:8000/security/resources/echo-referrer.php", finishJSTest);
+ }).catch(function(error) {
+ console.log(error.message);
+ finishJSTest();
+ });
+
+ }).catch(function(error) {
+ console.log(error.message);
+ finishJSTest();
+ });
+
+</script>
+</body>
+</html>
Modified: trunk/LayoutTests/platform/ios/TestExpectations (228238 => 228239)
--- trunk/LayoutTests/platform/ios/TestExpectations 2018-02-07 19:52:45 UTC (rev 228238)
+++ trunk/LayoutTests/platform/ios/TestExpectations 2018-02-07 20:09:51 UTC (rev 228239)
@@ -3020,7 +3020,13 @@
http/tests/resourceLoadStatistics/grandfathering.html [ Pass ]
http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html [ Pass ]
http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html [ Pass ]
+http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html [ Pass ]
+http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html [ Pass ]
+# Skipped in general expectations since they only work on iOS and Mac, WK2.
+http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Pass ]
+http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html [ Pass ]
+
webkit.org/b/175273 imported/w3c/web-platform-tests/html/browsers/windows/noreferrer-window-name.html [ Failure ]
webkit.org/b/175353 imported/w3c/web-platform-tests/css/css-ui/outline-004.html [ ImageOnlyFailure ]
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (228238 => 228239)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2018-02-07 19:52:45 UTC (rev 228238)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2018-02-07 20:09:51 UTC (rev 228239)
@@ -810,7 +810,13 @@
[ HighSierra+ ] http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html [ Pass ]
[ HighSierra+ ] http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store-one-hour.html [ Pass ]
[ HighSierra+ ] http/tests/resourceLoadStatistics/grandfathering.html [ Pass ]
+[ HighSierra+ ] http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html [ Pass ]
+[ HighSierra+ ] http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html [ Pass ]
+# Skipped in general expectations since they only work on iOS and Mac, WK2.
+http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html [ Pass ]
+http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html [ Pass ]
+
# <rdar://problem/33555759>
webkit.org/b/177616 [ HighSierra+ ] http/tests/media/video-buffered-range-contains-currentTime.html [ Pass Timeout ]
Modified: trunk/LayoutTests/platform/wk2/TestExpectations (228238 => 228239)
--- trunk/LayoutTests/platform/wk2/TestExpectations 2018-02-07 19:52:45 UTC (rev 228238)
+++ trunk/LayoutTests/platform/wk2/TestExpectations 2018-02-07 20:09:51 UTC (rev 228239)
@@ -705,6 +705,8 @@
http/tests/resourceLoadStatistics/add-blocking-to-redirect.html [ Skip ]
http/tests/resourceLoadStatistics/remove-partitioning-in-redirect.html [ Skip ]
http/tests/resourceLoadStatistics/remove-blocking-in-redirect.html [ Skip ]
+http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html [ Skip ]
+http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html [ Skip ]
### END OF (5) Progressions, expected successes that are expected failures in WebKit1.
########################################
Modified: trunk/Source/WebCore/ChangeLog (228238 => 228239)
--- trunk/Source/WebCore/ChangeLog 2018-02-07 19:52:45 UTC (rev 228238)
+++ trunk/Source/WebCore/ChangeLog 2018-02-07 20:09:51 UTC (rev 228239)
@@ -1,3 +1,30 @@
+2018-02-07 John Wilander <[email protected]>
+
+ Restrict Referer to just the origin for third parties in private mode and third parties ITP blocks cookies for in regular mode
+ https://bugs.webkit.org/show_bug.cgi?id=182559
+ <rdar://problem/36990337>
+
+ Reviewed by Andy Estes.
+
+ Tests: http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-redirects.html
+ http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-prevalent-subresource-requests.html
+ http/tests/security/strip-referrer-to-origin-for-third-party-redirects-in-private-mode.html
+ http/tests/security/strip-referrer-to-origin-for-third-party-requests-in-private-mode.html
+
+ * page/SecurityPolicy.cpp:
+ (WebCore::SecurityPolicy::referrerToOriginString):
+ Now exposed within WebCore. This is to make sure we create a proper referrer
+ string in WebCore::ResourceRequestBase::setExistingHTTPReferrerToOriginString().
+ (WebCore::referrerToOriginString): Deleted.
+ Used to be internal.
+ * page/SecurityPolicy.h:
+ * platform/network/ResourceRequestBase.cpp:
+ (WebCore::ResourceRequestBase::setExistingHTTPReferrerToOriginString):
+ New, exported function used in WebKit. Note that this function does not
+ set the referrer if the request has none since before.
+ * platform/network/ResourceRequestBase.h:
+
+
2018-02-07 Zalan Bujtas <[email protected]>
[RenderTreeBuilder] Remove RenderElement::destroyLeftoverChildren.
Modified: trunk/Source/WebCore/page/SecurityPolicy.cpp (228238 => 228239)
--- trunk/Source/WebCore/page/SecurityPolicy.cpp 2018-02-07 19:52:45 UTC (rev 228238)
+++ trunk/Source/WebCore/page/SecurityPolicy.cpp 2018-02-07 20:09:51 UTC (rev 228239)
@@ -67,7 +67,7 @@
return !URLIsSecureURL;
}
-static String referrerToOriginString(const String& referrer)
+String SecurityPolicy::referrerToOriginString(const String& referrer)
{
String originString = SecurityOrigin::createFromString(referrer)->toString();
if (originString == "null")
Modified: trunk/Source/WebCore/page/SecurityPolicy.h (228238 => 228239)
--- trunk/Source/WebCore/page/SecurityPolicy.h 2018-02-07 19:52:45 UTC (rev 228238)
+++ trunk/Source/WebCore/page/SecurityPolicy.h 2018-02-07 20:09:51 UTC (rev 228239)
@@ -42,6 +42,10 @@
// If you intend to send a referrer header, you should use generateReferrerHeader instead.
WEBCORE_EXPORT static bool shouldHideReferrer(const URL&, const String& referrer);
+ // Returns the referrer's security origin plus a / to make it a canonical URL
+ // and thus useable as referrer.
+ static String referrerToOriginString(const String& referrer);
+
// Returns the referrer modified according to the referrer policy for a
// navigation to a given URL. If the referrer returned is empty, the
// referrer header should be omitted.
Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp (228238 => 228239)
--- trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp 2018-02-07 19:52:45 UTC (rev 228238)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp 2018-02-07 20:09:51 UTC (rev 228239)
@@ -29,6 +29,7 @@
#include "HTTPHeaderNames.h"
#include "PublicSuffix.h"
#include "ResourceRequest.h"
+#include "SecurityPolicy.h"
#include <wtf/PointerComparison.h>
namespace WebCore {
@@ -324,6 +325,14 @@
setHTTPHeaderField(HTTPHeaderName::Referer, httpReferrer);
}
+void ResourceRequestBase::setExistingHTTPReferrerToOriginString()
+{
+ if (!hasHTTPReferrer())
+ return;
+
+ setHTTPHeaderField(HTTPHeaderName::Referer, SecurityPolicy::referrerToOriginString(httpReferrer()));
+}
+
void ResourceRequestBase::clearHTTPReferrer()
{
updateResourceRequest();
Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.h (228238 => 228239)
--- trunk/Source/WebCore/platform/network/ResourceRequestBase.h 2018-02-07 19:52:45 UTC (rev 228238)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.h 2018-02-07 20:09:51 UTC (rev 228239)
@@ -110,6 +110,7 @@
WEBCORE_EXPORT String httpReferrer() const;
bool hasHTTPReferrer() const;
WEBCORE_EXPORT void setHTTPReferrer(const String&);
+ WEBCORE_EXPORT void setExistingHTTPReferrerToOriginString();
WEBCORE_EXPORT void clearHTTPReferrer();
String httpOrigin() const;
Modified: trunk/Source/WebKit/ChangeLog (228238 => 228239)
--- trunk/Source/WebKit/ChangeLog 2018-02-07 19:52:45 UTC (rev 228238)
+++ trunk/Source/WebKit/ChangeLog 2018-02-07 20:09:51 UTC (rev 228239)
@@ -1,3 +1,25 @@
+2018-02-07 John Wilander <[email protected]>
+
+ Restrict Referer to just the origin for third parties in private mode and third parties ITP blocks cookies for in regular mode
+ https://bugs.webkit.org/show_bug.cgi?id=182559
+ <rdar://problem/36990337>
+
+ Reviewed by Andy Estes.
+
+ * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
+ * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+ (WebKit::NetworkDataTaskCocoa::isThirdPartyRequest):
+ New convenience function. Checks whether the resource shares
+ partition with the first party.
+ (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
+ Now strips the referrer to just the origin for:
+ 1. All third party requests in private mode.
+ 2. Third party requests to domains that ITP blocks cookies for.
+ (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):
+ Now strips the referrer in redirects to just the origin for:
+ 1. All third party requests in private mode.
+ 2. Third party requests to domains that ITP blocks cookies for.
+
2018-02-07 Daniel Bates <[email protected]>
Log error when authentication challenge is blocked due to an insecure request
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h (228238 => 228239)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h 2018-02-07 19:52:45 UTC (rev 228238)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h 2018-02-07 20:09:51 UTC (rev 228239)
@@ -82,6 +82,7 @@
void applyCookieBlockingPolicy(bool shouldBlock);
void applyCookiePartitioningPolicy(const String& requiredStoragePartition, const String& currentStoragePartition);
#endif
+ bool isThirdPartyRequest(const WebCore::ResourceRequest&);
RefPtr<SandboxExtension> m_sandboxExtension;
RetainPtr<NSURLSessionDataTask> m_task;
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (228238 => 228239)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm 2018-02-07 19:52:45 UTC (rev 228238)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm 2018-02-07 20:09:51 UTC (rev 228239)
@@ -141,6 +141,11 @@
}
#endif
+bool NetworkDataTaskCocoa::isThirdPartyRequest(const WebCore::ResourceRequest& request)
+{
+ return request.partitionName(request.url().host()) != request.partitionName(request.firstPartyForCookies().host());
+}
+
NetworkDataTaskCocoa::NetworkDataTaskCocoa(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& requestWithCredentials, uint64_t frameID, uint64_t pageID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly shouldPreconnectOnly)
: NetworkDataTask(session, client, requestWithCredentials, storedCredentialsPolicy, shouldClearReferrerOnHTTPSToHTTPRedirect)
, m_frameID(frameID)
@@ -171,7 +176,14 @@
applyBasicAuthorizationHeader(request, m_initialCredential);
}
#endif
-
+
+ bool shouldBlockCookies = false;
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+ shouldBlockCookies = session.networkStorageSession().shouldBlockCookies(request);
+#endif
+ if (shouldBlockCookies || (m_session->sessionID().isEphemeral() && isThirdPartyRequest(request)))
+ request.setExistingHTTPReferrerToOriginString();
+
NSURLRequest *nsRequest = request.nsURLRequest(WebCore::UpdateHTTPBody);
applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(nsRequest, shouldContentSniff == WebCore::SniffContent && !url.isLocalFile(), shouldContentEncodingSniff == WebCore::ContentEncodingSniffingPolicy::Sniff);
@@ -197,7 +209,7 @@
}
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
- if (auto shouldBlockCookies = session.networkStorageSession().shouldBlockCookies(request)) {
+ if (shouldBlockCookies) {
#if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
if (NetworkProcess::singleton().shouldLogCookieInformation())
RELEASE_LOG_IF(m_session->sessionID().isAlwaysOnLoggingAllowed(), Network, "%p - NetworkDataTaskCocoa::logCookieInformation: pageID = %llu, frameID = %llu, taskID = %lu: Blocking cookies for URL %s", this, pageID, frameID, (unsigned long)[m_task taskIdentifier], nsRequest.URL.absoluteString.UTF8String);
@@ -312,10 +324,18 @@
}
#endif
}
-
+
+ bool shouldBlockCookies = false;
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
- auto shouldBlockCookies = m_session->networkStorageSession().shouldBlockCookies(request);
+ shouldBlockCookies = m_session->networkStorageSession().shouldBlockCookies(request);
LOG(NetworkSession, "%llu %s cookies for redirect URL %s", [m_task taskIdentifier], (shouldBlockCookies ? "Blocking" : "Not blocking"), request.url().string().utf8().data());
+#endif
+
+ if (shouldBlockCookies || (m_session->sessionID().isEphemeral() && isThirdPartyRequest(request)))
+ request.setExistingHTTPReferrerToOriginString();
+
+#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+ // Always apply the policy since blocking may need to be turned on or off in a redirect.
applyCookieBlockingPolicy(shouldBlockCookies);
if (!shouldBlockCookies) {