The Actual Risk
Every third-party script tag is a standing grant of code execution on your site to whoever controls that CDN or origin - not just at the moment you added the tag, but every single time a browser loads that URL. If that CDN is compromised, or a build pipeline pushes a bad update to a shared path, every site referencing it is affected simultaneously - this is exactly how several real supply-chain attacks against widely-used JS libraries have played out.
SRI closes that gap for the specific case where the file at a URL changes unexpectedly: you supply a cryptographic hash of the exact file you expect, and the browser refuses to execute anything that doesn't match it byte-for-byte.
How to Add SRI
1. Get the hash
Most CDNs (cdnjs, jsDelivr) publish the SRI hash alongside the script tag directly on their site. To generate one yourself:
1cat lib.js | openssl dgst -sha384 -binary | openssl base64 -A2. Add integrity and crossorigin to the tag
1<script
2 src="https://cdn.example.com/lib.js"
3 integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC"
4 crossorigin="anonymous"
5></script>crossorigin is required alongside integrity- without it, the browser can't read the response to verify the hash at all, and silently skips the check.
3. Apply it to stylesheets too
1<link
2 rel="stylesheet"
3 href="https://cdn.example.com/styles.css"
4 integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk"
5 crossorigin="anonymous"
6/>How Scanverra Detects This
Scanverra's security scan inspects every <script> tag loading from an external origin and flags any that has no integrity attribute, so you get a concrete list of which third-party resources are running without any tamper protection.