-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Description
The CspHtmlWebpackPlugin generates incorrect hashes, causing issues when trying to use the generated CSP.
I have created a GitHub repository to reproduce the issue and deployed the site for reference:
- Reproduction repository: github.com/warnyul/bvarga.dev/pull/59/files
- Deployed site: bvarga-fe600--pr59-csp-m690t8vi.web.app
My observations
If I copy the content of the <style> or <script> tags from the generated index.html into an online CSP hash generator, I get different hash values. When I manually replace the generated hashes in index.html with these correct values, my site works as expected without CSP violations.
I could not prove it but maybe the issue is related to #111
What type of issue is this? (place an x in one of the [ ])
- bug
- enhancement (feature request)
- question
- documentation related
- testing related
- discussion
Requirements (place an x in each of the [ ])
- I've read and understood the Contributing guidelines and have done my best effort to follow them.
- I've read and agree to the Code of Conduct.
- I've searched for any related issues and avoided creating a duplicate issue.
Bug Report
Reproducible in:
slackhq/csp-html-webpack-plugin version: 5.1.0
node version: 22.10.0
OS version(s): macOS Sequoia 15.01, Ubuntu 24.04
Steps to reproduce:
- Clone the reproduction repository:
git clone https://github.com/warnyul/bvarga.dev.git - Install dependencies:
npm install - Build the project:
npm run build - Open
index.htmlindistfolder using Safari or Google Chrome.
Expected result:
The hashes generated by the CspHtmlWebpackPlugin should correctly match the content of the built files.
Actual result:
The hashes generated by the plugin do not match the content of the files, causing CSP violations in the browser when accessing the deployed site. Manually generated hashes work correctly when applied.