-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[AssetMapper] Support SRI (integrity hashes) #54249
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
Comments
As some files are changed during compilation, before beeing deployed in the public assets directory, it may be easier more efficient to compute those hash locallly. In fact, as we already compute a hash based on the content, it would just be a question of "hashing strategy" (similar to the user password hashing behaviour in Security) |
AssetMapper uses SRI only supports SHA-256, SHA-384, and SHA-512. See https://w3c.github.io/webappsec-subresource-integrity/#hash-functions |
AKAIK, import maps do not support intergrity hashes. And that's where the majority of 3rd party assets are referenced. The other assets (endpoints and CSS mainly) are changed during compilation, so we cannot use SRI computed elsewhere for that. |
Plus, it's really useful for Remote Resource, not as much for self serve resource. |
I'm closing this because as @ph-il said, SRI is really useful when embedding third-party assets ... but with AssetMapper we're serving assets from our own servers. What we might need is to have checksums of the assets downloaded from jsDeliver. But that's a completely different feature. Thanks! |
Hi,
No, if a malicious user change the script content stored in your server or CDN, it's a security risk. Like Webpack Encore, the Asset Mapper should have a |
I just opened a PR, with some basic implementation / first ideas.. if you want to contribute :) |
Docs about SRI: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
The jsDelivr CDN API used to download packages seem to support SRI (jsdelivr/api#137) so we could use that to only generate hashes for application assets.
Also, this should be an option because if you use CDN/servers that mangle the assets (e.g. to minify or compress the source code) the hashes won't be valid.
The text was updated successfully, but these errors were encountered: