Skip to content
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

Fix #536: Abort document.open if origins mismatch #583

Closed
wants to merge 3 commits into from

Conversation

jeisinger
Copy link
Member

This matches the implementation of Firefox, and will automatically
resolve the issue that we use the document's origin for initializing the
realm but the responsible document's url for setting the url: After this
change, the document's origin and the responsible document's origin will
be equal.

This matches the implementation of Firefox, and will automatically
resolve the issue that we use the document's origin for initializing the
realm but the responsible document's url for setting the url: After this
change, the document's origin and the responsible document's origin will
be equal.
@jeisinger
Copy link
Member Author

@bzbarsky @foolip wdyt?

<li>
<p>If the <span>origin</span> of the <code>Document</code> is not equal to the
<span>origin</span> of the <span>responsible document</span> specified by the <span>entry
settings object</span>, throw an <code>SecurityError</code> exception and abort these
Copy link
Member

Choose a reason for hiding this comment

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

s/an/a/

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@jeisinger
Copy link
Member Author

note that Blink actually makes the doc's origin and alias of the responsible doc's origin, but FF doesn't.

@@ -88391,6 +88391,13 @@ interface <dfn>WindowBase64</dfn> {
<li><p>If the <code>Document</code> object is not an <span>active document</span>, then abort
these steps.</p></li>

<li>
Copy link
Member

Choose a reason for hiding this comment

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

So the style conventions for this spec are a bit special, but when an <li> (or <dd> etc.) has only a single <p> child, they flow together, as in the <li> right above here. No clang-format for this, so we get to have fun in review :)

@foolip
Copy link
Member

foolip commented Jan 28, 2016

The change itself LGTM assuming this is precisely what Gecko does (let's let @bzbarsky confirm) but is this whole fix for #536? Does the question about which document to copy from become moot because the two documents involved are guaranteed to be the same, or...?

@jeisinger
Copy link
Member Author

kinda - at least that's what FF implements as far as I can tell, and it would solve my specific problem (define what origin the resulting document should have)

@foolip
Copy link
Member

foolip commented Jan 28, 2016

That's good! Can you tell if https://html.spec.whatwg.org/multipage/webappapis.html#set-up-a-browsing-context-environment-settings-object is till wrong? If this merely hides the issue in this instance, we need a separate issue to figure that out.

@jeisinger
Copy link
Member Author

it's a bit difficult to tell for me, as Blink's implementation of document.open() doesn't exactly align with the spec :-/

Maybe @bzbarsky can tell whether it's still not aligned with FF's implementation?

@annevk
Copy link
Member

annevk commented Jan 28, 2016

So I think the way this is handled in Firefox is through a generic origin check at the IDL layer that applies to everything, not just document.open(): https://github.com/annevk/html-cross-origin-objects.

@annevk annevk added the do not merge yet Pull request must not be merged per rationale in comment label Jan 28, 2016
@jeisinger
Copy link
Member Author

well, at least in the source, there's an explicit check: http://mxr.mozilla.org/mozilla-central/source/dom/html/nsHTMLDocument.cpp#1497

@annevk
Copy link
Member

annevk commented Jan 28, 2016

Interesting, I'll defer to @bzbarsky and @bholley then.

@bzbarsky
Copy link
Contributor

There are two separate checks in Firefox.

The first check, at the IDL layer, ensures that the effective script origin of the global of the Realm of the open function matches the effective script origin of the HTMLDocument object. This check applies in pretty much all cases (except some things on Window and Location). This is the "perform a security check" bit from the IDL spec.

For document.open specifically, there is an additional check, as cited by @jeisinger, which compares the origin (not the effective script origin) of the entry document to the origin of the document used as this for the open call. If this check fails, Firefox throws a SecurityError DOMException.

In web-facing terms, the main effect of this in Firefox is that if two sites start out not-same-origin and then set document.domain to the same thing they can touch each other's objects but can't call document.open on each other. I think that's OK, personally.

The diff here looks good to me.

@annevk annevk removed the do not merge yet Pull request must not be merged per rationale in comment label Jan 28, 2016
@jeisinger
Copy link
Member Author

updated the formatting

@annevk
Copy link
Member

annevk commented Jan 28, 2016

Committed as 05599ab. Thank you!

@annevk annevk closed this Jan 28, 2016
@annevk
Copy link
Member

annevk commented Jan 28, 2016

(I had to change the formatting a bit more, but no big deal.)

@Ms2ger
Copy link
Member

Ms2ger commented Jan 29, 2016

@jeisinger, feel like writing a test for this case?

@jeisinger
Copy link
Member Author

I'll give it a try

On Fri, Jan 29, 2016, 2:22 PM Ms2ger [email protected] wrote:

@jeisinger https://github.com/jeisinger, feel like writing a test for
this case?


Reply to this email directly or view it on GitHub
#583 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants