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

Are nonces allowed/supported in frame-src? #433

Open
viraptor opened this issue Apr 29, 2020 · 5 comments
Open

Are nonces allowed/supported in frame-src? #433

viraptor opened this issue Apr 29, 2020 · 5 comments

Comments

@viraptor
Copy link

I'm running into a weird situation in practice in both FF and Chrome where if I send frame-src 'nonce-...';, the browsers still don't allow a nonce-tagged iframe to load. Chrome even explicitly returns:

Refused to frame '...' because it violates the following Content Security Policy directive: "frame-src 'none'".

Reading the spec, it seems that nonces are allowed on frame-src. Am I mistaken in how it works?
Or is it that the current implementations don't support it?

@bakkot
Copy link

bakkot commented Apr 29, 2020

Speaking as an outside observer, my understanding is that such nonces are allowed in the sense of matching the grammar, but they don't actually do anything. frame-src has two associated checks, and both of them only use Does response to request match source list?, which does not care about nonces.

(See also #431, which points out a similar discrepancies.)

@dveditz
Copy link
Member

dveditz commented May 5, 2020

Nonces are only checked for script or style. These are called out in the pre- and post- check algorithms for those types, but also the global "match element to source list" algorithm only checks nonces if the element is style or script.

Interesting. I don't think anyone has brought up the possibility of it being a generic whitelisting mechanism. I suppose it could be useful for "infinite scroll" type pages where you don't know what the content is going to be when you're setting up the page's CSP, but you know you want embedding of various user content.

@viraptor
Copy link
Author

viraptor commented May 5, 2020

FTR, my use case was a bit different. Application so large that keeping a list, getting everyone trained, etc is challenging. Banning <iframe and allowing <%= nonced_iframe ... (or whatever implementation may be) though is much simpler.

@arturjanc
Copy link

I generally like the idea of nonces as a generic mechanism to allow the loading of arbitrary elements, not just script or style. I think the Firefox implementation even allowed this at some point for a number of other elements.

This has been proposed as a "web ASLR" a long time ago, see:

I'm not entirely sure there's interest in implementing it at this point, however, especially since a potential (likely?) future direction for CSP is a split into Scripting Policy / Confinement Policy.

@egranty
Copy link

egranty commented Nov 28, 2020

I think the Firefox implementation even allowed this at some point for a number of other elements.

Yes, Mozilla Firefox v52.9.0 ESR (release Jun 2018, WinXP) did supported 'nonce-value' in any elements.
Situation has changed in Firefox v69 browser (release September 2019). It looks like they looked at how this is implemented in Chrome and unified the behavior of their browser.

Currently only the <script> and <style> elements are "nonceable".

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

5 participants