-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add unsafe-inherit
as a value for the Cross-Origin Opener Policy
#4581
Comments
Overall this makes sense, but I wonder if this would require other nuanced changes. E.g., currently |
Thinking about this some more, I wonder if instead we can make this a different keyword from |
Minor nit: since we already have unsafe-allow-outgoing, why not call this unsafe-allow-incoming? This would, in fact, allow openees to be opened in someone else's context, which is the reciprocal action of allowing yourself to bring someone else in your context (u-a-o). |
I think the one problem with that is that this is not only |
One issue @mystor raised that is good to keep in mind is that this proposal requires remembering the final computed state in session history. That is, in
it would be bad if 5 was not true I think. |
Thinking about this even more, I wonder if we could make 'unsafe-inherit' the default mode, i.e. have the lack of a COOP header imply the behavior we're talking about here (keeping the browsing context for same-origin / same-site navigations depending on the COOP value of the opener page). A negative consequence of this model is that there would be "action at a distance", i.e. a page could exhibit different behavior depending on whether the user arrived on it from a page with COOP or not. Requiring developers to explicitly set The upside is that this seems easier to deploy -- not setting COOP on some documents would still result in expected behavior, i.e. same-origin navigations/popups which open that document would retain the existing browsing context group, rather than creating a new one. It also seems to not poke holes in the security model because all navigations outside of the scope defined in the original COOP (same-origin or same-site) would result in a new browsing group. The one exception is if the original page sets COOP with unsafe-allow-outgoing, which would now make cross-site links from same-origin-no-COOP pages open in the same browsing context, but this seems like a minor issue (and we could make unsafe-allow-outgoing not inherit if need be). Do you have any thoughts about this @annevk? |
I would like to understand your final example better:
How would this not replace the popup browsing context? |
In your example, if we open a second popup from the document with the inherited COOP, then that popup will be in the same browsing context group because of So, previously, if some parts of your origin set COOP with I have to say that I'm skeptical about this being a meaningful security risk, because it applies only in cases where an application uses |
It will be in the same browsing context group, but that would also happen without inheritance (because then the unsafe popup would lack a policy). So I don't think that's a novel angle? Also, if a victim resource does not set COOP, an attacker could also open it into a popup or (unless protected) a frame (see also XSLeaks). |
You're right, the concern I described for I think there is still an issue with inheritance, but it's different:
Previously, the popup would be in a different browsing context group because of a same-origin navigation to a no-COOP document. With inheritance, the same-origin popup will be put in the same browsing context group and its frame will get access to the opener. It's hard to say how realistic this is (the scenario seems somewhat contrived), so the main question is whether the adoption benefits would outweigh this concern. |
I think I agree that implicit copying of the policy is probably better. We can add another value (e.g., |
What we did not explicitly consider is that inheriting by default might give complications if a document is unsure about its "outgoing" links. That is, if A1 adopts COOP and A2 does not and A2 needs to load B in a popup and A1 sometimes loads A2 in a popup, it depends on whether or not A1 specifies unsafe-allow-outgoing whether A2 is going to function. So therefore, explicit inheritance might be better:
A variant not in the above table is the combination of |
cross-origin
as a value for the Cross-Origin Opener Policyunsafe-inherit
as a value for the Cross-Origin Opener Policy
The COOP processing model has support for |
Back in #4581 (comment) @annevk mentions a conversaion with me which relates to session history. I think my mind might have changed on what behaviour we should take there. I originally thought we needed to store the inherited COOP state inside of session history, so that when going back in history it would act the same. This would be needed to make the behaviour when the document is in the BFCache match the behaviour when it is not better. I'm not convinced that this is the right decision, given that the behaviour of loading something out of history is already poorly defined, and can be quite different depending on what has happened, including history being truncated, surviving across browser restarts, and being evicted from the cache. It seems like it might be much simpler to not store this information, and consider loads from history to, if the document isn't bfcached, be effectively a new fetch from the network, inheriting from the new context it is loading in. I'm not super attached to this, but I'm not sure that storing this extra information in session history is worthwhile, especially considering how underspecified history is right now. 🤷♀️ |
Given that this is already in the test suite and part of the processing model I'm going to close this, but see #5044 for some follow-up work regarding this feature. |
The problem
While working on a COOP deployment strategy across our apps we came across a potential issue which might be common enough to warrant supporting at the spec level. The situation is as follows:
Cross-Origin-Opener-Policy: same-origin
for all of its responses.It seems useful for developers to be able to exempt parts of their site from COOP enforcement to enable incremental rollouts.
A possible solution
I believe we could solve this by adding a new value of
unsafe-inherit
to COOP. When a document setsCross-Origin-Opener-Policy: unsafe-inherit
it would elect to be put into the browsing context group of the opening document, assuming the opening document's own COOP doesn't prevent this.That is:
COOP: unsafe-inherit
then the popup would end up in its browsing context group and the documents can communicate.COOP: unsafe-inherit
, then:same-origin
/same-site
, the documents would be in the same browsing context group.unsafe-allow-outgoing
.This would allow sites like OAuth providers set
COOP: unsafe-inherit
on documents which need to be accessible by cross-origin windows while using a stricter COOP elsewhere in the same origin/site.Similarly to CORP this could also provide a path to setting COOP restrictions by default sometime in the future by allowing developers with resources which need to be accessed cross-origin with a way to opt out of the restrictions.
Note: The original text of this issue referred to this mode as
cross-origin
instead ofunsafe-inherit
and references tocross-origin
still remain in some of the discussion below.@mikewest @annevk @empijei @csreis @lweichselbaum
The text was updated successfully, but these errors were encountered: