Skip to content

Add the Origin-Isolation header - #5545

Merged
domenic merged 2 commits into
masterfrom
origin-isolation
Aug 21, 2020
Merged

domenic merged 2 commits into
masterfrom
origin-isolation

Conversation

@domenic

@domenic domenic commented May 14, 2020 •

Copy link
Copy Markdown
Member

See https://github.com/WICG/origin-isolation.

(See WHATWG Working Mode: Changes for more details.)

(Obsolete) Things that I needed help on but are now fixed:
  • This has a similar problem as Add cross-origin opener policy #5334 in that it wants to do a secure context check before the environment settings object/Window/Document are created. It seems like we'll need to refactor the secure contexts spec a good bit, for both of them... But I'd like someone to confirm that line of thinking before I go off and do so. /cc @mikewest

  • I'm not sure if changing the agent cluster key automatically makes document.domain a no-op, or not. I think by my current reading, IsPlatformObjectSameOrigin does not care about agent clusters, so this PR as-written does not prevent cross-agent-cluster sync access. Should we add an agent cluster check to IsPlatformObjectSameOrigin, and let the domain component change via the document.domain setter? Or should we store an "is origin-isolated" boolean on the Document, and bail out of the document.domain setter algorithm if that boolean is true? The former seems a bit nicer, but I'm unsure if there's any observable difference between the two. /cc @dtapuska


/browsers.html ( diff )
/browsing-the-web.html ( diff )
/iana.html ( diff )
/index.html ( diff )
/infrastructure.html ( diff )
/origin.html ( diff )
/webappapis.html ( diff )
/window-object.html ( diff )

@domenic domenic added topic: navigation Navigating documents, the Location interface, window.open() and fragment navigation topic: origin Origins, sites, same origin and same site, opaque origins and document.domain topic: agent JavaScript agents and agent clusters, and how documents and workers are grouped into them labels May 14, 2020
@domenic

domenic commented May 14, 2020

Copy link
Copy Markdown
Member Author

Hmm, I think there is a big difference between just changing IsPlatformObjectSameOrigin, and storing a boolean on the document. If we only change IsPlatformObjectSameOrigin, then other same origin-domain checks will still pass. So I think we need to store a boolean, and also write tests for other such checks.

@annevk

annevk commented May 17, 2020

Copy link
Copy Markdown
Member

I like the idea though that changing the keying of the agent cluster is what disables document.domain. Unfortunately there's no clear way back from an agent cluster to its key. Setting a flag on the agent cluster similar to cross-origin isolated is something you could do though. That also avoids having to maintain a per-document boolean.

@domenic

domenic commented May 17, 2020

Copy link
Copy Markdown
Member Author

Did you see my latest commit? I think with the historical agent cluster key map, there kind of effectively is such a way back now.

Comment thread source Outdated
data-x="concept-response-header-list">header list</span>.</p></li>

<li><p>Let <var>requestsOI</var> be true if <var>oiHeader</var> is not failure,
<var>oiHeader</var> is not null, and <var>oiHeader</var>[0] is the <span>structured header

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is oiHeader indexable as such?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

All structured header items are a pair of the actual value plus the parameters.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess Fetch should define how they translate to Infra then if we want to do this. Might also be nice for parameters.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think the concepts used are already Infra concepts: pairs, maps, booleans, ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Heh, if only they would have referenced it as well. But okay, that should make any formal equating pretty straightforward.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I noticed you still used "structured header boolean true". If they are the same we don't have to do that, right?

@annevk annevk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Most of this looks really good, but I think we should stick more to COOP+COEP design in a few places.

Comment thread source Resolved
Comment thread source Resolved
Comment thread source Outdated

<li><p>Let <var>requestsOI</var> be true if <var>oiHeader</var> is not failure,
<var>oiHeader</var> is not null, and <var>oiHeader</var>[0] is the <span>structured header
boolean</span> true.</p></li>

ghost Jun 16, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's too early, but I can't help but think we want an abstraction to make this less awkward and encourage consistency in handling. No great ideas other than collapsing failure into null though. (Or maybe that is what we should always do?)

ghost Jun 16, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I do suspect collapsing failure into null might be what all callers want. Perhaps let's reassess after this lands, COOP lands, COEP lands, and CORP gets converted to a structured header. (And maybe by then Permission Policy / Document Policy might be ready too.)

Comment thread source Resolved
Comment thread source Outdated

<p class="XXX"><a href="https://github.com/whatwg/html/pull/4734">Issue #4734</a> is expected to
further modify this algorithm to increase the number of cases where the returned value is an
<span>origin</span>.</p>

ghost Jun 16, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I prefer the approach in that PR by modifying "obtain a similar-origin window agent" and inlining "obtain an agent cluster key".

I also wonder, if we did that, could we modify browsing context group's historical agent cluster key map before invoking that algorithm so it could use that map to make decisions, requiring us to pass less state around?

Furthermore, now that we tie state to browsing context groups, it almost seems like we should have different types of them. Those that carry a historical map and those that are cross-origin isolated. But some asserts is probably enough initially.

ghost Jun 16, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

https://github.com/whatwg/html/pull/4734/files#r405428958 indicates we want to fold all three algorithms together. I'll give that a shot...

ghost Jun 16, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This turned out pretty nicely.

I didn't address your latest paragraph so I'll leave this un-resolved. If you have concrete suggestions (either for now or as a followup) then let me know; otherwise I wasn't sure where to go with it.

ghost Jun 17, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was mostly wondering if we should make normal browsing context groups and cross-origin isolated browsing context groups more clearly mutually exclusive. We can address it in the context of cross-origin isolated.

@annevk

ghost commented Jun 17, 2020

Copy link
Copy Markdown
Member

It's unfortunate PR Preview no longer seems to work here. I added a space to try to trigger it, but it's not working.

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Apart from the map issue I realized that another thing we need to agree on is how cross-origin isolated and origin-isolation restricted play together.

My initial take was that cross-origin isolated implies the latter, but this would do the wrong thing for things that are already keyed on origin. Perhaps we should revisit that as allowing those to be origin-isolation restricted despite it not meaning anything would simplify several things at this point?

Comment thread source Resolved
Comment thread source Outdated

<p class="XXX"><a href="https://github.com/whatwg/html/pull/4734">Issue #4734</a> is expected to
further modify this algorithm to increase the number of cases where the returned value is an
<span>origin</span>.</p>

ghost Jun 17, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was mostly wondering if we should make normal browsing context groups and cross-origin isolated browsing context groups more clearly mutually exclusive. We can address it in the context of cross-origin isolated.

@domenic

ghost commented Jun 17, 2020

Copy link
Copy Markdown
Member Author

My initial take was that cross-origin isolated implies the latter, but this would do the wrong thing for things that are already keyed on origin. Perhaps we should revisit that as allowing those to be origin-isolation restricted despite it not meaning anything would simplify several things at this point?

The way I was envisioning it was that cross-origin isolated just causes requestsOI to be true (regardless of the Origin-Isolation header). Then the logic in this PR takes over and oiRestricted (and thus window.originIsolationRestricted) will be false if you were already keyed to an origin. But window.crossOriginIsolated would be true.

WDYT?

@annevk

ghost commented Jun 17, 2020

Copy link
Copy Markdown
Member

That could work I think. We'd change

<li><var>requestsOI</var> is true</li>

to also check for bcg's cross-origin isolated and where we write into the map (TBD) we add another conditional to only do so if bcg's cross-origin isolated is false.

@domenic

ghost commented Jun 17, 2020

Copy link
Copy Markdown
Member Author

where we write into the map (TBD) we add another conditional to only do so if bcg's cross-origin isolated is false.

I don't think this would be strictly necessary, because cross-origin isolation ensures consistency within a BCG itself. So the map would just be redundant for any BCG with cross-origin isolated pages; writing to it would be fine (and have no effect).

I guess maybe that gets to your point above about making normal BCGs and COI BCGs mutually exclusive.

@annevk

ghost commented Jun 17, 2020

Copy link
Copy Markdown
Member

If we did that I think we'd have to add a note, but maybe we should do that either way. (Agreed that there is no observable difference.)

@domenic

ghost commented Jun 25, 2020

Copy link
Copy Markdown
Member Author

This now has a secure context check. It, like COOP, needed to check the response's HTTPS state, so maybe we should have an abstraction? There's no great one though, since reservedEnvironment and response are separate anyway. The best we could do is something like

If request and reservedEnvironment do not represent a new secure context, then...

although I think there should be better names.

Anyway, this is now blocked on WICG/origin-agent-cluster#31, I guess.

Base automatically changed from editorial-document-domain to master July 10, 2020 16:21
@domenic
domenic force-pushed the origin-isolation branch from 5202ca4 to c41ac69 Compare July 10, 2020 16:23
Comment thread source
</dd>
</dl>

<p>A <code>Document</code> delivered over a <span>secure context</span> can opt in to origin

ghost Jul 13, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

into? We only have two instances of "in to" and both look suspect.

ghost Jul 13, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread source Resolved
Comment thread source Resolved
Comment thread source
<li><p>Set <var>group</var>'s <span>historical agent cluster key map</span>[<var>origin</var>]
to <var>key</var>.</p></li>
</ol>
</li>

ghost Jul 13, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we change this whole addition to start with "Otherwise, if" we could keep the historical agent cluster key map and cross-origin isolated separated. I would somewhat prefer that as the less (unneeded) bookkeeping the better.

(It would also allow more easily for introducing different group types in the future.)

ghost Jul 13, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm, I'll give it a try.

Comment thread source Outdated
<var>group</var>'s <span>historical agent cluster key map</span>[<var>origin</var>].</p></li>

<li>
<p>Otherwise, if <var>requestsOI</var> is true, then:</p>

ghost Jul 14, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This part of the change is wrong. I initially read the algorithm like this, but that ends up making the map redundant as it would only ever contain origin values. The requestsOI conditional has to be part of overwriting the key only.

ghost Jul 14, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think I misunderstood what you meant by keeping them separate; PTAL.

ghost Jul 14, 2020 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This works, but I think what would also work (and is preferable) is keeping this as

Otherwise:

  • If requestsOI is true, set ...
  • Modify map.

My "Otherwise, if" comment was about the step above this one.

ghost Jul 14, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, thanks, that makes sense now. Done.

@domenic

ghost commented Aug 19, 2020

Copy link
Copy Markdown
Member Author

Alright, I've updated all the tests to use the standard window.originIsolated getter. And, the test suite is basically finished. (A couple PRs around popups are still going through review but they should land soon.) So, I'm now comfortable with this getting merged.

@annevk, want to do the final review?

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks great apart from these minor nits around initializing requestsOI. Nice work!

Comment thread source Resolved
Comment thread source Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: agent JavaScript agents and agent clusters, and how documents and workers are grouped into them topic: navigation Navigating documents, the Location interface, window.open() and fragment navigation topic: origin Origins, sites, same origin and same site, opaque origins and document.domain

Development

Successfully merging this pull request may close these issues.

2 participants