Repository navigation
Clarify origin check in document.open() - #2288
Conversation
|
This looks good. Would be good if the tests discussed on IRC can land first. |
|
working on it |
|
If we make this same origin-domain I think we should just remove the check altogether. It would be redundant with https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl. |
|
Test for removing the check: Test for current spec:
|
It's not redundant in blink, as you don't lose access to objects you once got. So getting the document and the open function, and then setting the document.domain still allows you to call open on the now no longer same origin-domain document. In that case, the check in step 4 triggers. In Firefox on the other hand, the membrane will revoke access so step 4 might be indeed redundant. @zcorpan I don't think your tests are correct due to the difference in how security checks are implemented in the two browsers. |
|
@jeisinger it's not redundant in Blink because Blink doesn't implement the "perform a security check" that the HTML standard requires. If we start defining Blink's model, we'd have to remove that check, from HTML and IDL, and define a couple things in a different way. But putting both in would make it logically inconsistent. |
|
@annevk maybe I'm misunderstanding. Can you point me at where "perform a security check" is invoked? |
|
@jeisinger basically for each getter/setter/operation in https://heycam.github.io/webidl/. |
|
the way I read this is that we have to perform the security check when reading the attribute which we do. The result of reading the attribute is converted to a ECMAScript object that doesn't require further access checks. So something like this is still spec compliant const doc = window.frames[0].document; // performs access check to get the doc |
|
Thank you, it does indeed seem to only be invoked on creation, not on invocation. So currently HTML describes Chrome's SOP model and not Firefox's model. And this change would add defense-in-depth for @bzbarsky does that also match your understanding of things as far as HTML and SOP go? |
Per the current specs as written, in @jeisinger's testcase, when you call
which applies to us, since So per current spec as written, this should in fact succeed in calling into the steps of On the other hand, doing In Gecko the step that would throw in that testcase is crossing the now-revoked membrane to reach the [[Call]] of the On the other hand, Chrome does not seem to perform any security check from inside the IDL operation at all, so the spec also does not define Chrome's security model. ;) Moving right along....
This step does not perform any security checks I'm aware of per the HTML and IDL specs (but does on Gecko, for getting the "open" property, so if you set The only security checks in the specs I'm aware of are the "perform a security check" bits in IDL and the internal methods of WindowProxy and Location objects. |
|
Oh, and as for the main topic of this issue: what is the point of the check in Note that "the responsible document of the entry settings object" may well not be same origin-domain with the actual caller of |
|
One other note: I would have no objection to tightening the security check here to require that the document being I should also note that Chrome and WebKit do some sort of security checks here. I'm just not sure which ones. For example, http://web.mit.edu/bzbarsky/www/testcases/document/document-open-domains.html throws from every single test. But maybe they're checking same origin-domain or something? |
|
I should note that http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4851 (cited above) doesn't make sense to me: in that testcase both windows are same-origin and same origin-domain at all times, so there's just no security check issue, right? Hence no exceptions in any browsers. |
|
Oh, sorry, I forgot about about:blank getting the creator origin. Corrected: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4857 |
|
Right, that sure makes it look like Blink is doing some sort of "same origin-domain" check inside document.open. |
|
@bzbarsky can you clarify what case should throw when you said "On the other hand, Chrome does not seem to perform any security check from inside the IDL operation at all, so the spec also does not define Chrome's security model. ;)" |
|
Well, for example this: does not throw in Chrome, whereas per spec it should. |
I read the spec that creating docOpen runs the "create an operation function" steps, but later calling it doesn't run those steps again. |
|
The "create an operation" steps are run at global creation time. They create the JS Function object. Step 2 of "create an operation" defines the variable steps to be a list of steps, but doesn't run them or anything. Then step 3 passes this variable to CreateBuiltinFunction. That lands you at https://tc39.github.io/ecma262/#sec-createbuiltinfunction. Per step 3 of that algorithm the result is a function that "when called performs the action described by steps". |
|
ok, I think this boils down to https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl step 2 (IsPlatformObjectSameOrigin) not being implemented in blink (nor is that easily implementable) |
|
soo... the conclusion is that "same origin-domain" is the right behavior but tests are hard? |
|
Conclusion for which?
|
09582bf to
b3bec4d
Compare
|
right. Update this PR, the WPT PR, and https://codereview.chromium.org/2691083006 updates blink to check for same-origin |
|
Okay, so this PR as-is is correct, but there should be a follow-up issue where we discuss "perform a security check" and what we actually want as a security model, is that correct? (And yes, I realize we have tried in the past, but we should keep trying and at least acknowledge the current standard matches nobody there...) |
|
yeah, there's some discussion going on on the (private) issue that @bzbarsky filed on crbug.com I'll file an issue once we come to a conclusion what to do |
|
I doubt "we" (broadly speaking) are going to come to a "conclusion what to do" in a hidden Blink issue, fwiw. ;) |
|
FWIW, after stating that #2360 was filed as well, so there's now a public issue where we can try to make progress on this question as well. |
Fixes #2282