Skip to content

Conversation

domenic
Copy link
Member

@domenic domenic commented Jun 19, 2020

This supersedes the definition in
https://w3c.github.io/webappsec-secure-contexts/, and fixes several bugs
while doing so.

Closes #5558. Closes w3c/webappsec-secure-contexts#56. Closes
w3c/webappsec-secure-contexts#57. Closes
w3c/webappsec-secure-contexts#74. Closes
w3c/webappsec-secure-contexts#75.

Notes/things to discuss:

  • I didn't check the HTTPS state because Secure Contexts integration #5558 didn't mention it. Should I?
  • I think the Secure Context's many definitions are confusing. You can talk about an environment settings object in three ways: "Is settings object contextually secure?", "settings object is contextually secure", and "settings object is a secure context". I only surfaced the last one, although I added data-lt="" to preserve autolinks the first one. I can't figure out how to preserve autolinks to the middle one as it would require a data-dfn-for="", which would break the other two. /cc @tabatkins
  • I also did not bother defining "secure context" for globals. It seems easy enough to grab their relevant settings object. (Note that no autolinks will break since the Secure Context spec only has one definition.)
  • I moved isSecureContext here since that is mentioned as an open item in https://w3c.github.io/webappsec-secure-contexts/#monkey-patching-global-object
  • I was planning to send a PR to update the Secure Context spec to point to this (while preserving existing IDs), but given how many open PRs on it have been sitting with no response, I'm feeling discouraged. (And I'd want to wait for at least Meta: no more fork of WHATWG HTML w3c/webappsec-secure-contexts#76 to land before doing mine.) /cc @mikewest

/browsing-the-web.html ( diff )
/infrastructure.html ( diff )
/origin.html ( diff )
/parsing.html ( diff )
/webappapis.html ( diff )
/workers.html ( diff )

@domenic domenic added the security/privacy There are security or privacy implications label Jun 19, 2020
@domenic domenic requested a review from annevk June 19, 2020 19:20
Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I was thinking of is renaming the internal concept to "secure environment" to more accurately capture what it is about.

source Outdated

<ol>
<li>
<p>If <var>environment</var> is an <span>environment settings object</span>, and its <span
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for a comma.

@annevk
Copy link
Member

annevk commented Jun 24, 2020

Hmm, I guess HTTPS state should be checked although there's only a single implementation who cares about "deprecated" at the moment and that's Chrome. But that seems fairly easy to add. An environment is not a secure context if its HTTPS state is "deprecated".

We might also want to expose the API in worklets at some point, but I guess we can wait until there are requests and we wouldn't want to use this PR to add new features anyway.

@domenic
Copy link
Member Author

domenic commented Jun 24, 2020

OK, force-pushed a new commit that takes into account HTTPS state (which led to some algorithm restructuring), and also a separate commit on top of this which uses the resulting definition for COOP.

@domenic
Copy link
Member Author

domenic commented Jun 24, 2020

One thing I was thinking of is renaming the internal concept to "secure environment" to more accurately capture what it is about.

I agree that would have been a better name from the beginning, but the current terminology is so deeply embedded in how we talk about security on the web, I'd rather not shift things now.

@domenic domenic requested a review from annevk June 24, 2020 18:05
@annevk
Copy link
Member

annevk commented Jun 25, 2020

  1. For workers I think we technically only have to check owner set[0] as they are either all a secure context or not due to the way we allocate shared workers. Otherwise secure context could change over time which should not be the case. So perhaps we should make that explicit somehow.
  2. This would still apply COOP if HTTPS state of the response is "deprecated" as you're not checking the response, only the reserved environment.

domenic added 2 commits June 25, 2020 13:18
Fixes #5669. This also fixes existing mismatched parameter passing to
the "obtain a cross-origin opener policy" algorithm.
@domenic
Copy link
Member Author

domenic commented Jun 25, 2020

Alright, force-pushed to update both commits to address those points. PTAL!

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we get many things like COOP we might need another abstraction layer, but hopefully we don't. Ideally @mikewest would look at this, but I haven't been able to get in touch either...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
security/privacy There are security or privacy implications
Development

Successfully merging this pull request may close these issues.

Secure Contexts integration "Is an environment settings object contextually secure?" does not deal with nested workers
2 participants