Skip to content

Use SHA256 for JavaScript subresource integrity#10647

Merged
aduth merged 1 commit intomainfrom
aduth-asset-sri-sha256
May 20, 2024
Merged

Use SHA256 for JavaScript subresource integrity#10647
aduth merged 1 commit intomainfrom
aduth-asset-sri-sha256

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented May 17, 2024

🛠 Summary of changes

Updates subresource integrity hashes produced by the Webpack configuration to use SHA256 instead of SHA512.

This is a continuation of improvements around resource hints started in #10612, where Rails' hard cap of 1kb resource hints also includes integrity hashes, which you can see in production today for all preloaded JavaScript (except init.js):

curl -I https://secure.login.gov | grep link

The intent of these changes is to use a hash with a smaller byte size, without meaningfully sacrificing security. By using smaller hashes, the hope is that more assets can fit within the 1kb resource hint limit.

Additional considerations:

📜 Testing Plan

  1. Build JavaScript assets for production: NODE_ENV=production yarn build
  2. Start the server directly: rails s
  3. Go to http://localhost:3000
  4. Observe no regression in JavaScript behaviors (accordions, etc.)
  5. Inspect page markup
  6. Observe <script> tags at the bottom of <body> include integrity=sha256- attributes

changelog: Internal, Build Tooling, Use SHA256 for JavaScript subresource integrity
@aduth
Copy link
Contributor Author

aduth commented May 20, 2024

(except init.js)

For posterity, an integrity hash was added for init.js in #10648.

@aduth aduth merged commit 9041cd3 into main May 20, 2024
@aduth aduth deleted the aduth-asset-sri-sha256 branch May 20, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants