How to fix: CDN Script With No Version Pin and No Integrity Hash
A script is loaded from jsdelivr's npm alias or unpkg with no version number in the URL (or an explicit @latest) and no integrity attribute. Requesting the same URL tomorrow can return different bytes with nothing to catch the change.
Why it matters
Without a pinned version, the file served from the CDN can change at any time: a new release, a compromised package pushed by the upstream maintainer's account, or a CDN-level substitution. With no SRI hash either, the browser has no way to detect that the code it just executed is not the code you tested.
jsdelivr's /npm/ alias and unpkg both resolve a package path with no @version to whatever the latest published release is at request time. That is convenient during development but means production visitors can silently receive a different file than the one you reviewed, and there is no integrity check to catch a malicious or broken substitution.
How to fix it
- 1Pin every jsdelivr/unpkg script URL to an exact version, e.g. /npm/[email protected]/lodash.min.js instead of /npm/lodash/lodash.min.js.
- 2Add an integrity attribute with the SRI hash for that exact pinned version.
- 3Bump the pinned version deliberately (and regenerate the hash) as part of a reviewed change, not automatically.
- 4Consider self-hosting the script if it changes rarely, removing the CDN dependency entirely.
Code examples
Pinned version with SRI hash
<!-- BAD: resolves to whatever is newest right now -->
<script src="https://cdn.jsdelivr.net/npm/lodash/lodash.min.js"></script>
<!-- GOOD: exact version, verified with SRI -->
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js"
integrity="sha384-abc123..."
crossorigin="anonymous"
></script>References
Detected automatically by VulnRadar. The check id is supply-chain-cdn-script-unpinned-version, 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
- MediumExternal CDN Script Without SRI Hash
- 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
Questions
- How severe is CDN Script With No Version Pin and No Integrity 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-cdn-script-unpinned-version, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does CDN Script With No Version Pin and No Integrity Hash map to?
- It maps to CWE-829. 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.