-
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
HTML's "navigate" algorithm should handle 'X-Frame-Options' and CSP's 'frame-ancestors' #1230
Comments
This should be pretty easy to add now. |
Poking at this today. For |
This introduces a new 'navigation check', which we'll need to wire up to HTML. That, in turn, requires HTML to use Fetch. WHATWG's does, W3C's does not (w3c/html#548).
The initial pass at whatwg/html#1230 was too simple. Let's complexify it up a little bit, shall we?
"Pretty easy to add", he says. Basically, we didn't think about this enough, and it's more subtle than I though, because we need the source browsing context's policy in some cases ( WDYT? |
One way to do form-action is to just hook it directly in form submission. And just navigate to a network error if it blocks. If it's specific to forms invoking navigate we might as well keep it there. The others remain complicated. |
Hooking directly into form submission wouldn't catch redirects, would it? I think we need to live in navigate for that to work. |
Good point. |
Are you waiting on me for this PR? (Sorry, I've been out for almost two weeks, so I'm trying to page this back in....) |
Yeah, the review comments are not addressed yet I thought. |
This will enable implementation of 'frame-ancestors' and 'form-action', and makes a bit of progress towards #1230.
Previous version. w3c/webappsec-csp@3c625fdc9fd9798da198ed449c47 fc46063fb902 whatwg/html#1230 landed. w3c/webappsec-csp@366e5de698015dedce7925c8ba05 c273f28bd3cb
Today @travisleithead discovered that Chrome does not support the ALLOW-FROM variant. Edge had strict parsing, which broke when it encountered a web site with If we do manage to get around to speccing this, so that nobody else runs into these sorts of interop issues while building their browsers, we'll need to figure out what to do with ALLOW-FROM. Probably also questions around whitespace trimming etc. So yeah, not just semantic issues, also syntactic ones :( |
This will enable implementation of 'frame-ancestors' and 'form-action', and makes a bit of progress towards whatwg#1230.
As mentioned in https://bugzilla.mozilla.org/show_bug.cgi?id=1599256 this should also define what kind of document does get loaded |
Last I checked, Chrome (and WebKit) loads an error page with an opaque origin ( |
Ah, I guess Chrome in general fires the |
Yes, that's my understanding of Chrome's (and WebKit's, I believe) behavior. We move network errors to an opaque-origin'd error page, and fire an |
This brings the spec closer to how it would look upon landing in HTML, and explicitly calls out what sections it would expect things to land in. Notable changes: * Moved window.portalHost from "Miscellaneous extensions" into a new "Portal hosts" section, which contains the definitions for both window.portalHost and the PortalHost interface. * Made the onportalactivate event handler addition match HTML's existing structure. * Moved subsections of "Security considerations" which were spec patches into a new dedicated section, "Updates to other specifications". * Noted the connection to whatwg/html#1230 in addition to RFC 7034. * Tweaks the wording in the "Fetch Metadata Request Headers" section's non-normative summary notes.
This brings the spec closer to how it would look upon landing in HTML, and explicitly calls out what sections it would expect things to land in. Notable changes: * Moved window.portalHost from "Miscellaneous extensions" into a new "Portal hosts" section, which contains the definitions for both window.portalHost and the PortalHost interface. * Made the onportalactivate event handler addition match HTML's existing structure. * Moved subsections of "Security considerations" which were spec patches into a new dedicated section, "Updates to other specifications". * Noted the connection to whatwg/html#1230 in addition to RFC 7034. * Tweaks the wording in the "Fetch Metadata Request Headers" section's non-normative summary notes.
This brings the spec closer to how it would look upon landing in HTML, and explicitly calls out what sections it would expect things to land in. Notable changes: * Moved window.portalHost from "Miscellaneous extensions" into a new "Portal hosts" section, which contains the definitions for both window.portalHost and the PortalHost interface. * Made the onportalactivate event handler addition match HTML's existing structure. * Moved subsections of "Security considerations" which were spec patches into a new dedicated section, "Updates to other specifications". * Noted the connection to whatwg/html#1230 in addition to RFC 7034. * Tweaks the wording in the "Fetch Metadata Request Headers" section's non-normative summary notes.
I'm interested in tackling this in the near future. It looks like currently frame-ancestors is completely handled, right? That is, https://html.spec.whatwg.org/#process-a-navigate-response step 1 handles frame-ancestors (and other CSP checks, like form-action and frame-src). It creates a network error. Network error pages have an opaque origin (clearer after #5736) and fire a load event (per https://html.spec.whatwg.org/#read-ua-inline "stopped parsing" step). So this bug reduces to only X-Frame-Options handling. There'll be a bit of trickiness around parsing, but otherwise it should be pretty straightforward once parsed. Assuming we don't support
The last step only checking top-level origin (instead of all intermediate origins) is based off of the remarks in https://w3c.github.io/webappsec-csp/#frame-ancestors-and-frame-options about "many user agents" |
Hmm per the discussions in https://bugzilla.mozilla.org/show_bug.cgi?id=725490 it looks like Chrome and Firefox implement all-ancestors checking, which is nice. And everyone passes the associated WPTs. https://wpt.fyi/results/x-frame-options?label=master&label=experimental&aligned&q=x-frame-options |
So I've got an initial spec for this up in #5737. The question remains on what to do in "conflict" cases like
(this is meant to be equivalent to the algorithm @mikewest outlines, but with more clarity at the cost of more O(n) operations. We could also just use the Chrome algorithm as-is.) Note that this conflict cases, according to Chromium metrics back in February, affects 0.002% of page loads. I'm OK with either the current simple spec proposal in #5737 (which I believe matches Firefox behavior), or with the more complicated Chromium version. I like simplicity, but I am sympathetic to the argument that conflicts are a sign that something has gone wrong and we should err on the side of blocking. Also, blackbox testing indicates that the Chromium model and the Safari model are probably the same, so it might be easier to just align there. What would Mozilla prefer? /cc @mozfreddyb EDIT: further testing reveals that the above algorithm proposal doesn't seem quite correct. In particular |
Alright. I did another pass through the tests, and rewrote everything to be less copy-pastey, and made sure that every same-origin test has a corresponding cross-origin test. Results over at web-platform-tests/wpt#24618. Here is the current status of browsers vs. the spec draft in #5737:
I don't have strong feelings about which model is better. The proposed spec is simpler, but it seems like the Chrome and Safari behavior might be a bit more strict, which could be good. /cc @dveditz /cc @ArthurSonzogni who I noticed working a bit on XFO in Chromium recently. |
Given the lack of engagement from implementers here I've decided the simplest course is to match the spec to 2/3 browsers and get things merged. I'll work on the spec/test updates for that now. |
This introduces a new 'navigation check', which we'll need to wire up to HTML. That, in turn, requires HTML to use Fetch. WHATWG's does, W3C's does not (w3c/html#548).
The initial pass at whatwg/html#1230 was too simple. Let's complexify it up a little bit, shall we?
See whatwg/fetch#302 where I initially filed this request. @annevk's suggestion that we handle the header inside the navigation algorithm (probably as step 21, after the response checks?) SGTM.
This will require some changes to CSP as well to move
frame-ancestors
from a response check in Fetch to a new check in the navigate algorithm.The text was updated successfully, but these errors were encountered: