--- title: "Subresource Integrity" description: "Understanding Subresource Integrity" date: "2023-04-29" badge: "Security" --- Understanding Subresource Integrity In my junior year while I was learning HTML and CSS I got to use the Bootstrap css library. The easiest way to obtain the files was from a Content Delivery Network(CDN). I could see links such as: ```html ``` I didn't bother with the `integrity` attribute of the link(guess I wasn't curious enough). The integrity attribute has a cryptographic hash value that is important in CDNs and its called the Subresource Integrity. Subresource Integrity (SRI) is a security feature in web browsers that helps prevent malicious or compromised scripts from being loaded and executed on a website. It is a security feature that enables browsers to verify that resources 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 resource must match. When a resource, such as a script or stylesheet, fails the SRI check, the browser will block the resource from being loaded and displayed on the website. ## How Subresource Integrity Helps SRI helps protect against supply chain attacks where a CDN or third-party host is compromised. By verifying the hash of the fetched resource, the browser ensures the content hasn't been tampered with. ## Using it To use SRI, you add an `integrity` attribute to the `