Skip to content

[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

Closed
javiereguiluz opened this issue Mar 12, 2024 · 7 comments · May be fixed by #58722
Closed

[AssetMapper] Support SRI (integrity hashes) #54249

javiereguiluz opened this issue Mar 12, 2024 · 7 comments · May be fixed by #58722

Comments

@javiereguiluz
Copy link
Member

javiereguiluz commented Mar 12, 2024

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.

@smnandre
Copy link
Member

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)

@javiereguiluz
Copy link
Member Author

@smnandre
Copy link
Member

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.

@ph-il
Copy link

ph-il commented Mar 17, 2024

Plus, it's really useful for Remote Resource, not as much for self serve resource.

@javiereguiluz
Copy link
Member Author

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!

@pierreboissinot
Copy link

Hi,

SRI is really useful when embedding third-party assets

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 enableIntegrityHashes feature.

@smnandre
Copy link
Member

@pierreboissinot

I just opened a PR, with some basic implementation / first ideas.. if you want to contribute :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants