How to fix: ES module imported from an unversioned CDN specifier
An import statement pulls a module from a CDN with no version in the specifier. esm.sh, Skypack and esm.run all resolve such a specifier to the newest published release at request time.
Why it matters
The browser executes whatever that package published most recently. A compromised maintainer account, or a package that changes hands, reaches every visitor on the next page load with no deploy and no review. These CDNs also transitively rewrite the package's own dependencies to the same unversioned form, so a single bare import can pull in a whole tree of code chosen at request time.
Distinct from a script tag without SRI: this is inside module code, so it is not visible in the markup a reviewer scans, and ES module imports cannot carry an integrity attribute at all. The version in the specifier is the only pin available, and esm.sh and Skypack both accept an exact one.
How to fix it
- 1Pin an exact version in every CDN import specifier.
- 2Prefer bundling these modules into your own build, where the lockfile and SRI both apply.
- 3Restrict script-src in CSP to the specific CDN host so an unexpected origin cannot be introduced later.
Code examples
Pin the specifier
// Resolves to whatever is newest right now
import confetti from 'https://esm.sh/canvas-confetti';
// Pinned
import confetti from 'https://esm.sh/[email protected]';Or bundle it and serve it yourself
npm install [email protected]
npx esbuild src/main.js --bundle --format=esm --outfile=public/main.jsReferences
Detected automatically by VulnRadar. The check id is supply-chain-esm-cdn-unpinned-import, 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 ES module imported from an unversioned CDN specifier?
- 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-esm-cdn-unpinned-import, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does ES module imported from an unversioned CDN specifier map to?
- It maps to CWE-1357. 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.