Add support for Subresource Integrity on MDN.
I know it's a bit early, so see it more as a "future-todo".
I'm not sure this is polyfillable. We can obviously ship implementations of the SHA algorithms, but is it possible to stop a browser loading and parsing a script that has been written into the markup?
i was not thinking about polyfilling SRI in itself - instead support the integrity attribute.
I'm not sure I understand what you mean, sorry. HTML5 parsers ignore all unknown attributes automatically so if we're not doing anything with the integrity attribute there should be no need to explicitly 'support' it...
I think I understand the what is being asked.
Subresource Integrity is a mechanism between the developer, the resource provider (like a CDN, like cdn.polyfill.io) and the browser. The browser does not run the script if the CDN does not provide the script that has the hash the author has provided as integrity attribute.
It could be useful for people relying on cdn.polyfill.io to be sure that the served scripts are the expected ones (polyfills) and don't contain any tracking or cookie stealing code (not accusing the FT of being malicious, but DNS poisoning or other MITM attacks can happen).
That being said there are several things that can be said:
polyfill-service could provide the hashes in the docs so people can easily copy/paste in their HTMLs (sort of, see below)But the FT providing the hashes comes with a massive drawback:
integrity attribute on a per UA basis, which becomes a ridiculous amount of work (unless they use the always flag or ua to have a stable script being served).All in all, it looks like Subresource Integrity is a lot of work on all sides... to which point installing on your own server seems like a more reasonable solution to have a trustworthy service. It doesn't prevent the MITM, but your entire website is under attack then, so at this point, the integrity of the polyfills hosted on your server probably isn't the biggest problem.
Thanks David, that is really very helpful, and I'd agree with you.
Most helpful comment
I think I understand the what is being asked.
Subresource Integrity is a mechanism between the developer, the resource provider (like a CDN, like cdn.polyfill.io) and the browser. The browser does not run the script if the CDN does not provide the script that has the hash the author has provided as
integrityattribute.It could be useful for people relying on cdn.polyfill.io to be sure that the served scripts are the expected ones (polyfills) and don't contain any tracking or cookie stealing code (not accusing the FT of being malicious, but DNS poisoning or other MITM attacks can happen).
That being said there are several things that can be said:
polyfill-servicecould provide the hashes in the docs so people can easily copy/paste in their HTMLs (sort of, see below)But the FT providing the hashes comes with a massive drawback:
integrityattribute on a per UA basis, which becomes a ridiculous amount of work (unless they use thealwaysflag oruato have a stable script being served).All in all, it looks like Subresource Integrity is a lot of work on all sides... to which point installing on your own server seems like a more reasonable solution to have a trustworthy service. It doesn't prevent the MITM, but your entire website is under attack then, so at this point, the integrity of the polyfills hosted on your server probably isn't the biggest problem.