Loading...
Loading...
SRI ensures that files you load from CDNs (like jQuery or Bootstrap) haven't been tampered with.
Supply Chain Attack: If you load `https://cdn.example.com/lib.js` and that CDN gets hacked, attackers can replace `lib.js` with malware. Your site will unwittingly execute this malware for every visitor. SRI prevents this by verifying the file's hash before execution.
The `integrity` attribute contains a base64-encoded cryptographic hash. If the downloaded file doesn't match the hash, the browser blocks it. This is mandatory for high-security applications.
SRI is verifiable in the HTML itself. Every `<script src="...">` and `<link rel="stylesheet" href="...">` that loads from a cross-origin CDN should carry an `integrity` attribute and a `crossorigin` attribute. Missing `integrity` on a cross-origin asset is the finding.
curl -s https://yourdomain.com | grep -E "src=\"https?://[^\"]+\"|href=\"https?://[^\"]+\"" | grep -v integritycat library.js | openssl dgst -sha384 -binary | openssl base64 -Ahttps://www.srihash.org/`sha384` is the standard choice and matches what MDN and most CDN documentation recommend. `sha512` is fine but offers no meaningful security gain for this use case. `sha256` works but is slightly weaker. Do not use `sha1` or `md5` - modern browsers will refuse them.
Pin to a specific version in the URL, regenerate the SRI hash during your release process, and treat it like any other dependency bump. Tools like `npm`'s `integrity` field in `package-lock.json` handle this automatically for npm-hosted packages.
No. SRI ensures a trusted file was loaded unmodified. It does not check what the file does. XSS protection comes from CSP. Use both together.
Applied the configuration change? Run a live scan to confirm the vulnerability is patched.