service worker fetch handler results in bad referrer
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Jan 2019 23:06:12 +0000 (23:06 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Jan 2019 23:06:12 +0000 (23:06 +0000)
commit0cd8d09f9b49d33c522f1890f9c827103cd7e480
tree31d8898f5a59cf66931e19675b701fa4d705955d
parent22afbc5f6a04154b0329308d4c557ab3e9ac4bdf
service worker fetch handler results in bad referrer
https://bugs.webkit.org/show_bug.cgi?id=188248
<rdar://problem/47050478>

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/service-worker/referrer-policy-header.https-expected.txt:

Source/WebCore:

Response sanitization was removing the ReferrerPolicy header from opaque redirect responses.
Reduce sanitization of opaque redirect responses to opaque responses and allow Location header.
Make sure referrer policy is updated for all load redirections, not only CORS loads.

Test: http/tests/security/referrer-policy-redirect-link-downgrade.html

* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::checkRedirectionCrossOriginAccessControl):
* platform/network/ResourceResponseBase.cpp:
(WebCore::isSafeCrossOriginResponseHeader):
(WebCore::ResourceResponseBase::sanitizeHTTPHeaderFieldsAccordingToTainting):

Source/WebKit:

NetworkDataTaskCocoa is sometimes updating the referrer on its own.
Instead of updating the referrer when sending the request to WebProcess for evaluation,
Update the referrer once the web process decides to follow the redirection.
This ensures that any referrer that the WebProcess will set will be updated by NetworkDataTaskCocoa.

* NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
(WebKit::NetworkDataTaskCocoa::restrictRequestReferrerToOriginIfNeeded):
(WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):

LayoutTests:

* http/tests/security/referrer-policy-redirect-link-downgrade-expected.txt: Added.
* http/tests/security/referrer-policy-redirect-link-downgrade.html: Added.
* http/tests/security/resources/referrer-policy-redirect-link-downgrade.html: Added.
* http/tests/security/resources/referrer-policy-redirect-link.html:
* platform/ios-wk2/TestExpectations: Skip referrer-policy-redirect-link-downgrade.html
as it is very similar to already skipped referrer-policy-redirect-link.html.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/security/referrer-policy-redirect-link-downgrade-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/security/referrer-policy-redirect-link-downgrade.html [new file with mode: 0644]
LayoutTests/http/tests/security/resources/referrer-policy-redirect-link-downgrade.html [new file with mode: 0644]
LayoutTests/http/tests/security/resources/referrer-policy-redirect-link.html
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/referrer-policy-header.https-expected.txt
LayoutTests/platform/ios-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/loader/SubresourceLoader.cpp
Source/WebCore/platform/network/ResourceResponseBase.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h
Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm