Skip to content

SRI hash generated by sprockets doesn't work in Google Chrome 45 - 46 and Firefox 43 - 51 #681

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

Closed
andreas-venturini opened this issue Jun 3, 2020 · 1 comment

Comments

@andreas-venturini
Copy link

andreas-venturini commented Jun 3, 2020

Expected behavior

SRI hash should work in all versions of Google Chrome & Firefox that support SRI (see https://caniuse.com/#feat=subresource-integrity).

Actual behavior

  • The SRI hash only works as expected in Google Chrome >= 47 and Firefox >= 52.
  • In Firefox versions 43 - 51 assets w/ SRI hash are not loaded and the following error message is displayed in the browser console: None of the “sha256” hashes in the integrity attribute match the content of the subresource
  • In Google Chrome versions 45 - 46 assets w/ SRI hash are not loaded and the following error message is displayed in the browser console: Failed to find a valid digest in the 'integrity' attribute for resource application-ASSET_HASH.css with computed SHA-256 integrity SRI_HASH'. The resource has been blocked.

I downloaded the asset and calculated the sha-256 hash locally by runnning the following command:

cat application-ASSET_HASH.css | openssl dgst -sha256 -binary | openssl base64 -A

The result matches the hash computed by sprockets.

I looked at the changelog of Firefox 52 (https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/52) and Google Chrome 47 but couldn't find any indications of bug fixes related to the SRI implementation.

System configuration

  • Sprockets version: 3.7.2
  • Ruby version: 2.6.6p146
@andreas-venturini andreas-venturini changed the title SRI hash generated by sprockets doesn't work in Google Chrome 45 & 46 and Firefox 43 - 51 SRI hash generated by sprockets doesn't work in Google Chrome 45 - 46 and Firefox 43 - 51 Jun 3, 2020
@andreas-venturini
Copy link
Author

andreas-venturini commented Jun 4, 2020

I looked at the Mozilla bug-tracker again and found this https://bugzilla.mozilla.org/show_bug.cgi?id=1271796

It seems to describe exactly what I'm reporting above (wrong SRI hash calculated for the css asset) - and was resolved in Firefox 52 which also matches my observations.

I'm assuming there was a similar problem in Chrome 45-46.

Therefore closing.

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

1 participant