Something for ScriptTagHelper and maybe a StyleSheetTagHelper?
The website author includes an integrity attribute on JavaScript and CSS tags, specifying the cryptographic digest of the resource being loaded from the third party. When the browser fetches the resource, it computes the file's digest and compares it with the value from the integrity attribute. If the values match, the resource is loaded. Otherwise, the browser refuses to load the resource.
W3C Working Draft http://www.w3.org/TR/SRI/
GitHub blog on it: http://githubengineering.com/subresource-integrity/
Could have a compute hash with local file type approach
Sounds pretty cool. This isn't in the plan for this release, but certainly worth looking at in the future.
Unclear what we could do that was correct and worked at runtime.
I'd like to vote to bring this back...
Unclear what we could do that was correct and worked at runtime.
Given:
<script src="~/dist/vendor.js" asp-append-version="true"></script>
You're already generating a SHA256 hash on the file contents.
This value, base64 encoded, could be exposed as the integrity attribute along with adding the appropriate crossorigin attribute.
Re-opening for discussion. The bug triage team will review again.
@Eilon - FYI this issue is still closed.
Buuuut I was thinking about this. If we're generating the SRI based on the hash of the file, and our system is compromised, it doesn't actually provide a huge a mount of benefit - we'll just generate a new hash which matches the compromised file and the browser will happily carry on.
It might help in the case where someone meddles with the resource on the wire, but given HTTPS is taking over I'm not sure how much of a concern this is.
Oops, I must have pressed the wrong button! Actually re-opened now.
Moved this out to 2.2.0 as we won't be doing this earlier than that.
@DamianEdwards, any suggestions regarding this?
This is not a priority for the 2.2 release, hence closing again. Let's re visit after 2.2
Most helpful comment
I'd like to vote to bring this back...
Given:
You're already generating a SHA256 hash on the file contents.
This value, base64 encoded, could be exposed as the
integrityattribute along with adding the appropriatecrossoriginattribute.