Changeset 285823 in webkit
- Timestamp:
- Nov 15, 2021 12:21:10 PM (8 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 3 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/wpt/html/cross-origin-embedder-policy/require-corp-data-url-expected.txt (added)
-
LayoutTests/http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html (added)
-
LayoutTests/http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html.headers (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/loader/cache/CachedResourceLoader.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r285822 r285823 1 2021-11-15 Chris Dumez <cdumez@apple.com> 2 3 `Cross-Origin-Embedder-Policy: require-corp` prevents loading of data URL images 4 https://bugs.webkit.org/show_bug.cgi?id=233131 5 <rdar://85236459> 6 7 Reviewed by Geoffrey Garen. 8 9 Add layout test coverage. This test is based on a reduce test case from Cameron McCormack. 10 11 * http/wpt/html/cross-origin-embedder-policy/require-corp-data-url-expected.txt: Added. 12 * http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html: Added. 13 * http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html.headers: Added. 14 1 15 2021-11-15 Kiet Ho <tho22@apple.com> 2 16 -
trunk/Source/WebCore/ChangeLog
r285822 r285823 1 2021-11-15 Chris Dumez <cdumez@apple.com> 2 3 `Cross-Origin-Embedder-Policy: require-corp` prevents loading of data URL images 4 https://bugs.webkit.org/show_bug.cgi?id=233131 5 <rdar://85236459> 6 7 Reviewed by Geoffrey Garen. 8 9 When doing an initial data URL <img> load, we properly wouldn't perform a cross-origin resource policy check. 10 This is per the Fetch specification that says to use a scheme fetch [1] when the request URL is a data URL. 11 When the protocol is data, the scheme fetch algorithm would return a response without performing an HTTP 12 Fetch. The HTTP check [2] is the algorithm that actually performs a cross-origin resource policy check, at 13 step 7. 14 15 The issue with our implementation was that data URL <img> loads would perform a cross-origin resource policy 16 check in the case where the image is loaded from our memory cache, due to a check we had in 17 CachedResourceLoader::requestResource(). As a result, data URL <img> loads would fail when served from the 18 memory cache, when CORP is enforced. To address the issue and match the specification, we now disable this 19 CORP check when the request URL is a data URL. 20 21 [1] https://fetch.spec.whatwg.org/#scheme-fetch 22 [2] https://fetch.spec.whatwg.org/#concept-http-fetch 23 24 Test: http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html 25 26 * loader/cache/CachedResourceLoader.cpp: 27 (WebCore::CachedResourceLoader::requestResource): 28 1 29 2021-11-15 Kiet Ho <tho22@apple.com> 2 30 -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp
r284080 r285823 1015 1015 } 1016 1016 } 1017 if (request.options().mode == FetchOptions::Mode::NoCors) { 1017 // Per the Fetch specification, the "cross-origin resource policy check" should only occur in the HTTP Fetch case (https://fetch.spec.whatwg.org/#concept-http-fetch). 1018 // However, per https://fetch.spec.whatwg.org/#main-fetch, if the request URL's protocol is "data:", then we should perform a scheme fetch which would end up 1019 // returning a response WITHOUT performing an HTTP fetch (and thus no CORP check). 1020 if (request.options().mode == FetchOptions::Mode::NoCors && !url.protocolIsData()) { 1018 1021 auto coep = document() ? document()->crossOriginEmbedderPolicy().value : CrossOriginEmbedderPolicyValue::UnsafeNone; 1019 1022 if (auto error = validateCrossOriginResourcePolicy(coep, *request.origin(), request.resourceRequest().url(), resource->response(), ForNavigation::No)) 1020 1023 return makeUnexpected(WTFMove(*error)); 1021 1024 } 1025 if (request.options().mode == FetchOptions::Mode::NoCors) { 1022 1026 if (auto error = validateRangeRequestedFlag(request.resourceRequest(), resource->response())) 1023 1027 return makeUnexpected(WTFMove(*error));
Note: See TracChangeset
for help on using the changeset viewer.