Subresource Integrity
A browser check in which a script or stylesheet tag carries the expected hash of the file, and the browser refuses to use the file if it does not match.
In more detail
SRI stands for Subresource Integrity. The integrity attribute holds an algorithm and a Base64 hash, such as sha384-..., so a tampered file on a compromised CDN is blocked with a network error instead of running. Cross-origin files also need the crossorigin attribute.
Example
<script src="https://cdn.example.com/lib.js" integrity="sha384-..." crossorigin="anonymous"></script>Related terms
- hash — A short fixed-length fingerprint calculated from data, which changes completely if even one byte of the data changes.
- SHA-256 — A widely used hash function that turns any data into a 256-bit fingerprint, shown as 64 hexadecimal characters.
- crossorigin attribute — The HTML attribute that makes the browser fetch a resource using CORS, anonymous meaning without cookies.
- content delivery network — A network of servers around the world that keep copies of a site's files and serve each visitor from a nearby location.
- software supply chain — Everything that goes into your software before it runs: base images, packages, build tools, CI systems and registries.
Taught in
- CSRF Mitigations, SameSite Cookies And Subresource Integrity — Frontend Architecture & Web Platform