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

Define security around Window, WindowProxy, and Location properly #638

Merged
merged 1 commit into from
Feb 27, 2016

Conversation

annevk
Copy link
Member

@annevk annevk commented Feb 6, 2016

This is a relative large change to the way Window, WindowProxy, and
Location objects work, at least from a standards’ perspective. This
should more closely match implementations and define all the relevant
details.

A rough summary of the changes:

  • Window indexed getters have moved to WindowProxy.
  • WindowProxy is now a JavaScript exotic object and it handles all the
    security aspects for Window so Window can become an ordinary object.
  • Cross-origin named properties for Window are now exposed (though on
    WindowProxy). This addresses Child browsing context names leak across origins #544 and
    https://www.w3.org/Bugs/Public/show_bug.cgi?id=21674 which that PR was
    intended to replace.
  • Location is now an exotic object with all its internal methods
    overridden to handle the cross-origin security aspects.
  • Location no longer uses Unforgeable on the interface, allowing that
    to be removed from IDL. (It moved to all of its properties instead and
    the remaining details are defined through prose.)

This should also address these bugs:

@annevk
Copy link
Member Author

annevk commented Feb 6, 2016

Things I need to look into:

Things that made me ponder:

  • Although I used <span> around a bunch of Ordinary* abstract operation references, the build script is not complaining about missing <dfn>s. What is up with that?

In any event, this is definitely ready for review.

@annevk
Copy link
Member Author

annevk commented Feb 6, 2016

If tc39/ecma262#367 lands we need to figure out what to do with [[Enumerate]]. It's not entirely clear to me what we can do then.

@domenic
Copy link
Member

domenic commented Feb 6, 2016

Although I used around a bunch of Ordinary* abstract operation references, the build script is not complaining about missing s. What is up with that?

I've noticed this too. I think the build script thinks that empty spans are just meant to be using span to mark up a length of text, not auto-linking. That is why we should move to longer term.

Will try to review Monday.

@sideshowbarker
Copy link
Member

Although I used around a bunch of Ordinary* abstract operation references, the build script is not complaining about missing s. What is up with that?

I've noticed this too. I think the build script thinks that empty spans are just meant to be using span to mark up a length of text, not auto-linking. That is why we should move to longer term.

To be clear, that’s an issue with wattsi, right? (Not something else in the build.sh script or the Perl scripts it calls.) If so, I wonder if whatwg/wattsi#5 regressed this, or if it’s always been this way, or what.

<p>The <dfn>number of child browsing contexts</dfn> is the number of <span data-x="child browsing
context">child browsing contexts</span> that are <span data-x="browsing context nested
through">nested through</span> elements that are <span data-x="in a document">in the
<code>Document</code></span> that is the <span>active document</span> of the <code>Window</code>
Copy link
Member

Choose a reason for hiding this comment

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

A Window does not have an "active document"; a browsing context does.

@annevk
Copy link
Member Author

annevk commented Feb 10, 2016

WindowProxy needs to use https://heycam.github.io/webidl/#dfn-named-property-visibility (or a variant thereof) where it implements cross-origin named properties. In particular I think we don't want to have [OverrideBuiltins] behavior if I understood @bzbarsky's comments in https://bugzilla.mozilla.org/show_bug.cgi?id=1245554 correctly.

@annevk annevk force-pushed the cross-origin-objects branch from 52a6d48 to 442575a Compare February 10, 2016 14:27
@bzbarsky
Copy link
Contributor

We should probably test what UAs actually do with cross-origin named properties carefully. Defining how this should behave will be a bit tricky. For example, consider this testcase:

<!DOCTYPE html>
<body>
  <iframe name="foo"></iframe>
  <script>
    Object.prototype.foo = 5;
    onload = function() { alert(window.foo); }
  </script>
</body> 

In browsers this alerts "5" (at least in Chrome, Safari, and Firefox). What should happen on cross-origin access to the "foo" property on this window? Chrome and Firefox return the subframe, looks like. Safari returns undefined (or 5, depending on what the accessing thing actually is; yes, it leaks info cross-origin in some cases). Of course maybe Safari returns undefined for cross-origin named access in general? We really need some exhaustive tests. :(

@@ -2976,16 +2977,23 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
<li>The <dfn data-noexport="" data-x="js-prod-Module" data-x-href="https://tc39.github.io/ecma262/#prod-Module"><i>Module</i></dfn> production</li>
<li>The <dfn data-noexport="" data-x="js-prod-Pattern" data-x-href="https://tc39.github.io/ecma262/#prod-Pattern"><i>Pattern</i></dfn> production</li>
<li>The <dfn data-noexport="" data-x="js-prod-Script" data-x-href="https://tc39.github.io/ecma262/#prod-Script"><i>Script</i></dfn> production</li>
<li><dfn data-noexport="" data-x-href="https://tc39.github.io/ecma262/#sec-property-descriptor-specification-type">PropertyDescriptor</dfn></li>
Copy link
Member

Choose a reason for hiding this comment

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

I've been curating this section, perhaps a bit obsessively. This should be "The [PropertyDescriptor] specification type"

Copy link
Member Author

Choose a reason for hiding this comment

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

This is meant to refer to the tag literal descriptions of Property Descriptor records.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah but ES conflates them

Copy link
Member

Choose a reason for hiding this comment

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

Still would like to see this fixed. The fact that ES uses specification type names as tags when creating literals is just notation; the actual thing being referenced is the PropertyDescriptor specification type.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should it then say "Property Descriptor specification type"? But the references can use the literal PropertyDescriptor?

Copy link
Member

Choose a reason for hiding this comment

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

Yep.

@domenic domenic added normative change addition/proposal New features or enhancements clarification Standard could be clearer labels Feb 24, 2016
@annevk annevk force-pushed the cross-origin-objects branch from 573c619 to ff6a7c1 Compare February 25, 2016 11:15
@annevk annevk assigned domenic and unassigned annevk Feb 25, 2016
@annevk
Copy link
Member Author

annevk commented Feb 25, 2016

@domenic I had a few more issues opened against ECMAScript that are now resolved (two PRs still pending). The biggest change is the removal of [[HasProperty]] overrides due to an upstream change. Since OrdinaryHasProperty will invoke [[GetOwnProperty]] now instead of OrdinaryGetOwnProperty.

@annevk
Copy link
Member Author

annevk commented Feb 25, 2016

In another PR @domenic noted:

I think for these kind of informal maps, I much prefer the phrasing I used for the module map:

  • If module map contains an entry with key url, ...
  • If module map contains an entry with key url whose value is "fetching", ...
  • Create an entry in module map with key url and value "fetching"

Pretty sure we're not using that terminology for the internal map we are introducing here.

@annevk annevk force-pushed the cross-origin-objects branch from 6f64898 to 7447524 Compare February 25, 2016 18:12
<li><p>Return false.</p></li>
</ol>

<h5 id="location-get-receiver">[[Get]] ( <var>P</var>, <var>Receiver</var> )</h5>
Copy link
Member

Choose a reason for hiding this comment

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

Can this be "location-get"?

@domenic domenic added the do not merge yet Pull request must not be merged per rationale in comment label Feb 25, 2016
@annevk annevk force-pushed the cross-origin-objects branch from 392492c to 918cd71 Compare February 26, 2016 09:04
@annevk
Copy link
Member Author

annevk commented Feb 26, 2016

Is the "do not merge yet" label there because of tc39/ecma262#416?

@domenic
Copy link
Member

domenic commented Feb 26, 2016

Yep

@domenic domenic removed the do not merge yet Pull request must not be merged per rationale in comment label Feb 26, 2016
@domenic
Copy link
Member

domenic commented Feb 26, 2016

Dependencies merged; land at will @annevk!

This is a relative large change to the way Window, WindowProxy, and Location objects work, at least
from a standards perspective. This should more closely match implementations and define all their
relevant security details.

A rough summary of the changes:

* Window indexed getters have moved to WindowProxy.
* WindowProxy is now a JavaScript exotic object and it handles all the security aspects for Window
  so Window can become an ordinary object.
* Cross-origin named properties for Window are now exposed (though on WindowProxy).
* Location is now an exotic object with all its internal methods overridden to handle the
  cross-origin security aspects.
* Location no longer uses Unforgeable on the interface, allowing that to be removed from IDL. (It
  moved to all of its properties instead and the remaining details are defined through prose.)

This should also address these bugs:

* https://www.w3.org/Bugs/Public/show_bug.cgi?id=20701
* https://www.w3.org/Bugs/Public/show_bug.cgi?id=21674
* https://www.w3.org/Bugs/Public/show_bug.cgi?id=22346
* https://www.w3.org/Bugs/Public/show_bug.cgi?id=27128
* https://www.w3.org/Bugs/Public/show_bug.cgi?id=27502
@annevk annevk force-pushed the cross-origin-objects branch from 918cd71 to acae3df Compare February 27, 2016 06:26
@annevk annevk merged commit acae3df into master Feb 27, 2016
@annevk annevk deleted the cross-origin-objects branch February 27, 2016 06:33
@sideshowbarker
Copy link
Member

Rock n rollーVery cool to see this landing.

@domenic
Copy link
Member

domenic commented Feb 27, 2016

This might deserve a blog post :D

@Ms2ger
Copy link
Member

Ms2ger commented May 13, 2016

https://blog.whatwg.org/windowproxy-window-and-location

<p class="warning">The <code>Location</code> exotic object is defined through a mishmash of IDL,
invocation of JavaScript internal methods post-creation, and overridden JavaScript internal
methods. Coupled with its scary security policy, please take extra care while implementing
this excrescence.</p>

Choose a reason for hiding this comment

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

Wanted to say this is such an incredible word choice that had me search for over an hour on how this was added. Now i can relieve myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements clarification Standard could be clearer normative change
Development

Successfully merging this pull request may close these issues.

8 participants