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

How to fix: Import map resolves to an unversioned CDN URL

An import map on this page resolves a bare module specifier to an unversioned CDN URL. The path carries no version at all, or an explicit @latest.

Why it matters

Every module the page imports through that specifier is fetched fresh from whatever the CDN currently serves, so the code running in your users' browsers changes when the package publishes, without any deploy on your side. A malicious or compromised release reaches every visitor immediately, and import maps cannot carry an integrity attribute, so there is no hash to catch it.

This is the module-graph version of an unpinned script tag, and it is worse in one specific way: a script tag can carry integrity, an import map entry cannot. That makes the version pin the only control available. Pinning is also what makes the page reproducible, since an unversioned specifier means two users loading the page a week apart can run different code.

How to fix it

  1. 1Put an exact version in every import map URL. Prefer a specific patch version over a range.
  2. 2Better still, bundle these modules and serve them from your own origin, where SRI and your own CSP apply.
  3. 3Restrict script-src in CSP to the specific CDN origin so an unexpected host cannot be introduced.
  4. 4Automate version bumps through your dependency updater rather than relying on the CDN to hand you the newest build.

Code examples

Pin every entry

HTML
<script type="importmap">
{
  "imports": {
    "lit": "https://cdn.jsdelivr.net/npm/[email protected]/index.js",
    "preact": "https://cdn.jsdelivr.net/npm/[email protected]/dist/preact.module.js"
  }
}
</script>

Constrain where modules may come from

text
Content-Security-Policy: script-src 'self' https://cdn.jsdelivr.net; object-src 'none'; base-uri 'none'

References

Detected automatically by VulnRadar. The check id is supply-chain-importmap-unpinned-cdn, stable across every scan so you can filter or diff on it.

See every supply chain check

Questions

How severe is Import map resolves to an unversioned CDN URL?
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-importmap-unpinned-cdn, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Import map resolves to an unversioned CDN URL 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.

Propose a checkHow a check is built

Scan your own site for import map resolves to an unversioned cdn url

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

Import map resolves to an unversioned CDN URL | VulnRadar