-
Notifications
You must be signed in to change notification settings - Fork 79
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
Allow nonce-source to be used in more directives. #116
Comments
Checking if this is a sane proposal: @mikewest @marumari @ptoomey3 @jonathanKingston @oreoshake |
I am not in the list of selected people, so sorry for jumping in. Is changing from external resources whitelisted in source-list to inline scripts whitelisted by nonce made your policy shorter? Can you give an example of how do you see a nonce used with, say image? |
Hi @shekyan, no problem, I was just dropping some names in there of people that jumped to mind :-) I think you may have misunderstood the change I've made, I've not moved to inline scripts, I've changed from this:
To this:
This way I don't need to whitelist the many hosts that I load various assets from nor do I need to maintain that list going forwards. For images, or other resource types, I was thinking of the exact same approach, going from this:
To this:
It seems like the benefit of the nonce approach can be easily passed on to other elements on the page, further reducing the burden of CSP.
|
For reference, you can see the policy I'm currently testing and the changes I'm making here: https://securityheaders.io/?q=https%3A%2F%2Fscotthelme.co.uk%2F&followRedirects=on I have my live policy in the CSP header and I'm testing nonces in the CSPRO header. |
Seems sensible to me. I don't see any real downsides, and consistency is a nice usability win. I always have to double check what sources |
I see you covered this already 😀...not.the first time writing a reply 30 minutes after reading a comment has bitten me. My short-term memory is, as they say, not so good. |
I keep forgetting that nonces are also applicable to external resources :( Makes sense to me to expand to other resources. |
I think we'll run into the same problem here that we have with |
Wouldn't backwards compatibility work in the same way that it does for
Perhaps I've missed something, in which case it'd be great if you could explain! :) |
Yes, but not while at the same time "simplif[ing] the rest of [your] policy" as you suggested at the top. That is, it would work fine as a purely additive mechanism in addition to your existing whitelist, but then there's no advantage to adding it. :) shrug If folks really want to use nonces for other kinds of resources, I don't have a fundamental problem with adding them to the framework. There's a lot of wiring things together that we'd need to do in HTML to make this work (to say nothing of the same that would need to be done in actual implementation code), so I'm not dying to add it. It seems like a lot of work for me, for very little advantage for you. :) But if it's useful, we can make it work. |
Ok I see. For the present day, yes, I agree. However, I do see a point in the future where we have widespread CSP 3 support. At that time I think it'd be nice if we could use nonces across the board instead of it being limited to styles and scripts with a whitelist for everything else still. There is a technical cost to implementing nonces so it'd be great if they were a replacement for the cost of implementing and maintaining the whitelist instead of in addition to it. My perfect scenario would be:
|
Would the approach used in
Using @ScottHelme's example, perhaps the following
Would look like
to CSP 1 and 2 browsers and
to CSP 3 browsers. Either way, this would still load
|
This directive could also enable inline style in a SVG that is referenced. page.html
kitten.svg
I am not aware of any solution for inline style in a referenced SVG within the current framework. Or am I missing something? |
I'm not sure why a document's CSP applies to the internals of a completely separate svg image load. in-line SVG, sure -- we should block the inline style. But the external SVG image is a completely separate document (which could have its down CSP I suppose). |
@dveditz You are right. But also consider this. The web is increasingly using SVGs for a variety of solutions. If you create SVGs using apps like Illustrator, inline style is quite common I would say. Since SVG does not have a So maybe my proposed solution is in the wrong direction, but at least one can say it is really difficult for external SVGs to have inline style and be compliant with a Content Security Policy. |
@frederikbosch I think you can apply CSP to a SVG document with a |
I recently deployed nonce support on my site and it makes deploying a strong CSP considerably easier. A lot easier than I thought it was going to be now I've actually done it. One of the other aspects I liked was that my ridiculously huge
script-src
andstyle-src
directives were cut down by more than 90%.This got me thinking it'd be nice to simplify the rest of my policy and use nonces in other elements on the page. Things like
img-src
,child-src
,frame-src
and even thedefault-src
perhaps?Could we extend the nonce-source to be used more widely?
The text was updated successfully, but these errors were encountered: