How to fix: External CDN Script Without SRI Hash
An external JavaScript file is loaded from a CDN without a Subresource Integrity (integrity=) attribute. If the CDN is compromised or serves a different file version, malicious code can run on your site without detection.
Why it matters
CDN compromises (Polyfill.io 2024, event-stream 2018, ua-parser-js 2021) have injected malicious code into millions of sites. SRI is the primary defense: it makes CDN tampering immediately detectable and blocks execution of modified scripts.
When you load a script from a CDN without SRI, you're trusting that CDN completely. SRI lets you cryptographically pin the exact bytes of the script you tested, so any modification by a compromised CDN is blocked.
How to fix it
- 1Generate SRI hash: npx sri-hash https://cdn.example.com/script.js
- 2Add integrity and crossorigin attributes to all external script and link tags.
- 3Pin to specific versions in CDN URLs, avoid 'latest' or major-version aliases.
- 4Consider self-hosting critical scripts instead of relying on CDNs.
Code examples
SRI-protected script tag
<script
src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"
integrity="sha512-WFN04846sdKMIP5LKNphMaWzU7YpMyCU245etK3g/2ARYbPK9Ub18eG+ljU96qKRCWh+quCY7yefSmlkQw1ANQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>References
Detected automatically by VulnRadar. The check id is supply-chain-sri-external-script, stable across every scan so you can filter or diff on it.
More supply chain checks
- Mediumnpm/yarn Lock File Exposed
- MediumPython Requirements File Exposed
- MediumRuby Gemfile or Gemfile.lock Exposed
- HighHTTP Script Loaded on HTTPS Page
- MediumPHP composer.json or composer.lock Exposed
- HighDockerfile or docker-compose.yml Exposed
- Critical.env File Exposed at Public URL
- MediumCDN Script With No Version Pin and No Integrity Hash
Questions
- How severe is External CDN Script Without SRI Hash?
- VulnRadar rates this medium severity in the supply chain category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id supply-chain-sri-external-script, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does External CDN Script Without SRI Hash map to?
- It maps to CWE-353. In the OWASP Top 10 it falls under A08:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.