-
Notifications
You must be signed in to change notification settings - Fork 16
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
"origin's origin policy" seems like a bad spec primitive #73
Comments
I suspect you need both mitigations as sometimes the policy is relevant before you have constructed a global to consult (e.g., navigation, cross-origin subresource). Also, given how this will use the "cache key" (or whatever we'll end up calling it) using the origin alone is wrong as it suggests a much wider scope than it has. |
Hmm yeah, since we are keying that off of fetch clients, then all of the current null-client fetches are probably not correct... that's not good. I'll open a new fetch issue to discuss... Edit: In the process of writing up a new fetch issue I realized the solution is actually relatively simple. I just need to pass the request's client from Fetch and re-use that when fetching origin policies. I will open a new issue to track fixing that so that this one can stay focused on the "origin's origin policy" problem. |
Sanity check please: when creating the initial |
Yeah, you'll also need to consider blob: URLs, data: URLs, javascript: URLs, etc. that also inherit. See some of the tests I recently landed for COOP/COEP (beware, some of them still use templates). And maybe also some of the open issues. In particular for blob: URLs there's some agreement on a better design in that the policy would be copied at |
I think I can mostly piggyback on the existing feature policy/CSP/etc. infrastructure. It was just a question as to which parts I do so. E.g. FP hooks in to both "create a new browsing context" and "initialize a new Document object". I have a patch locally that does so for FP-via-OP as well. CSP is a bit more complicated because: (1) it seems to ignore "create a new browsing context", but I think I convinced myself that was on purpose; (2) it also checks a response against itsself, which we probably want to get in on for CSP-via-OP, and thus we need to hook in earlier in the pipeline. The cleanest solution for CSP (which also matches our current implementation) might involve something very early in the pipeline that modifies the response to have both header-CSP and OP-CSP, so that they are treated equally. We'll see. |
Previously, the Fetch integration would "update" the origin's origin policy, i.e. make sure the version in the cache was updated. Then the various integration points (so far, CSP and FP) would grab the origin policy from the cache. This architecture is fragile (see discussion in #73) and does not match how implementations would reasonably work. This new version stores the origin policy on the response, and then uses that when constructing CSP and FP from the response. Fixes #73.
Previously, the Fetch integration would "update" the origin's origin policy, i.e. make sure the version in the cache was updated. Then the various integration points (so far, CSP and FP) would grab the origin policy from the cache. This architecture is fragile (see discussion in #73) and does not match how implementations would reasonably work. This new version stores the origin policy on the response, and then uses that when constructing CSP and FP from the response. Fixes #73.
A bit late here, but yes, for feature policy at least, we always apply the parent's policy (modulo any container policy) to an about:blank child, as well as data:, blob:, srcdoc etc. URLs. Document policy should do the same. Feature policy hooks in to two places in HTML, since the container policy is defined on the browsing context: once when the browsing context is created, and there is no response yet, and then again when the document is initialized, and we have the response headers. CSP (without CSPEE, at least) may not need the first one if it is strictly scoped to single documents. |
Thanks @clelland! I think the current spec (after merging #80) manages to get most of the right FP behavior "for free" by hooking in around the same place HTTP headers do, when responses are being processed. See https://wicg.github.io/origin-policy/#monkeypatch-fp, and please holler if anything looks wrong. |
The current spec says in https://wicg.github.io/origin-policy/#origin-origin-policy
and then the way that anyone (e.g., the CSP or FP spec) is supposed to use origin policy, is by consulting that definition. E.g. in https://wicg.github.io/origin-policy/#monkeypatch-fp it is consulted by
Now, this particular example works, because it makes a copy, at a point in the request lifecycle which reasonably makes sense. But the general idea of there being an ambient "origin's origin policy" which anyone could grab, synchronously, from specs, is not a good one.
For example, consider if we tried to define #48 using this. It'd be something like
This would (kind of, modulo frozen-array weirdness) imply that, if the cache entry for
/.well-known/origin-policy
expires, we'd start returning a different value. Whereas what we really want is to snapshot the IDs at some startup time (Window
creation time, I think?) and return the same ones forevermore.In summary, it's possible to use "origin's origin policy" correctly, but it's way too easy to use it incorrectly.
Potential mitigations:
Probably the second is more aligned with implementation architecture.
Relatedly, it's not obvious from the spec right now that cached origin policies apply even when no origin-policy header is present. Consulting them is hidden inside the CSP/FP monkeypatches. That would be more obvious if there were such an explicit copying point.
The text was updated successfully, but these errors were encountered: