Changeset 207752 in webkit
- Timestamp:
- Oct 24, 2016 12:49:14 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r207737 r207752 1 2016-10-24 Youenn Fablet <youenn@apple.com> 2 3 Redirections should be upgraded if CSP policy says so 4 https://bugs.webkit.org/show_bug.cgi?id=163544 5 6 Reviewed by Darin Adler. 7 8 * http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/basic-upgrade-after-redirect.https-expected.txt: Added. 9 * http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/basic-upgrade-after-redirect.https.html: Added. 10 * http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-redirect-https-to-http-script-in-iframe-expected.txt: 11 * http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-redirect-https-to-http-script-in-iframe.html: 12 * platform/mac/TestExpectations: 13 1 14 2016-10-22 Sam Weinig <sam@webkit.org> 2 15 -
trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-redirect-https-to-http-script-in-iframe-expected.txt
r201753 r207752 2 2 main frame - didFinishDocumentLoadForFrame 3 3 frame "<!--framePath //<!--frame0-->-->" - didCommitLoadForFrame 4 CONSOLE MESSAGE: [blocked] The page at https://127.0.0.1:8443/security/contentSecurityPolicy/upgrade-insecure-requests/resources/frame-with-redirect-https-to-http-script.html was not allowed to run insecure content from http://127.0.0.1:8080/security/mixedContent/resources/script.js.5 6 4 frame "<!--framePath //<!--frame0-->-->" - didFinishDocumentLoadForFrame 7 5 frame "<!--framePath //<!--frame0-->-->" - didHandleOnloadEventsForFrame … … 9 7 frame "<!--framePath //<!--frame0-->-->" - didFinishLoadForFrame 10 8 main frame - didFinishLoadForFrame 11 This test loads a secure iframe that loads an insecure script (but with a tricky redirect). We should upgrade the relevant requests for the any top-level frames, but not sub-resources of those frames, triggering a mixed content callback.9 This test loads a secure iframe that loads an insecure script (but with a tricky redirect). We should upgrade the relevant requests. 12 10 13 11 -
trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-redirect-https-to-http-script-in-iframe.html
r201753 r207752 8 8 } 9 9 </script> 10 <p>This test loads a secure iframe that loads an insecure script (but with a 11 tricky redirect). We should upgrade the relevant requests for the any top-level 12 frames, but not sub-resources of those frames, triggering a mixed content callback.</p> 10 <p>This test loads a secure iframe that loads an insecure script (but with a tricky redirect). We should upgrade the relevant requests.</p> 13 11 <iframe src="https://127.0.0.1:8443/security/contentSecurityPolicy/upgrade-insecure-requests/resources/frame-with-redirect-https-to-http-script.html"></iframe> 14 12 </body> -
trunk/LayoutTests/platform/mac/TestExpectations
r207660 r207752 1332 1332 webkit.org/b/155140 js/promises-tests/promises-tests-2-3-3.html [ Pass Failure ] 1333 1333 1334 webkit.org/b/163544 http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/upgrade-redirect-https-to-http-script-in-iframe.html [ Pass Timeout ] 1335 1334 1336 # Content Security Policy for media redirects is not supported on some OSes. 1335 1337 [ Yosemite ElCapitan ] http/tests/security/contentSecurityPolicy/audio-redirect-blocked.html [ Failure ] -
trunk/Source/WebCore/ChangeLog
r207737 r207752 1 2016-10-24 Youenn Fablet <youenn@apple.com> 2 3 Redirections should be upgraded if CSP policy says so 4 https://bugs.webkit.org/show_bug.cgi?id=163544 5 6 Reviewed by Darin Adler. 7 8 Test: http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/basic-upgrade-after-redirect.https.html 9 10 Introducing CachedResourceLoader::updateRequestAfterRedirection to do the checks that CachedResourceLoader is doing 11 to the initial request, but for redirection requests. 12 13 Implemented URL upgrade according CSP policy, as specified by fetch algorithm. 14 Minor refactoring in CachedResourceRequest to share some code. 15 Fixing some constness issues. 16 17 * loader/SubresourceLoader.cpp: 18 (WebCore::SubresourceLoader::willSendRequestInternal): 19 * loader/cache/CachedResourceLoader.cpp: 20 (WebCore::CachedResourceLoader::allowedByContentSecurityPolicy): 21 (WebCore::CachedResourceLoader::canRequestAfterRedirection): 22 (WebCore::CachedResourceLoader::updateRequestAfterRedirection): 23 * loader/cache/CachedResourceLoader.h: 24 * loader/cache/CachedResourceRequest.cpp: 25 (WebCore::upgradeInsecureResourceRequestIfNeeded): 26 (WebCore::CachedResourceRequest::upgradeInsecureRequestIfNeeded): 27 * loader/cache/CachedResourceRequest.h: 28 1 29 2016-10-22 Sam Weinig <sam@webkit.org> 2 30 -
trunk/Source/WebCore/loader/SubresourceLoader.cpp
r207388 r207752 204 204 } 205 205 206 if (!m_documentLoader->cachedResourceLoader(). canRequestAfterRedirection(m_resource->type(), newRequest.url(), options())) {206 if (!m_documentLoader->cachedResourceLoader().updateRequestAfterRedirection(m_resource->type(), newRequest, options())) { 207 207 cancel(); 208 208 return; -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp
r207459 r207752 381 381 } 382 382 383 bool CachedResourceLoader::allowedByContentSecurityPolicy(CachedResource::Type type, const URL& url, const ResourceLoaderOptions& options, ContentSecurityPolicy::RedirectResponseReceived redirectResponseReceived) 383 bool CachedResourceLoader::allowedByContentSecurityPolicy(CachedResource::Type type, const URL& url, const ResourceLoaderOptions& options, ContentSecurityPolicy::RedirectResponseReceived redirectResponseReceived) const 384 384 { 385 385 if (options.contentSecurityPolicyImposition == ContentSecurityPolicyImposition::SkipPolicyCheck) … … 471 471 472 472 // FIXME: Should we find a way to know whether the redirection is for a preload request like we do for CachedResourceLoader::canRequest? 473 bool CachedResourceLoader::canRequestAfterRedirection(CachedResource::Type type, const URL& url, const ResourceLoaderOptions& options) 473 bool CachedResourceLoader::canRequestAfterRedirection(CachedResource::Type type, const URL& url, const ResourceLoaderOptions& options) const 474 474 { 475 475 if (document() && !document()->securityOrigin()->canDisplay(url)) { … … 496 496 497 497 return true; 498 } 499 500 bool CachedResourceLoader::updateRequestAfterRedirection(CachedResource::Type type, ResourceRequest& request, const ResourceLoaderOptions& options) 501 { 502 ASSERT(m_documentLoader); 503 if (auto* document = m_documentLoader->cachedResourceLoader().document()) 504 upgradeInsecureResourceRequestIfNeeded(request, *document); 505 506 // FIXME: We might want to align the checks done here with the ones done in CachedResourceLoader::requestResource, content extensions blocking in particular. 507 508 return canRequestAfterRedirection(type, request.url(), options); 498 509 } 499 510 -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.h
r207086 r207752 137 137 void printPreloadStats(); 138 138 139 bool canRequestAfterRedirection(CachedResource::Type, const URL&, const ResourceLoaderOptions&);139 bool updateRequestAfterRedirection(CachedResource::Type, ResourceRequest&, const ResourceLoaderOptions&); 140 140 141 141 static const ResourceLoaderOptions& defaultCachedResourceOptions(); … … 172 172 bool shouldContinueAfterNotifyingLoadedFromMemoryCache(const CachedResourceRequest&, CachedResource*); 173 173 bool checkInsecureContent(CachedResource::Type, const URL&) const; 174 bool allowedByContentSecurityPolicy(CachedResource::Type, const URL&, const ResourceLoaderOptions&, ContentSecurityPolicy::RedirectResponseReceived) ;174 bool allowedByContentSecurityPolicy(CachedResource::Type, const URL&, const ResourceLoaderOptions&, ContentSecurityPolicy::RedirectResponseReceived) const; 175 175 176 176 void performPostLoadActions(); … … 179 179 void reloadImagesIfNotDeferred(); 180 180 181 bool canRequestAfterRedirection(CachedResource::Type, const URL&, const ResourceLoaderOptions&) const; 181 182 bool canRequestInContentDispositionAttachmentSandbox(CachedResource::Type, const URL&) const; 182 183 183 184 HashSet<String> m_validatedURLs; 184 185 mutable DocumentResourceMap m_documentResources; -
trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp
r207459 r207752 106 106 } 107 107 108 void CachedResourceRequest::upgradeInsecureRequestIfNeeded(Document& document)109 { 110 URL url = m_resourceRequest.url();108 void upgradeInsecureResourceRequestIfNeeded(ResourceRequest& request, Document& document) 109 { 110 URL url = request.url(); 111 111 112 112 ASSERT(document.contentSecurityPolicy()); 113 113 document.contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(url, ContentSecurityPolicy::InsecureRequestType::Load); 114 114 115 if (url == m_resourceRequest.url())115 if (url == request.url()) 116 116 return; 117 117 118 m_resourceRequest.setURL(url); 118 request.setURL(url); 119 } 120 121 void CachedResourceRequest::upgradeInsecureRequestIfNeeded(Document& document) 122 { 123 upgradeInsecureResourceRequestIfNeeded(m_resourceRequest, document); 119 124 } 120 125 -
trunk/Source/WebCore/loader/cache/CachedResourceRequest.h
r207459 r207752 95 95 }; 96 96 97 void upgradeInsecureResourceRequestIfNeeded(ResourceRequest&, Document&); 98 97 99 } // namespace WebCore 98 100
Note: See TracChangeset
for help on using the changeset viewer.