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

Secure Contexts and Cross-Origin-Embedder-Policy #4930

Closed
annevk opened this issue Sep 23, 2019 · 24 comments
Closed

Secure Contexts and Cross-Origin-Embedder-Policy #4930

annevk opened this issue Sep 23, 2019 · 24 comments
Assignees
Labels
topic: cross-origin-embedder-policy Issues and ideas around the new "require CORP for subresource requests and frames and etc" proposal.

Comments

@annevk
Copy link
Member

annevk commented Sep 23, 2019

Related to #4921 by @shhnjk, @mystor pointed out that in addition to computing the origin way before we are ready to create a document, we also need to have the secure context state way before we are ready to have a settings object. This is particularly relevant for Cross-Origin-Embedder-Policy, which can work in a framed context, provided that frame is a secure context.

cc @mikewest

@annevk annevk added the topic: cross-origin-embedder-policy Issues and ideas around the new "require CORP for subresource requests and frames and etc" proposal. label Sep 23, 2019
yutakahirano added a commit to web-platform-tests/wpt that referenced this issue May 27, 2020
@domenic domenic mentioned this issue May 29, 2020
3 tasks
pull bot pushed a commit to Yannic/chromium that referenced this issue Jun 5, 2020
whatwg/html#4930 (We don't have a spec text
yet).

Bug: 1086066
Change-Id: I0d51df12af686dc4f1bbad252e02f9bf64981b56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216833
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775421}
domenic pushed a commit 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.)
@yutakahirano
Copy link
Member

We can check whether the url of the response is trustworthy. We can also check if the environment settings object is (or, will be) contextually secure. Which do you prefer?

Chrome implements the former.

@annevk
Copy link
Member Author

annevk commented Jun 29, 2020

@yutakahirano I suspect we want to emulate the COOP check which checks both the URL and response's HTTP state (in case it's deprecated). (And perhaps we want to abstract it to make it clear they share the same logic.)

@yutakahirano
Copy link
Member

Something like this?

  • A response response is called trustworthy when
    1. response's URL's scheme is 'https', and response's URL is trustworthy, and response's HTTPS state is 'modern', or
    2. response's URL's scheme is not 'https', and response's URL is trustworthy.
  • To obtain a cross-origin opener policy given a response response and an environment reservedEnvironment:
    1. If reservedEnvironment is a non-secure context, then return "unsafe-none".
    2. If response is not trustworthy, then return "unsafe-none".
    3. ...
  • To obtain an embedder policy from a response response:
    1. If response is not trustworthy, then return "unsafe-none".
    2. ...

@annevk
Copy link
Member Author

annevk commented Jun 29, 2020

Hmm, I see the dilemma. COEP doesn't always have an environment settings object at hand currently. I would suggest we try to find one though and use that to decide. Basing it solely on the response would seem to miss some cross-window-named targeting scenarios, although maybe they are ruled out and that's unclear due to #313?

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jun 30, 2020
 - platform/mac-mac10.13/.../require-corp-about-blank-expected.txt
   is redundant - it's same as the base expectation.
 - platform/mac-mac10.14/.../require-corp-about-blank-expected.txt
   is wrong - the test always fails on the platform (and the failures
   are suppressed by TestExpectations).
 - wpt/html/coep/require-corp-about-blank.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-blank.https.html
 - wpt/html/coep/require-corp-about-srcdoc.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-srcdoc.https.html
 - Remove redundant TestExpectations entries.

Bug: 1086065, 626703
Change-Id: I5573dd4446f482acdde828404e0a88893897ce09
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jun 30, 2020
 - platform/mac-mac10.13/.../require-corp-about-blank-expected.txt
   is redundant - it's same as the base expectation.
 - platform/mac-mac10.14/.../require-corp-about-blank-expected.txt
   is wrong - the test always fails on the platform (and the failures
   are suppressed by TestExpectations).
 - wpt/html/coep/require-corp-about-blank.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-blank.https.html
 - wpt/html/coep/require-corp-about-srcdoc.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-srcdoc.https.html
 - Remove redundant TestExpectations entries.

Bug: 1086065, 626703
Change-Id: I5573dd4446f482acdde828404e0a88893897ce09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274133
Auto-Submit: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Makoto Shimazu <shimazu@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783875}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jun 30, 2020
 - platform/mac-mac10.13/.../require-corp-about-blank-expected.txt
   is redundant - it's same as the base expectation.
 - platform/mac-mac10.14/.../require-corp-about-blank-expected.txt
   is wrong - the test always fails on the platform (and the failures
   are suppressed by TestExpectations).
 - wpt/html/coep/require-corp-about-blank.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-blank.https.html
 - wpt/html/coep/require-corp-about-srcdoc.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-srcdoc.https.html
 - Remove redundant TestExpectations entries.

Bug: 1086065, 626703
Change-Id: I5573dd4446f482acdde828404e0a88893897ce09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274133
Auto-Submit: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Makoto Shimazu <shimazu@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783875}
pull bot pushed a commit to Alan-love/chromium that referenced this issue Jun 30, 2020
 - platform/mac-mac10.13/.../require-corp-about-blank-expected.txt
   is redundant - it's same as the base expectation.
 - platform/mac-mac10.14/.../require-corp-about-blank-expected.txt
   is wrong - the test always fails on the platform (and the failures
   are suppressed by TestExpectations).
 - wpt/html/coep/require-corp-about-blank.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-blank.https.html
 - wpt/html/coep/require-corp-about-srcdoc.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-srcdoc.https.html
 - Remove redundant TestExpectations entries.

Bug: 1086065, 626703
Change-Id: I5573dd4446f482acdde828404e0a88893897ce09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274133
Auto-Submit: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Makoto Shimazu <shimazu@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783875}
@yutakahirano
Copy link
Member

The TrustedType bypass problem discussed at w3c/trusted-types#259 is pretty interesting. COEP would have the same problem, and I think it's good to rely only on the response, not the parent contexts.

@annevk
Copy link
Member Author

annevk commented Jul 3, 2020

Could you elaborate?

@yutakahirano
Copy link
Member

When a frame asserts COEP: require-corp, it requires COEP and CORP for nested frames. Breaking that expectation when the frame is embedded in an (unencrypted) HTTP frame is confusing I think.

@annevk
Copy link
Member Author

annevk commented Jul 3, 2020

I'm not sure, allowing yourself to be embedded in that way is insecure so I'm not sure we have to cater to it. frame-ancestors can be used to prevent that from happening, though it might be somewhat neater if you could still allow localhost somehow.

@yutakahirano
Copy link
Member

Do you mean frame-ancestors: https:? That doesn't work because it is possible for http://malicious/ to embed https://malicious/ which embeds https://victim/.

@yutakahirano
Copy link
Member

Ah sorry I misunderstood frame-ancestors. It's checked for every ancestor. https://w3c.github.io/webappsec-csp/#frame-ancestors-navigation-response

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jul 3, 2020
…ank,srcdoc}.html, a=testonly

Automatic update from web-platform-tests
Fix wpt/html/coep/require-corp-about-{blank,srcdoc}.html

 - platform/mac-mac10.13/.../require-corp-about-blank-expected.txt
   is redundant - it's same as the base expectation.
 - platform/mac-mac10.14/.../require-corp-about-blank-expected.txt
   is wrong - the test always fails on the platform (and the failures
   are suppressed by TestExpectations).
 - wpt/html/coep/require-corp-about-blank.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-blank.https.html
 - wpt/html/coep/require-corp-about-srcdoc.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-srcdoc.https.html
 - Remove redundant TestExpectations entries.

Bug: 1086065, 626703
Change-Id: I5573dd4446f482acdde828404e0a88893897ce09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274133
Auto-Submit: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Makoto Shimazu <shimazu@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783875}

--

wpt-commits: f911e6744606f48835f3296fab56e40d8185121c
wpt-pr: 24392
xeonchen pushed a commit to xeonchen/gecko that referenced this issue Jul 6, 2020
…ank,srcdoc}.html, a=testonly

Automatic update from web-platform-tests
Fix wpt/html/coep/require-corp-about-{blank,srcdoc}.html

 - platform/mac-mac10.13/.../require-corp-about-blank-expected.txt
   is redundant - it's same as the base expectation.
 - platform/mac-mac10.14/.../require-corp-about-blank-expected.txt
   is wrong - the test always fails on the platform (and the failures
   are suppressed by TestExpectations).
 - wpt/html/coep/require-corp-about-blank.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-blank.https.html
 - wpt/html/coep/require-corp-about-srcdoc.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-srcdoc.https.html
 - Remove redundant TestExpectations entries.

Bug: 1086065, 626703
Change-Id: I5573dd4446f482acdde828404e0a88893897ce09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274133
Auto-Submit: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Makoto Shimazu <shimazu@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783875}

--

wpt-commits: f911e6744606f48835f3296fab56e40d8185121c
wpt-pr: 24392
@yutakahirano
Copy link
Member

Hmm, I see the dilemma. COEP doesn't always have an environment settings object at hand currently. I would suggest we try to find one though and use that to decide. Basing it solely on the response would seem to miss some cross-window-named targeting scenarios, although maybe they are ruled out and that's unclear due to #313?

Can we use request's reserved client? We don't have it for service workers but it is not a problem.

@annevk
Copy link
Member Author

annevk commented Jul 14, 2020

I think we have to use that for top-level. For nested we can just look at the parent.

@yutakahirano
Copy link
Member

Currently https://html.spec.whatwg.org/multipage/webappapis.html#secure-context doesn't check if parent is a secure context for documents, and giving the parent environment just checks one-level. We want to check it recursively, right?

@annevk
Copy link
Member Author

annevk commented Jul 14, 2020

No, that algorithm is fine. No need for recursion. The problem is that a reserved client won't have an HTTPS state so you'd have to check that manually. That's why a "full" environment settings object is preferable.

@yutakahirano
Copy link
Member

Let's assume we have nested documents D1, D2 and D3. D1 is the parent of D2, D2 is the parent of D3. All have COEP: require-corp HTTP header.

D1: http://www.example.com/D1
D2: https://www.example.com/D2
D3: https://www.example.com/D3

D1 is not a secure context, so the COEP value is unsafe-none.
D2 is got from secure transport but its parent is not a secure context so the COEP value is unsafe-none, but D2 itself is a secure context.
D3 is got from secure transport and its parent is secure context so the COEP value is require-corp, and D3 itself is a secure context.

Is this behavior expected?

@annevk
Copy link
Member Author

annevk commented Jul 14, 2020

How would D2 end up being a secure context? (Note how it uses "top-level creation URL".)

@yutakahirano
Copy link
Member

Oh thanks you're right, but we still can create a similar example I think.

D1: https://www.example.com/D1 (HTTPS state is "deprecated")
D2: https://www.example.com/D2 (HTTPS state is "modern")
D3: https://www.example.com/D3 (HTTPS state is "modern")

@annevk
Copy link
Member Author

annevk commented Jul 14, 2020

That seems like something we overlooked in #5659, indeed.

There's a deeper issue with HTTPS state though in that an embedded document could have it set to "deprecated", but the top-level document would still be considered a secure context. Perhaps that's not something that should impact secure contexts to begin with. Only Chrome implements it so it's not even clear if it carries its weight standards-wise.

@yutakahirano
Copy link
Member

yutakahirano commented Jul 14, 2020

IIUC your intention is to enable COEP settings only for environments that will be secure contexts, right?

Then I think giving the parent context is confusing because parent's URL and parent's HTTPS state is not taken into account for document's secure context calculation.

Does it make sense to split https://html.spec.whatwg.org/multipage/webappapis.html#secure-context to two algorithms, one[A] takes an environment settings object, another[B] takes an environment and a response?

I'm considering migrating existing callers to [A] by default, and migrating the COOP use-case to [B]. COEP will use [B] for documents. It may make sense for COEP to use [A] for dedicated workers.

@annevk
Copy link
Member Author

annevk commented Jul 14, 2020

I guess it really depends on whether Chrome wants to keep around HTTPS state for secure contexts as it can lead to cases where the document tree is not consistent secure-context-wise.

@yutakahirano
Copy link
Member

@domenic @mikewest Do you have opinions? I don't know who has strong opinions on this topic...

@domenic
Copy link
Member

domenic commented Jul 14, 2020

I don't have an opinion, sorry to say; I just carried over HTTPS state from previous revisions of the secure context definition. I've also not had any success in getting @mikewest's help with secure context stuff. Maybe we should put a meeting on his calendar.

@zcorpan
Copy link
Member

zcorpan commented Jan 18, 2021

If/when this is fixed, html/cross-origin-embedder-policy/shared-workers.html introduced in web-platform-tests/wpt#20899 should be renamed to shared-workers.https.html

@annevk
Copy link
Member Author

annevk commented Jan 18, 2021

This has been fixed as HTTPS state is gone so secure contexts is now based purely on the URL.

@annevk annevk closed this as completed Jan 18, 2021
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this issue Oct 14, 2022
whatwg/html#4930 (We don't have a spec text
yet).

Bug: 1086066
Change-Id: I0d51df12af686dc4f1bbad252e02f9bf64981b56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216833
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#775421}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 6585711c62108312c5a411fad351e495ff7bbcab
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this issue Oct 14, 2022
 - platform/mac-mac10.13/.../require-corp-about-blank-expected.txt
   is redundant - it's same as the base expectation.
 - platform/mac-mac10.14/.../require-corp-about-blank-expected.txt
   is wrong - the test always fails on the platform (and the failures
   are suppressed by TestExpectations).
 - wpt/html/coep/require-corp-about-blank.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-blank.https.html
 - wpt/html/coep/require-corp-about-srcdoc.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-srcdoc.https.html
 - Remove redundant TestExpectations entries.

Bug: 1086065, 626703
Change-Id: I5573dd4446f482acdde828404e0a88893897ce09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274133
Auto-Submit: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Makoto Shimazu <shimazu@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#783875}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 34c0036a47c782ddd4528a37a25394f7acfd8939
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this issue Jun 1, 2024
…ank,srcdoc}.html, a=testonly

Automatic update from web-platform-tests
Fix wpt/html/coep/require-corp-about-{blank,srcdoc}.html

 - platform/mac-mac10.13/.../require-corp-about-blank-expected.txt
   is redundant - it's same as the base expectation.
 - platform/mac-mac10.14/.../require-corp-about-blank-expected.txt
   is wrong - the test always fails on the platform (and the failures
   are suppressed by TestExpectations).
 - wpt/html/coep/require-corp-about-blank.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-blank.https.html
 - wpt/html/coep/require-corp-about-srcdoc.html always fails because
   COEP is only effective on secure contexts
   (whatwg/html#4930). Rename it to
   wpt/html/coep/require-corp-about-srcdoc.https.html
 - Remove redundant TestExpectations entries.

Bug: 1086065, 626703
Change-Id: I5573dd4446f482acdde828404e0a88893897ce09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274133
Auto-Submit: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Makoto Shimazu <shimazu@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783875}

--

wpt-commits: f911e6744606f48835f3296fab56e40d8185121c
wpt-pr: 24392
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: cross-origin-embedder-policy Issues and ideas around the new "require CORP for subresource requests and frames and etc" proposal.
Development

No branches or pull requests

4 participants