Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Subresource Integrity any useful for inline JavaScript?

I'm reading about Subresource Integrity and understand it's meant for verifying external files. I guess it's no surprise I couldn't find any reference to inline JavaScript from either MDN or W3C.

So, is it safe to say that the SRI-related attributes, integrity and crossorigin, are completely useless for inline JavaScript ?

like image 480
Ron Martinez Avatar asked Oct 23 '25 21:10

Ron Martinez


1 Answers

So, is it safe to say that the SRI-related attributes integrity and crossorigin are completely useless for inline JavaScript?

Yes, because those attributes are only useful for a script element that has a src attribute:

https://html.spec.whatwg.org/multipage/scripting.html#attr-script-integrity

The integrity attribute represents the integrity metadata for requests which this element is responsible for. The value is text. The integrity attribute must not be specified when embedding a module script or when the src attribute is not specified. [SRI]

Also as noted in the question, that’s also made clear by the description in MDN:

https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity

Subresource Integrity (SRI) is a security feature that enables browsers to verify that files they fetch (for example, from a CDN) are delivered without unexpected manipulation. It works by allowing you to provide a cryptographic hash that a fetched file must match.

like image 128
sideshowbarker Avatar answered Oct 26 '25 10:10

sideshowbarker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!