Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache.match() and COEP #1490

Closed
wanderview opened this issue Dec 9, 2019 · 15 comments · Fixed by #1516
Closed

cache.match() and COEP #1490

wanderview opened this issue Dec 9, 2019 · 15 comments · Fixed by #1516

Comments

@wanderview
Copy link
Member

What should we do if cache.match() is called in a context with Cross-Origin-Embedder-Policy: require-corp and the Response to be returned does not have a Cross-Origin-Resource-Policy header?

I would like to advocate that we reject the match() since it seems possible there could be information stored in the headers that should not be exposed to spectre attacks. Also, it seems you can have a CORS response without a CORP header that would fail the COEP check and we would not want to expose the body in that case.

@mikewest @annevk @yutakahirano @makotoshimazu

@ArthurSonzogni
Copy link
Member

@ArthurSonzogni

@annevk
Copy link
Member

annevk commented Dec 9, 2019

There shouldn't be a COEP/CORP check for non-opaque responses (such as a CORS response).

Our thinking about this so far has been that if the opaque response only holds a handle to the actual secret and there's no way for the secret to enter the content process there's no problem and no need for API changes.

But I don't care strongly.

cc @asutherland @perryjiang

@ArthurSonzogni
Copy link
Member

ArthurSonzogni commented Dec 9, 2019

@annevk, If I fully understand what you said:

From a document with Cross-Origin-Embedder-Policy: require-corp
If a CORS request is made and the response contains:Access-Control-Allow-Origin: * (for instance)
Then the response is non-opaque and the document can access it. Even if the response do NOT have: Cross-Origin-Resource-Policy: cross-origin
Is it what you said?

@annevk
Copy link
Member

annevk commented Dec 9, 2019

Yeah, https://mikewest.github.io/corpp/#abstract-opdef-cross-origin-resource-policy-check exits early with allowed for such a case, no?

@wanderview
Copy link
Member Author

Ok, ignore the comment about CORS responses then. Sorry for my confusion.

It still feels more clear to me to reject the match() call instead of returning an opaque response that may blow up when passed to respondWith() further along. And may leak headers via spectre.

@annevk
Copy link
Member

annevk commented Dec 9, 2019

If it's not just a handle things will leak, agreed. And it might therefore be worthwhile to block earlier on. Firefox will implement COEP service/shared workers later on, but I suspect similar considerations apply and unless Andrew/Perry feel otherwise I think we'd be okay with blocking early.

@wanderview
Copy link
Member Author

I'm fairly confident both chrome/firefox store and retrieve the full internal headers for opaque responses. In addition, both browsers do some amount of eager reading of the body data under different circumstances.

It would be possible to fix all that for COEP, but its much safer to never allow these Response objects to enter the child/renderer process at all.

@asutherland
Copy link

asutherland commented Dec 9, 2019

Yes, @wanderview is right that Firefox currently sends all the data about opaque responses to the content processes and only creates the opaque wrapped response when processing the received IPC data, which is too late. I think bug 1565199 covers the general scenario for Firefox.

The most recent thoughts @perryjiang and I had on this were that we would run the same CORP check on cache.match() responses and at least, for now, send a pre-opaqued response that can't be used for anything. (That is, there's just a opaque filtered response and any attempt to consume the underlying response will fail with a corp-check (network) error.)

API-wise, it seems like there are 5 options:

  1. Partition storage of COEP-affected storage by the COEP bits. A COEP-safe storage cannot store something that would fail a CORP-check. All storages opened by COEP contexts set this bit on creation and fail to open a storage if the bit is not set. A non-COEP context can opt in to this constraint when creating a storage. Maybe whole storage buckets can be marked COEP-safe. This may or may not be something that would have synergies about the proposals to give WASM memory-mapped block storage APIs so lucene and SQLite can be compiled into WASM and be fast.
  2. Hide keys and Responses when the Response would fail a CORP check. This seems untenably confusing.
  3. Ben's proposed match-rejects when a matched Response fails a CORP check. This would cause the most immediate/obvious breakage as matchAll() calls that might not look at the CORP-failing Response might now explode, although that use case seems wacky. This approach becomes more problematic if we allow Responses to be stored in IndexedDB. Application logic that invokes getAll is a thing that happens, and poisoned values would be a real problem in that case.
  4. Responses become unusable even though technically if they were just a handle and you were respondWith()ing to a non-COEP context, it could work. (Firefox's current short term plan.) Nothing breaks until you try and consume it.
  5. Responses are just a handle and can transit a COEP-context into a non-COEP-context and it should work just like the COEP-context isn't involved. This is least breakage prone but the most complex.

The Responses-get-nulled situation is similar to Blob edge-cases where a <input type="file"> sourced-Blob is invalidated by changes on disk. (Or when Clear-Site-Data/privacy API's clear an origin's data and there are still (cross-origin) Blob references that only held a reference to on-disk data and didn't copy the contents out.) It's an allegedly immutable thing that can turn out not to be there.

The Responses-are-handles situation is sorta analogous to the current MessagePort.postMessage of a SharedArrayBuffer. Because you can never reason about what global the serialized payload will be deserialized in because the ports can always be shipped, there are cases where it's safe to ship the data itself, and there are times when you have to be shipping around a handle. However, in that case we fail to deserialize the entire serialized object due to the SAB, not creating a nulled SAB reference.

I don't have any specific proposal other than banding together to build a gateway to a parallel universe without SPECTRE attacks.

@wanderview
Copy link
Member Author

Ben's proposed match-rejects when a matched Response fails a CORP check. This would cause the most immediate/obvious breakage as matchAll() calls that might not look at the CORP-failing Response might now explode, although that use case seems wacky. This approach becomes more problematic if we allow Responses to be stored in IndexedDB. Application logic that invokes getAll is a thing that happens, and poisoned values would be a real problem in that case.

I think these issues are only problematic for sites that want some contexts COEP protected and some other contexts non-COEP protected. This seems like an unusual use case.

Also, IDB support for responses does not exist today and I haven't seen any movement towards making it happen. Its easier to relax the rejecting behavior if we need to support something like that in the future than it is to claw back the returned Response.

I feel pretty strongly we should start by rejecting cache.match() and cache.matchAll().

@asutherland
Copy link

I feel pretty strongly we should start by rejecting cache.match() and cache.matchAll().

It's definitely easy to implement and easy to relax. I've filed https://bugzilla.mozilla.org/show_bug.cgi?id=1603168 for the specific implementation in Firefox and we'll likely implement it in the near future.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 18, 2019
[PROTOTYPE] => DO NOT COMMIT.

Document using:
"Cross-Origin-Embedder-Policy: require-corp"
must not access cross-origin response that do not have the header:
"Cross-Origin-Resource-Policy: cross-site"

This is about only no-cors requests. CORS requests are checked against the
CORS headers instead.

See:
 - whatwg/fetch#985
 - w3c/ServiceWorker#1490

Bug:1031542
Change-Id: I94a2cb9435fcf3e76f57a8f3d3344c87fa23f9a9
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 18, 2019
[PROTOTYPE] => DO NOT COMMIT.

Document using:
"Cross-Origin-Embedder-Policy: require-corp"
must not access cross-origin response that do not have the header:
"Cross-Origin-Resource-Policy: cross-site"

This is about only no-cors requests. CORS requests are checked against the
CORS headers instead.

See:
 - whatwg/fetch#985
 - w3c/ServiceWorker#1490

Bug:1031542
Change-Id: I94a2cb9435fcf3e76f57a8f3d3344c87fa23f9a9
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 18, 2019
[PROTOTYPE] => DO NOT COMMIT.

Document using:
"Cross-Origin-Embedder-Policy: require-corp"
must not access cross-origin response that do not have the header:
"Cross-Origin-Resource-Policy: cross-site"

This is about only no-cors requests. CORS requests are checked against the
CORS headers instead.

See:
 - whatwg/fetch#985
 - w3c/ServiceWorker#1490

Bug:1031542
Change-Id: I94a2cb9435fcf3e76f57a8f3d3344c87fa23f9a9
@ArthurSonzogni
Copy link
Member

We also need to define what error type must be returned when cache.match is blocked by CORP checks. Do you have an opinion?

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 19, 2019
[PROTOTYPE] => DO NOT COMMIT.

Document using:
"Cross-Origin-Embedder-Policy: require-corp"
must not access cross-origin response that do not have the header:
"Cross-Origin-Resource-Policy: cross-site"

This is about only no-cors requests. CORS requests are checked against the
CORS headers instead.

See:
 - whatwg/fetch#985
 - w3c/ServiceWorker#1490

Bug:1031542
Change-Id: I94a2cb9435fcf3e76f57a8f3d3344c87fa23f9a9
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 19, 2019
Document using:
"Cross-Origin-Embedder-Policy: require-corp"
must not access cross-origin response that do not have the header:
"Cross-Origin-Resource-Policy: cross-site"

This is about only no-cors requests. CORS requests are checked against the
CORS headers instead.

See:
 - whatwg/fetch#985
 - w3c/ServiceWorker#1490

Bug:1031542
Change-Id: I94a2cb9435fcf3e76f57a8f3d3344c87fa23f9a9
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 19, 2019
Document using:
"Cross-Origin-Embedder-Policy: require-corp"
must not access cross-origin response that do not have the header:
"Cross-Origin-Resource-Policy: cross-site"

This is about only no-cors requests. CORS requests are checked against the
CORS headers instead.

See:
 - whatwg/fetch#985
 - w3c/ServiceWorker#1490

Bug:1031542
Change-Id: I94a2cb9435fcf3e76f57a8f3d3344c87fa23f9a9
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 19, 2019
Document using:
"Cross-Origin-Embedder-Policy: require-corp"
must not access cross-origin response that do not have the header:
"Cross-Origin-Resource-Policy: cross-site"

This is about only no-cors requests. CORS requests are checked against the
CORS headers instead.

See:
 - whatwg/fetch#985
 - w3c/ServiceWorker#1490

Bug:1031542
Change-Id: I94a2cb9435fcf3e76f57a8f3d3344c87fa23f9a9
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 20, 2019
Document using:
"Cross-Origin-Embedder-Policy: require-corp"
must not access cross-origin response that do not have the header:
"Cross-Origin-Resource-Policy: cross-site"

This is about only no-cors requests. CORS requests are checked against the
CORS headers instead.

See:
 - whatwg/fetch#985
 - w3c/ServiceWorker#1490

Bug:1031542
Change-Id: I94a2cb9435fcf3e76f57a8f3d3344c87fa23f9a9
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 20, 2019
Document using:
"Cross-Origin-Embedder-Policy: require-corp"
must not access cross-origin response that do not have the header:
"Cross-Origin-Resource-Policy: cross-site"

This is about only no-cors requests. CORS requests are checked against the
CORS headers instead.

See:
 - whatwg/fetch#985
 - w3c/ServiceWorker#1490

Bug: 1031542
Change-Id: I94a2cb9435fcf3e76f57a8f3d3344c87fa23f9a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1973913
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Reviewed-by: Ben Kelly <wanderview@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726782}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 20, 2019
Document using:
"Cross-Origin-Embedder-Policy: require-corp"
must not access cross-origin response that do not have the header:
"Cross-Origin-Resource-Policy: cross-site"

This is about only no-cors requests. CORS requests are checked against the
CORS headers instead.

See:
 - whatwg/fetch#985
 - w3c/ServiceWorker#1490

Bug: 1031542
Change-Id: I94a2cb9435fcf3e76f57a8f3d3344c87fa23f9a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1973913
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Reviewed-by: Ben Kelly <wanderview@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726782}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jan 3, 2020
…estonly

Automatic update from web-platform-tests
COEP: Enforce CORP in cache.match()

Document using:
"Cross-Origin-Embedder-Policy: require-corp"
must not access cross-origin response that do not have the header:
"Cross-Origin-Resource-Policy: cross-site"

This is about only no-cors requests. CORS requests are checked against the
CORS headers instead.

See:
 - whatwg/fetch#985
 - w3c/ServiceWorker#1490

Bug: 1031542
Change-Id: I94a2cb9435fcf3e76f57a8f3d3344c87fa23f9a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1973913
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Reviewed-by: Ben Kelly <wanderview@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726782}

--

wpt-commits: 236e6dbc70e128ab5ff5bad6ab98888281df8ffd
wpt-pr: 20840
xeonchen pushed a commit to xeonchen/gecko that referenced this issue Jan 3, 2020
…estonly

Automatic update from web-platform-tests
COEP: Enforce CORP in cache.match()

Document using:
"Cross-Origin-Embedder-Policy: require-corp"
must not access cross-origin response that do not have the header:
"Cross-Origin-Resource-Policy: cross-site"

This is about only no-cors requests. CORS requests are checked against the
CORS headers instead.

See:
 - whatwg/fetch#985
 - w3c/ServiceWorker#1490

Bug: 1031542
Change-Id: I94a2cb9435fcf3e76f57a8f3d3344c87fa23f9a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1973913
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Reviewed-by: Ben Kelly <wanderview@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726782}

--

wpt-commits: 236e6dbc70e128ab5ff5bad6ab98888281df8ffd
wpt-pr: 20840
@annevk
Copy link
Member

annevk commented Jan 10, 2020

I think I'd prefer a TypeError, similar to what fetch() would return for a network error.

annevk added a commit to web-platform-tests/wpt that referenced this issue Feb 18, 2020
TypeError is more consistent with the overall API.

See w3c/ServiceWorker#1490 (comment).
annevk added a commit to web-platform-tests/wpt that referenced this issue Feb 19, 2020
TypeError is more consistent with the overall API.

See w3c/ServiceWorker#1490 (comment).
xeonchen pushed a commit to xeonchen/gecko that referenced this issue Feb 24, 2020
…testonly

Automatic update from web-platform-tests
COEP: change cache.match() exception

TypeError is more consistent with the overall API.

See w3c/ServiceWorker#1490 (comment).

--

wpt-commits: 7feb47d66b5197715742d0aaff8c9cf0230b8cd1
wpt-pr: 21856
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Feb 25, 2020
…testonly

Automatic update from web-platform-tests
COEP: change cache.match() exception

TypeError is more consistent with the overall API.

See w3c/ServiceWorker#1490 (comment).

--

wpt-commits: 7feb47d66b5197715742d0aaff8c9cf0230b8cd1
wpt-pr: 21856

UltraBlame original commit: 88d4932e7da4b199cd3761e286f9a6b25bac5f0f
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Feb 25, 2020
…testonly

Automatic update from web-platform-tests
COEP: change cache.match() exception

TypeError is more consistent with the overall API.

See w3c/ServiceWorker#1490 (comment).

--

wpt-commits: 7feb47d66b5197715742d0aaff8c9cf0230b8cd1
wpt-pr: 21856
@annevk
Copy link
Member

annevk commented Jun 2, 2020

@yutakahirano it doesn't seem this change is captured by https://wicg.github.io/cross-origin-embedder-policy/ at the moment. Where is this captured in specification text?

@yutakahirano
Copy link
Contributor

I'm making a service worker spec PR which includes the change.

@yutakahirano
Copy link
Contributor

#1516

domenic pushed a commit to whatwg/html that referenced this issue Jun 25, 2020
Merges https://github.com/WICG/cross-origin-embedder-policy into HTML.

Associated PRs:

* whatwg/fetch#1030
* w3c/ServiceWorker#1516
* w3c/css-houdini-drafts#992

Fixes #5368, fixes #5634, fixes
whatwg/fetch#985, and fixes
w3c/ServiceWorker#1490.

Follow-up: #4916, #4919, #4930 #5223, and #5391. (As well as defining
cross-origin isolated, per #4732.)
mfreed7 pushed a commit to mfreed7/html that referenced this issue Sep 11, 2020
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 7, 2021
Add tentative WPT tests about COEP and CacheStorage.

Issues:
- COEP:require-corp: w3c/ServiceWorker#1490
- COEP:credentialless: w3c/ServiceWorker#1592

Bug:1175099
Change-Id: I857adbd134443b17b9689c314307bb1e3888235b
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 7, 2021
Add tentative WPT tests about COEP and CacheStorage.

Issues:
- COEP:require-corp: w3c/ServiceWorker#1490
- COEP:credentialless: w3c/ServiceWorker#1592

Bug:1175099
Change-Id: I857adbd134443b17b9689c314307bb1e3888235b
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 7, 2021
Add tentative WPT tests about COEP and CacheStorage.

Issues:
- COEP:require-corp: w3c/ServiceWorker#1490
- COEP:credentialless: w3c/ServiceWorker#1592

Bug: 1175099
Change-Id: I857adbd134443b17b9689c314307bb1e3888235b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2876191
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Antonio Sartori <antoniosartori@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#880447}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 7, 2021
Add tentative WPT tests about COEP and CacheStorage.

Issues:
- COEP:require-corp: w3c/ServiceWorker#1490
- COEP:credentialless: w3c/ServiceWorker#1592

Bug: 1175099
Change-Id: I857adbd134443b17b9689c314307bb1e3888235b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2876191
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Antonio Sartori <antoniosartori@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#880447}
pull bot pushed a commit to Mu-L/chromium that referenced this issue May 8, 2021
Add tentative WPT tests about COEP and CacheStorage.

Issues:
- COEP:require-corp: w3c/ServiceWorker#1490
- COEP:credentialless: w3c/ServiceWorker#1592

Bug: 1175099
Change-Id: I857adbd134443b17b9689c314307bb1e3888235b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2876191
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Antonio Sartori <antoniosartori@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#880447}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 9, 2021
…a=testonly

Automatic update from web-platform-tests
[Credentialless]: WPT vs CacheStorage.

Add tentative WPT tests about COEP and CacheStorage.

Issues:
- COEP:require-corp: w3c/ServiceWorker#1490
- COEP:credentialless: w3c/ServiceWorker#1592

Bug: 1175099
Change-Id: I857adbd134443b17b9689c314307bb1e3888235b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2876191
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Antonio Sartori <antoniosartori@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#880447}

--

wpt-commits: 6bf109f244a20f48bb8723663c384e1e2220f006
wpt-pr: 28891
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this issue Oct 14, 2022
Add tentative WPT tests about COEP and CacheStorage.

Issues:
- COEP:require-corp: w3c/ServiceWorker#1490
- COEP:credentialless: w3c/ServiceWorker#1592

Bug: 1175099
Change-Id: I857adbd134443b17b9689c314307bb1e3888235b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2876191
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Antonio Sartori <antoniosartori@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#880447}
NOKEYCHECK=True
GitOrigin-RevId: a07d25f92a3402c5d4b27014b353bff565873ddb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants