Subresource Integrity hashes for third-party CDN scripts
Why it matters
Third-party scripts loaded from CDNs without Subresource Integrity (SRI) hashes execute in your users' browsers with full page access — if the CDN is compromised or the script URL is hijacked, attackers can inject arbitrary JavaScript. CWE-829 (Inclusion of Functionality from Untrusted Control Sphere) and OWASP A08 (Software and Data Integrity Failures) both flag this. NIST 800-53 SA-9 requires controls on external services. A CDN supply chain attack targeting jQuery, Bootstrap, or Font Awesome affects every user of every site loading that URL — SRI hashes prevent the browser from executing a tampered file.
Severity rationale
Low because SRI failure only matters when the CDN is actively compromised, but when that occurs, every site loading the resource is immediately affected.
Remediation
Generate SHA-384 hashes for each CDN resource and add integrity and crossorigin attributes:
curl -s https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js | \
openssl dgst -sha384 -binary | openssl base64 -A
<script
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"
integrity="sha384-<hash-here>"
crossorigin="anonymous"
></script>
Prefer bundling CDN dependencies into your npm build (npm install jquery) and serving them self-hosted — this eliminates the CDN dependency entirely and makes SRI unnecessary. Most CDN providers list official SRI hashes on their documentation pages.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Security Hardening Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-829 — Inclusion of Functionality from Untrusted Control Sphere
- owasp:2021 · A08 — Software and Data Integrity Failures
- nist:rev5 · SA-9 — External System Services
Taxons
History
- 2026-04-18·v1.0.0·Initial import from security-hardening·automated