Skip to main content
MediumSupply chainOWASP A08:2021CWE-829

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

  1. 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.
  2. 2Add an integrity attribute with the SRI hash for that exact pinned version.
  3. 3Bump the pinned version deliberately (and regenerate the hash) as part of a reviewed change, not automatically.
  4. 4Consider self-hosting the script if it changes rarely, removing the CDN dependency entirely.

Code examples

Pinned version with SRI hash

HTML
<!-- 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.

See every supply chain check

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.

Propose a checkHow a check is built

Scan your own site for cdn script with no version pin and no integrity hash

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

CDN Script With No Version Pin and No Integrity Hash | VulnRadar