-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add hashes to external scripts (CSP3) #50
Comments
Hi @Kage-Yami The
We have a few options when it comes to supporting external scripts in CSP 3.0:
At the moment, I am leaning towards the first option, although I am unsure as to how frequently developers would want to use this feature. To anyone reading this: Maybe add a 🎉 to this comment if you'd like to stick with the 1st option, 👍 if you would like to see the 2nd or 😄 if you'd like to see the 3rd. |
Hmm, fair points. Definitely agree that (3) is right out. I'd vote for a (2b): default to (1), but have a config setting to enable (2) - idea being that if a dev is enabling it, they likely should've read the doco outlining the limitations; config setting can be verbose (e.g. I'm assuming that "Local-External" here is anything bundled (e.g. |
I think we're on the same page here :) If we're only including hashes from assets which are added as 'local-external' script srcs, then there is no risk there. Implementation steps here would be to:
The potential risk would be introduced if we were looking to add hashes for 'web-external' scripts too. Since we wouldn't be able to calculate the hashes for these assets as webpack emits them, the only way to add them to the csp policy would be to manually calculate them and add them to the policy, or download the files during webpack compilation and calculate the hashes then. If you're open to opening a PR with what we've discussed here, I would be happy to review! |
Unfortunately, hashing of external scripts is currently only supported in Chromium-based browsers (see web-platform-tests). |
We'd really like to use hashes for "external" scripts - ie our Webpack generated scripts. The only environment that matters to us is Chromium-based (Electron) and we have no truly external scripts. Is there any way to get this to work currently? I guess no?
Please don't require developers to manually assign hashes. They'll never do it. The second option may be confusing to developers initially, but would provide far more security since it would actually get used. The third option sounds like a significant security risk. Users always have the option to use (Though I should note that we can't get |
I spent an hour or so trying to implement this earlier today, and whilst I'm totally unfamiliar with Webpack, I couldn't work out a way to do it – you need the final content of each JS file in order to hash it, but you then need to modify the HTML in order to insert the hashes.
On the other hand, webpack-subresource-integrity seems like it does a similar kind of thing, so I suspect I'm just trying to use the wrong hooks. |
CSS is now statically inlined so that csp-html-webpack-plugin calculates hashes for it; this probably doesn't lead to ideal startup performance, but that's not currently a concern. See slackhq/csp-html-webpack-plugin#50.
Any movement on this? Few single issues could do as much to enhance security across a wide range of projects as this one. @AnujRNair any thoughts on a path forward? |
I hate to be a pain bumping this thread again, but I have to ask since I think this would be such a big deal for so many projects, any update on this? The status on the issue is both "In Review" and "In Development". Is this actually under development? Planned? Still under review? |
I thought this PR has been out there for almost a year: #87 We would really like to see this feature implemented. |
Hashes are supported on Hashes for elem scripts is not currently supported by CSP lv 3, which is what most browsers are currently at. Hashes currently only work for inline scripts and styling according to W3C specs. |
Description
According to Mozilla's documentation, CSP3 allows for the
<hash-algorithm>-<base64-value>
attribute ofscript-src
to be applied for external scripts.As I understand it (based on reading #35 and trying out the plugin myself), hashes are not generated and included for external scripts, only inline scripts.
It'd be nice if they could be included for external scripts too. (Maybe via a default-
false
configuration option?)What type of issue is this?
Requirements
The text was updated successfully, but these errors were encountered: