Changeset 281431 in webkit
- Timestamp:
- Aug 22, 2021, 7:24:23 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 9 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/tests/security/contentSecurityPolicy/report-blocked-uri-after-blocked-redirect-expected.txt (added)
-
LayoutTests/http/tests/security/contentSecurityPolicy/report-blocked-uri-after-blocked-redirect.html (added)
-
LayoutTests/http/tests/security/contentSecurityPolicy/report-blocked-uri-after-multiple-redirects-expected.txt (added)
-
LayoutTests/http/tests/security/contentSecurityPolicy/report-blocked-uri-after-multiple-redirects.html (added)
-
LayoutTests/platform/mac-wk1/http/tests/security/contentSecurityPolicy/report-blocked-uri-after-blocked-redirect-expected.txt (added)
-
LayoutTests/platform/mac-wk1/http/tests/security/contentSecurityPolicy/report-blocked-uri-after-multiple-redirects-expected.txt (added)
-
LayoutTests/platform/win/http/tests/security/contentSecurityPolicy/report-blocked-uri-after-blocked-redirect-expected.txt (added)
-
LayoutTests/platform/win/http/tests/security/contentSecurityPolicy/report-blocked-uri-after-multiple-redirects-expected.txt (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/loader/DocumentThreadableLoader.cpp (modified) (3 diffs)
-
Source/WebCore/loader/DocumentThreadableLoader.h (modified) (1 diff)
-
Source/WebCore/page/csp/ContentSecurityPolicy.cpp (modified) (4 diffs)
-
Source/WebCore/page/csp/ContentSecurityPolicy.h (modified) (2 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkLoadChecker.cpp (modified) (6 diffs)
-
Source/WebKit/NetworkProcess/NetworkLoadChecker.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r281429 r281431 1 2021-08-22 Kate Cheney <katherine_cheney@apple.com> 2 3 Report correct blocked URI in CSP violation report 4 https://bugs.webkit.org/show_bug.cgi?id=226316 5 <rdar://problem/78552912> 6 7 Reviewed by Alex Christensen. 8 9 * http/tests/security/contentSecurityPolicy/report-blocked-uri-after-blocked-redirect-expected.txt: Added. 10 * http/tests/security/contentSecurityPolicy/report-blocked-uri-after-blocked-redirect.html: Added. 11 * http/tests/security/contentSecurityPolicy/report-blocked-uri-after-multiple-redirects-expected.txt: Added. 12 * http/tests/security/contentSecurityPolicy/report-blocked-uri-after-multiple-redirects.html: Added. 13 * platform/mac-wk1/http/tests/security/contentSecurityPolicy/report-blocked-uri-after-multiple-redirects-expected.txt: Added. 14 * platform/mac-wk1/http/tests/security/contentSecurityPolicy/report-blocked-uri-after-blocked-redirect-expected.txt: Added. 15 * platform/win/http/tests/security/contentSecurityPolicy/report-blocked-uri-after-blocked-redirect-expected.txt: Added. 16 * platform/win/http/tests/security/contentSecurityPolicy/report-blocked-uri-after-multiple-redirects-expected.txt: Added. 17 WebKitLegacy and Win have different console logging. 18 1 19 2021-08-22 Yusuke Suzuki <ysuzuki@apple.com> 2 20 -
trunk/Source/WebCore/ChangeLog
r281426 r281431 1 2021-08-22 Kate Cheney <katherine_cheney@apple.com> 2 3 Report correct blocked URI in CSP violation report 4 https://bugs.webkit.org/show_bug.cgi?id=226316 5 <rdar://problem/78552912> 6 7 Reviewed by Alex Christensen. 8 9 Tests: http/tests/security/contentSecurityPolicy/report-blocked-uri-after-blocked-redirect.html 10 http/tests/security/contentSecurityPolicy/report-blocked-uri-after-multiple-redirects.html 11 12 Currently for a blocked redirection we report the blocked URI as the 13 target URL. This is not up to spec and we should actually report the 14 requested URL. 15 16 * loader/DocumentThreadableLoader.cpp: 17 (WebCore::DocumentThreadableLoader::redirectReceived): 18 (WebCore::DocumentThreadableLoader::isAllowedByContentSecurityPolicy): 19 * loader/DocumentThreadableLoader.h: 20 * page/csp/ContentSecurityPolicy.cpp: 21 (WebCore::ContentSecurityPolicy::allowConnectToSource const): 22 (WebCore::ContentSecurityPolicy::reportViolation const): 23 * page/csp/ContentSecurityPolicy.h: 24 1 25 2021-08-22 Myles C. Maxfield <mmaxfield@apple.com> 2 26 -
trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp
r281097 r281431 329 329 } 330 330 331 if (!isAllowedByContentSecurityPolicy(request.url(), redirectResponse.isNull() ? ContentSecurityPolicy::RedirectResponseReceived::No : ContentSecurityPolicy::RedirectResponseReceived::Yes )) {331 if (!isAllowedByContentSecurityPolicy(request.url(), redirectResponse.isNull() ? ContentSecurityPolicy::RedirectResponseReceived::No : ContentSecurityPolicy::RedirectResponseReceived::Yes, redirectResponse.url())) { 332 332 reportContentSecurityPolicyError(redirectResponse.url()); 333 333 clearResource(); … … 676 676 } 677 677 678 bool DocumentThreadableLoader::isAllowedByContentSecurityPolicy(const URL& url, ContentSecurityPolicy::RedirectResponseReceived redirectResponseReceived )678 bool DocumentThreadableLoader::isAllowedByContentSecurityPolicy(const URL& url, ContentSecurityPolicy::RedirectResponseReceived redirectResponseReceived, const URL& preRedirectURL) 679 679 { 680 680 switch (m_options.contentSecurityPolicyEnforcement) { … … 684 684 return contentSecurityPolicy().allowChildContextFromSource(url, redirectResponseReceived); 685 685 case ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective: 686 return contentSecurityPolicy().allowConnectToSource(url, redirectResponseReceived );686 return contentSecurityPolicy().allowConnectToSource(url, redirectResponseReceived, preRedirectURL); 687 687 case ContentSecurityPolicyEnforcement::EnforceScriptSrcDirective: 688 688 return contentSecurityPolicy().allowScriptFromSource(url, redirectResponseReceived); -
trunk/Source/WebCore/loader/DocumentThreadableLoader.h
r280953 r281431 104 104 void loadRequest(ResourceRequest&&, SecurityCheckPolicy); 105 105 bool isAllowedRedirect(const URL&); 106 bool isAllowedByContentSecurityPolicy(const URL&, ContentSecurityPolicy::RedirectResponseReceived );106 bool isAllowedByContentSecurityPolicy(const URL&, ContentSecurityPolicy::RedirectResponseReceived, const URL& preRedirectURL = URL()); 107 107 108 108 SecurityOrigin& securityOrigin() const; -
trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp
r280504 r281431 601 601 } 602 602 603 bool ContentSecurityPolicy::allowConnectToSource(const URL& url, RedirectResponseReceived redirectResponseReceived ) const603 bool ContentSecurityPolicy::allowConnectToSource(const URL& url, RedirectResponseReceived redirectResponseReceived, const URL& preRedirectURL) const 604 604 { 605 605 if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol().toStringWithoutCopying())) … … 609 609 auto handleViolatedDirective = [&] (const ContentSecurityPolicyDirective& violatedDirective) { 610 610 String consoleMessage = consoleMessageForViolation(ContentSecurityPolicyDirectiveNames::connectSrc, violatedDirective, url, "Refused to connect to"); 611 reportViolation(ContentSecurityPolicyDirectiveNames::connectSrc, violatedDirective, url, consoleMessage, sourceURL, sourcePosition );611 reportViolation(ContentSecurityPolicyDirectiveNames::connectSrc, violatedDirective, url, consoleMessage, sourceURL, sourcePosition, preRedirectURL); 612 612 }; 613 613 return allPoliciesAllow(WTFMove(handleViolatedDirective), &ContentSecurityPolicyDirectiveList::violatedDirectiveForConnectSource, url, redirectResponseReceived == RedirectResponseReceived::Yes); … … 660 660 } 661 661 662 void ContentSecurityPolicy::reportViolation(const String& effectiveViolatedDirective, const ContentSecurityPolicyDirective& violatedDirective, const URL& blockedURL, const String& consoleMessage, const String& sourceURL, const TextPosition& sourcePosition, JSC::JSGlobalObject* state) const663 { 664 return reportViolation(effectiveViolatedDirective, violatedDirective.text(), violatedDirective.directiveList(), blockedURL, consoleMessage, sourceURL, sourcePosition, state );665 } 666 667 void ContentSecurityPolicy::reportViolation(const String& effectiveViolatedDirective, const String& violatedDirective, const ContentSecurityPolicyDirectiveList& violatedDirectiveList, const URL& blockedURL, const String& consoleMessage, const String& sourceURL, const TextPosition& sourcePosition, JSC::JSGlobalObject* state ) const662 void ContentSecurityPolicy::reportViolation(const String& effectiveViolatedDirective, const ContentSecurityPolicyDirective& violatedDirective, const URL& blockedURL, const String& consoleMessage, const String& sourceURL, const TextPosition& sourcePosition, const URL& preRedirectURL, JSC::JSGlobalObject* state) const 663 { 664 return reportViolation(effectiveViolatedDirective, violatedDirective.text(), violatedDirective.directiveList(), blockedURL, consoleMessage, sourceURL, sourcePosition, state, preRedirectURL); 665 } 666 667 void ContentSecurityPolicy::reportViolation(const String& effectiveViolatedDirective, const String& violatedDirective, const ContentSecurityPolicyDirectiveList& violatedDirectiveList, const URL& blockedURL, const String& consoleMessage, const String& sourceURL, const TextPosition& sourcePosition, JSC::JSGlobalObject* state, const URL& preRedirectURL) const 668 668 { 669 669 logToConsole(consoleMessage, sourceURL, sourcePosition.m_line, sourcePosition.m_column, state); … … 700 700 ASSERT(m_client || is<Document>(m_scriptExecutionContext)); 701 701 702 String blockedURI = deprecatedURLForReporting(blockedURL); 702 String blockedURI; 703 if (preRedirectURL.isNull()) 704 blockedURI = deprecatedURLForReporting(blockedURL); 705 else 706 blockedURI = deprecatedURLForReporting(preRedirectURL); 707 703 708 // FIXME: Is it policy to not use the status code for HTTPS, or is that a bug? 704 709 unsigned short httpStatusCode = m_selfSourceProtocol == "http" ? m_httpStatusCode : 0; -
trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h
r278669 r281431 115 115 bool allowChildFrameFromSource(const URL&, RedirectResponseReceived = RedirectResponseReceived::No) const; 116 116 WEBCORE_EXPORT bool allowChildContextFromSource(const URL&, RedirectResponseReceived = RedirectResponseReceived::No) const; 117 WEBCORE_EXPORT bool allowConnectToSource(const URL&, RedirectResponseReceived = RedirectResponseReceived::No ) const;117 WEBCORE_EXPORT bool allowConnectToSource(const URL&, RedirectResponseReceived = RedirectResponseReceived::No, const URL& requestedURL = URL()) const; 118 118 bool allowFormAction(const URL&, RedirectResponseReceived = RedirectResponseReceived::No) const; 119 119 … … 211 211 void reportViolation(const String& effectiveViolatedDirective, const ContentSecurityPolicyDirective& violatedDirective, const URL& blockedURL, const String& consoleMessage, JSC::JSGlobalObject*) const; 212 212 void reportViolation(const String& effectiveViolatedDirective, const String& violatedDirective, const ContentSecurityPolicyDirectiveList&, const URL& blockedURL, const String& consoleMessage, JSC::JSGlobalObject* = nullptr) const; 213 void reportViolation(const String& effectiveViolatedDirective, const ContentSecurityPolicyDirective& violatedDirective, const URL& blockedURL, const String& consoleMessage, const String& sourceURL, const TextPosition& sourcePosition, JSC::JSGlobalObject* = nullptr) const;214 void reportViolation(const String& effectiveViolatedDirective, const String& violatedDirective, const ContentSecurityPolicyDirectiveList& violatedDirectiveList, const URL& blockedURL, const String& consoleMessage, const String& sourceURL, const TextPosition& sourcePosition, JSC::JSGlobalObject* ) const;213 void reportViolation(const String& effectiveViolatedDirective, const ContentSecurityPolicyDirective& violatedDirective, const URL& blockedURL, const String& consoleMessage, const String& sourceURL, const TextPosition& sourcePosition, const URL& preRedirectURL = URL(), JSC::JSGlobalObject* = nullptr) const; 214 void reportViolation(const String& effectiveViolatedDirective, const String& violatedDirective, const ContentSecurityPolicyDirectiveList& violatedDirectiveList, const URL& blockedURL, const String& consoleMessage, const String& sourceURL, const TextPosition& sourcePosition, JSC::JSGlobalObject*, const URL& preRedirectURL = URL()) const; 215 215 void reportBlockedScriptExecutionToInspector(const String& directiveText) const; 216 216 -
trunk/Source/WebKit/ChangeLog
r281420 r281431 1 2021-08-22 Kate Cheney <katherine_cheney@apple.com> 2 3 Report correct blocked URI in CSP violation report 4 https://bugs.webkit.org/show_bug.cgi?id=226316 5 <rdar://problem/78552912> 6 7 Reviewed by Alex Christensen. 8 9 Currently for a blocked redirection we report the blocked URI as the 10 target URL. This is not up to spec and we should actually report the 11 requested URL. 12 13 * NetworkProcess/NetworkLoadChecker.cpp: 14 (WebKit::NetworkLoadChecker::check): 15 (WebKit::NetworkLoadChecker::checkRedirection): 16 (WebKit::NetworkLoadChecker::checkRequest): 17 (WebKit::NetworkLoadChecker::isAllowedByContentSecurityPolicy): 18 * NetworkProcess/NetworkLoadChecker.h: 19 1 20 2021-08-22 Wenson Hsieh <wenson_hsieh@apple.com> 2 21 -
trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.cpp
r280953 r281431 93 93 94 94 m_firstRequestHeaders = request.httpHeaderFields(); 95 checkRequest(WTFMove(request), client, WTFMove(handler));95 checkRequest(WTFMove(request), client, URL(), WTFMove(handler)); 96 96 } 97 97 … … 143 143 m_url = redirectRequest.url(); 144 144 145 checkRequest(WTFMove(redirectRequest), client, [handler = WTFMove(handler), request = WTFMove(request), redirectResponse = WTFMove(redirectResponse)](auto&& result) mutable {145 checkRequest(WTFMove(redirectRequest), client, redirectResponse.url(), [handler = WTFMove(handler), request = WTFMove(request), redirectResponse](auto&& result) mutable { 146 146 WTF::switchOn(result, 147 147 [&handler] (ResourceError& error) mutable { … … 208 208 } 209 209 210 void NetworkLoadChecker::checkRequest(ResourceRequest&& request, ContentSecurityPolicyClient* client, ValidationHandler&& handler)210 void NetworkLoadChecker::checkRequest(ResourceRequest&& request, ContentSecurityPolicyClient* client, const URL& preRedirectURL, ValidationHandler&& handler) 211 211 { 212 212 ResourceRequest originalRequest = request; … … 217 217 contentSecurityPolicy->upgradeInsecureRequestIfNeeded(request, type); 218 218 } 219 if (!this->isAllowedByContentSecurityPolicy(request, client )) {219 if (!this->isAllowedByContentSecurityPolicy(request, client, preRedirectURL)) { 220 220 handler(this->accessControlErrorForValidationHandler("Blocked by Content Security Policy."_s)); 221 221 return; … … 254 254 } 255 255 256 bool NetworkLoadChecker::isAllowedByContentSecurityPolicy(const ResourceRequest& request, WebCore::ContentSecurityPolicyClient* client )256 bool NetworkLoadChecker::isAllowedByContentSecurityPolicy(const ResourceRequest& request, WebCore::ContentSecurityPolicyClient* client, const URL& preRedirectURL) 257 257 { 258 258 auto* contentSecurityPolicy = this->contentSecurityPolicy(); … … 276 276 return true; 277 277 case FetchOptions::Destination::EmptyString: 278 return contentSecurityPolicy->allowConnectToSource(request.url(), redirectResponseReceived );278 return contentSecurityPolicy->allowConnectToSource(request.url(), redirectResponseReceived, preRedirectURL); 279 279 case FetchOptions::Destination::Audio: 280 280 case FetchOptions::Destination::Document: -
trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.h
r280953 r281431 107 107 bool isRedirected() const { return m_redirectCount; } 108 108 109 void checkRequest(WebCore::ResourceRequest&&, WebCore::ContentSecurityPolicyClient*, ValidationHandler&&);109 void checkRequest(WebCore::ResourceRequest&&, WebCore::ContentSecurityPolicyClient*, const URL&, ValidationHandler&&); 110 110 111 bool isAllowedByContentSecurityPolicy(const WebCore::ResourceRequest&, WebCore::ContentSecurityPolicyClient* );111 bool isAllowedByContentSecurityPolicy(const WebCore::ResourceRequest&, WebCore::ContentSecurityPolicyClient*, const URL& preRedirectURL = URL()); 112 112 113 113 void continueCheckingRequest(WebCore::ResourceRequest&&, ValidationHandler&&);
Note:
See TracChangeset
for help on using the changeset viewer.