Skip to content

What does it mean to alias a policy from a CSP list? #207

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

Closed
bzbarsky opened this issue Apr 26, 2017 · 9 comments
Closed

What does it mean to alias a policy from a CSP list? #207

bzbarsky opened this issue Apr 26, 2017 · 9 comments
Assignees
Milestone

Comments

@bzbarsky
Copy link

https://w3c.github.io/webappsec-csp/#initialize-document-csp talks about aliasing policies from opener/parent documents.

But as far as I can tell, policies are immutable, really. What can mutate is the "CSP list" of the document. For example, https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-content-security-policy calls https://w3c.github.io/webappsec-csp/#enforced which just inserts the policy into the CSP list. So what does it mean to alias things when initializing the document's CSP?

@mikewest mikewest modified the milestone: CSP3 CR May 9, 2017
@andypaicu andypaicu self-assigned this Oct 17, 2017
@andypaicu
Copy link
Collaborator

What I take it to mean is just to insert a pointer to the parent policy in the CSP list of the child.

I think that is consistent with the general idea of aliases as way to access the same memory space using different "names" or "handles".

This could be spelled out in more details of course just to remove ambiguity.

@bzbarsky
Copy link
Author

My point is that you have a "CSP list", which contains "policies". Policies are immutable as currently specced, as far as I can tell. The "CSP list" can be mutated by adding or removing policies.

So there's no observable difference between copying and aliasing a policy, because policies are immutable anyway. If the idea is to "use whatever policies the parent/opener is using", you have to alias the "CSP list", not policies.

@bzbarsky
Copy link
Author

@mikewest Can you please get this sorted out? Browsers are not interoperable here, which seems like a serious problem for CSP deployment...

@ckerschb
Copy link

ckerschb commented Nov 28, 2017

@mikewest, we just experienced a bug [1] where a page creates an iframe using

frame = document.createElement("iframe");
document.body.appendChild(frame);

and then adds a meta CSP to that iframe. Since it's a same origin iframe, the iframe and the top-level page share the same principal. Ultimately, since the CSP hangs of the principal within Firefox, the CSP hoists to the embedding page and starts blocking content on the top-level document :-(

It seems Chrome behaves differently. Even though it sounds odd, I am not sure Firefox behavior is wrong here. Anyway, what do you think?

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1419222#c4

@mikewest
Copy link
Member

Thanks to you both for raising this. I agree that the language in the spec today isn't good. We should fix it together.

I think that we should have typed something like "copy" rather than "alias" in a few places. That is, I think Chrome's behavior is what I'd like to keep, but we should chat about it.

In the scenario you've spelled out, it seems valuable for a page to be able to break off a piece of itself and lock it down in a frame. Doing that in a way that doesn't persist the policy back up to the containing document is desirable in that case, as the framed page should have less privilege than the container.

Would you be willing to build that kind of behavior into Firefox if we did a better job specifying it? Or do you think Firefox's behavior is what we ought to run with in general?

Also, have you looked at Safari/Edge's behavior in the same scenario? If Chrome is the odd one out, I'm sure we can change our behavior instead.

@ckerschb
Copy link

I personally think Chrome's behavior is more intuitive and Firefox wants to get away from having the CSP on the nsIPrincipal anyway. I think I am willing to change Firefox behavior if we can spell out the behavior more explicitly in the spec.

@andypaicu
Copy link
Collaborator

Coincidentally I have a PR that replaces alias with copy which should separate the policies after the init part.

#273

Is there anything else that should be spelled out? Is the concept of a copy of a policy self-explanatory enough?

@bzbarsky
Copy link
Author

What would need to be copied is the policy list, presumably.

@andypaicu
Copy link
Collaborator

I will close this bug since everyone seems to be happy now.

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

No branches or pull requests

4 participants