Subresource Integrity
Subresource Integrity (SRI) is a security feature that enables web browsers to verify that resources they fetch (e.g., scripts or stylesheets from a Content Delivery Network) are delivered without unexpected manipulation. It works by allowing developers to include a cryptographic hash of the expected resource in the HTML, which the browser compares against the fetched file. This helps prevent attacks where a third-party resource is compromised and serves malicious content.
Developers should use SRI when loading external resources from CDNs or third-party services to ensure integrity and protect against supply-chain attacks, such as when a CDN is hacked or a library is tampered with. It is particularly critical for security-sensitive applications like banking sites, e-commerce platforms, or any site handling user data, as it mitigates risks from man-in-the-middle attacks or compromised dependencies.