⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 285892 in webkit


Ignore:
Timestamp:
Nov 16, 2021, 2:58:57 PM (5 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r285823. rdar://problem/85236459

Cross-Origin-Embedder-Policy: require-corp prevents loading of data URL images
https://bugs.webkit.org/show_bug.cgi?id=233131
<rdar://85236459>

Reviewed by Geoffrey Garen.

Source/WebCore:

When doing an initial data URL <img> load, we properly wouldn't perform a cross-origin resource policy check.
This is per the Fetch specification that says to use a scheme fetch [1] when the request URL is a data URL.
When the protocol is data, the scheme fetch algorithm would return a response without performing an HTTP
Fetch. The HTTP check [2] is the algorithm that actually performs a cross-origin resource policy check, at
step 7.

The issue with our implementation was that data URL <img> loads would perform a cross-origin resource policy
check in the case where the image is loaded from our memory cache, due to a check we had in
CachedResourceLoader::requestResource(). As a result, data URL <img> loads would fail when served from the
memory cache, when CORP is enforced. To address the issue and match the specification, we now disable this
CORP check when the request URL is a data URL.

[1] https://fetch.spec.whatwg.org/#scheme-fetch
[2] https://fetch.spec.whatwg.org/#concept-http-fetch

Test: http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html

  • loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::requestResource):

LayoutTests:

Add layout test coverage. This test is based on a reduce test case from Cameron McCormack.

  • http/wpt/html/cross-origin-embedder-policy/require-corp-data-url-expected.txt: Added.
  • http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html: Added.
  • http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html.headers: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285823 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-612.3.6.1-branch
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612.3.6.1-branch/LayoutTests/ChangeLog

    r285834 r285892  
     12021-11-16  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r285823. rdar://problem/85236459
     4
     5    `Cross-Origin-Embedder-Policy: require-corp` prevents loading of data URL images
     6    https://bugs.webkit.org/show_bug.cgi?id=233131
     7    <rdar://85236459>
     8   
     9    Reviewed by Geoffrey Garen.
     10   
     11    Source/WebCore:
     12   
     13    When doing an initial data URL <img> load, we properly wouldn't perform a cross-origin resource policy check.
     14    This is per the Fetch specification that says to use a scheme fetch [1] when the request URL is a data URL.
     15    When the protocol is data, the scheme fetch algorithm would return a response without performing an HTTP
     16    Fetch. The HTTP check [2] is the algorithm that actually performs a cross-origin resource policy check, at
     17    step 7.
     18   
     19    The issue with our implementation was that data URL <img> loads would perform a cross-origin resource policy
     20    check in the case where the image is loaded from our memory cache, due to a check we had in
     21    CachedResourceLoader::requestResource(). As a result, data URL <img> loads would fail when served from the
     22    memory cache, when CORP is enforced. To address the issue and match the specification, we now disable this
     23    CORP check when the request URL is a data URL.
     24   
     25    [1] https://fetch.spec.whatwg.org/#scheme-fetch
     26    [2] https://fetch.spec.whatwg.org/#concept-http-fetch
     27   
     28    Test: http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html
     29   
     30    * loader/cache/CachedResourceLoader.cpp:
     31    (WebCore::CachedResourceLoader::requestResource):
     32   
     33    LayoutTests:
     34   
     35    Add layout test coverage. This test is based on a reduce test case from Cameron McCormack.
     36   
     37    * http/wpt/html/cross-origin-embedder-policy/require-corp-data-url-expected.txt: Added.
     38    * http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html: Added.
     39    * http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html.headers: Added.
     40   
     41   
     42    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285823 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     43
     44    2021-11-15  Chris Dumez  <cdumez@apple.com>
     45
     46            `Cross-Origin-Embedder-Policy: require-corp` prevents loading of data URL images
     47            https://bugs.webkit.org/show_bug.cgi?id=233131
     48            <rdar://85236459>
     49
     50            Reviewed by Geoffrey Garen.
     51
     52            Add layout test coverage. This test is based on a reduce test case from Cameron McCormack.
     53
     54            * http/wpt/html/cross-origin-embedder-policy/require-corp-data-url-expected.txt: Added.
     55            * http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html: Added.
     56            * http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html.headers: Added.
     57
    1582021-11-15  Alan Coon  <alancoon@apple.com>
    259
  • branches/safari-612.3.6.1-branch/Source/WebCore/ChangeLog

    r285835 r285892  
     12021-11-16  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r285823. rdar://problem/85236459
     4
     5    `Cross-Origin-Embedder-Policy: require-corp` prevents loading of data URL images
     6    https://bugs.webkit.org/show_bug.cgi?id=233131
     7    <rdar://85236459>
     8   
     9    Reviewed by Geoffrey Garen.
     10   
     11    Source/WebCore:
     12   
     13    When doing an initial data URL <img> load, we properly wouldn't perform a cross-origin resource policy check.
     14    This is per the Fetch specification that says to use a scheme fetch [1] when the request URL is a data URL.
     15    When the protocol is data, the scheme fetch algorithm would return a response without performing an HTTP
     16    Fetch. The HTTP check [2] is the algorithm that actually performs a cross-origin resource policy check, at
     17    step 7.
     18   
     19    The issue with our implementation was that data URL <img> loads would perform a cross-origin resource policy
     20    check in the case where the image is loaded from our memory cache, due to a check we had in
     21    CachedResourceLoader::requestResource(). As a result, data URL <img> loads would fail when served from the
     22    memory cache, when CORP is enforced. To address the issue and match the specification, we now disable this
     23    CORP check when the request URL is a data URL.
     24   
     25    [1] https://fetch.spec.whatwg.org/#scheme-fetch
     26    [2] https://fetch.spec.whatwg.org/#concept-http-fetch
     27   
     28    Test: http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html
     29   
     30    * loader/cache/CachedResourceLoader.cpp:
     31    (WebCore::CachedResourceLoader::requestResource):
     32   
     33    LayoutTests:
     34   
     35    Add layout test coverage. This test is based on a reduce test case from Cameron McCormack.
     36   
     37    * http/wpt/html/cross-origin-embedder-policy/require-corp-data-url-expected.txt: Added.
     38    * http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html: Added.
     39    * http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html.headers: Added.
     40   
     41   
     42    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@285823 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     43
     44    2021-11-15  Chris Dumez  <cdumez@apple.com>
     45
     46            `Cross-Origin-Embedder-Policy: require-corp` prevents loading of data URL images
     47            https://bugs.webkit.org/show_bug.cgi?id=233131
     48            <rdar://85236459>
     49
     50            Reviewed by Geoffrey Garen.
     51
     52            When doing an initial data URL <img> load, we properly wouldn't perform a cross-origin resource policy check.
     53            This is per the Fetch specification that says to use a scheme fetch [1] when the request URL is a data URL.
     54            When the protocol is data, the scheme fetch algorithm would return a response without performing an HTTP
     55            Fetch. The HTTP check [2] is the algorithm that actually performs a cross-origin resource policy check, at
     56            step 7.
     57
     58            The issue with our implementation was that data URL <img> loads would perform a cross-origin resource policy
     59            check in the case where the image is loaded from our memory cache, due to a check we had in
     60            CachedResourceLoader::requestResource(). As a result, data URL <img> loads would fail when served from the
     61            memory cache, when CORP is enforced. To address the issue and match the specification, we now disable this
     62            CORP check when the request URL is a data URL.
     63
     64            [1] https://fetch.spec.whatwg.org/#scheme-fetch
     65            [2] https://fetch.spec.whatwg.org/#concept-http-fetch
     66
     67            Test: http/wpt/html/cross-origin-embedder-policy/require-corp-data-url.html
     68
     69            * loader/cache/CachedResourceLoader.cpp:
     70            (WebCore::CachedResourceLoader::requestResource):
     71
    1722021-11-15  Alan Coon  <alancoon@apple.com>
    273
  • branches/safari-612.3.6.1-branch/Source/WebCore/loader/cache/CachedResourceLoader.cpp

    r283922 r285892  
    10141014            }
    10151015        }
    1016         if (request.options().mode == FetchOptions::Mode::NoCors) {
     1016        // 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).
     1017        // 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
     1018        // returning a response WITHOUT performing an HTTP fetch (and thus no CORP check).
     1019        if (request.options().mode == FetchOptions::Mode::NoCors && !url.protocolIsData()) {
    10171020            auto coep = document() ? document()->crossOriginEmbedderPolicy().value : CrossOriginEmbedderPolicyValue::UnsafeNone;
    10181021            if (auto error = validateCrossOriginResourcePolicy(coep, *request.origin(), request.resourceRequest().url(), resource->response(), ForNavigation::No))
    10191022                return makeUnexpected(WTFMove(*error));
    1020 
     1023        }
     1024        if (request.options().mode == FetchOptions::Mode::NoCors) {
    10211025            if (auto error = validateRangeRequestedFlag(request.resourceRequest(), resource->response()))
    10221026                return makeUnexpected(WTFMove(*error));
Note: See TracChangeset for help on using the changeset viewer.