Re: Frame access


 I don't think that we're going to try to define policies that restrict interactions between resources that are same-origin.  There just is no firm isolation mechanism  pretending the frames are meaningfully different security principals isn't sustainable.

However, the suborigins proposal Joel Weinberger is working on, and which we are considering as part of rechartering, could help here:

In this way, the resource in each frame could opt-in to a stable sub-origin that was uniquely addressable by origin-aware APIs like postMessage, and they would behave as fully independent security principals.


From: Sean Snider <<>>
Reply-To: Sean Snider <<>>
Date: Wednesday, October 29, 2014 at 9:59 AM
To: Sean Snider <<>>, Frederik Braun <<>>, "<>" <<>>
Subject: Frame access
Resent-From: <<>>
Resent-Date: Wednesday, October 29, 2014 at 10:04 AM

I'd actually like to propose something else for CSP next if could, but I thought I'd create a thread first
(and if there already is another similar one, please someone let me know).

This idea is actually related to both of the following threads:

  1.  Frame Ancestors and Referrer
  2.  Consider directives to manage postMessage and external navigation of iframes [CSP Next] (webappsec issue 69)

Given the following example:

  1. at the top level browsing context
  2.  2 IFRAMES within, both with a  origin
     *   1 level down from top (IFRAME, parent is
     *   Lets label each frame from
        * (first frame)
        * (2nd frame) cannot access directly. . . cannot access directly
However, CAN access itself, so it can read / write to both IFRAMEs in
It can find them by simply scanning the frames/window array-like collection.

Now, if listens for messages, either, or can send information,
and in return and can receive messages.

However, there is currently no way to gurantee which FRAME the messageREALLY came from. . .
I say this b/c. . .

if does:
    top.frames[0].top.postMessage("some-data", "");

Then the message event received in the top window, will actually be from top.frames[1] which
is, and that's correct.

But. . . if both's have a function, which sends a postMessage to the top, then this changes:
both's have:

function send_msg(m) { top.postMessage(m, "*"); }

Now if, call's's send_msg function, the source window will change to,
which prevents the top level from really knowing which frame did the call.


What's really gross about this is. . . both IFRAMEs are same origin, so even if you changed
what the "source" property was on the message event, could just inject code into
as a way of working around the problem.

I should note in IE 8, this actually does not happen b/c postMessage is synchronous (although that's probably bad).
And like I said either way, you could just inject code into the frame. . .

Sandboxing the frames also doesn't help, b/c then they both have a "null" origin, and so there is no way
to really identify the origin of the message.

Now something else I found interesting. . . in Firefox (i tested version 30 on the PC), you can set document.domain
with a port number, even if the IFRAME / document has no port number defined in it's originating URL.

so you can do,
document.domain = location.hostname + ":[some random port number]".

Firefox allows this, and in turn doesn't expose the port number back if you were to ask for it. . .
In turn this basically breaks same-origin access between and, even when
the 2 frames actually do have the exact same origin.

No other browser that I can find seems to do / allow this. . . you cannot change the port to something
else other than what was originally defined. . . but honestly I think it's really neat b/c it provides a "light
sandbox". . . or in other words, a way to prevent access to 2 different global contexts.

I'm not sure if that behavior is really right or not. . ..we can discuss it further. . .but what I'm getting at here
is that it would be nice to have not only a way to specify message channels with CSP (ensuring that messaging
comes from the proper places), but it would ALSO be nice to RESTRICT access to the global context.

Rather than going to full-on sandboxing, being able to restrict sibling access would be very nice.
You could even still allow for postMessage (so long as you fix the source part :P), and location setting,
and whatever. . . but said frame can define a policy that says "no-one can access me except me"
would be great. . and honestly I can't even see anything it would break. . .


From: Sean Snider <<>>
To: Frederik Braun <<>>; "<>" <<>>
Sent: Wednesday, October 29, 2014 9:55 AM
Subject: Re: Frame Ancestors and Referrer (Re: [webappsec] Call for Consensus: Stop work on Content Security Policy 1.0, transition to WG Note)

OK let me put this another way. . .

Why shouldn't every single frame be able to know the origin of who did the embedding?
Seems to me that's reasonable, since we've ALWAYS allowed it in the past. . .

Further, if someone did set referrer to none, again the HTML document in question has no way to know
who / or way the embed-er is.. . and if the embed-ee wants to know that, or is required to know that. . .
what are they supposed to do?

Unless an embed-ee can require that knowledge somehow, (which he cannot unless we add something else to frame ancestors),
I really feel like this is game-breaking. . .

It's not to say that I don't believe in being able to protect the referrer, it's simply that we shouldn't create a 1-way block
with absolutely no recourse. . .

Right now the way the spec is setup, even if an embed-ee says to allow frame-ancestors of "", "", etc,
but one of those sites set "referrer" to "none", the embed-ee has absolutely 0 way to know who did the embedding,
even though they are trying to establish trust. . .


From: Frederik Braun <<>>
Sent: Monday, October 27, 2014 4:01 AM
Subject: Re: Frame Ancestors and Referrer (Re: [webappsec] Call for Consensus: Stop work on Content Security Policy 1.0, transition to WG Note)

On 25.10.2014 02:37, Sean Snider wrote:

> Anyway. . . In my very humble opinion. . .
> I really cannot see a "valid" use-case for "none", and I think it potentially breaks things or creates nasty situations..


I disagree. There are numerous cases for secrets in the link (aka
capability URLs) that may want to get a greater deal of leak protection.

Received on Monday, 3 November 2014 23:35:44 UTC