A <script src="https://cdn.example.com/lib.js"> tag runs whatever that CDN serves, with full access to your page - your cookies, your DOM, your users' input. Subresource Integrity is the one line that lets the browser refuse to run it if that file ever changes.
For the background on why third-party scripts need integrity checks, see what is subresource integrity. This guide shows how to add it.
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:
2. Add integrity and crossorigin to the tag
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
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.
