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

How to fix: Script loaded from a jsDelivr GitHub branch reference

The page loads an asset through jsDelivr's GitHub passthrough at a moving reference. The URL carries no @tag at all, or one of @master, @main, @latest or @HEAD.

Why it matters

The file that executes is whatever that branch points at when the browser fetches it. A push to the repository, by any collaborator or by anyone who compromises the account, changes what runs on your page without touching your deployment. Unlike jsDelivr's npm path, there is no registry publish step and no immutable version, so nothing is reviewed between a commit and your users.

jsDelivr supports pinning /gh/ URLs to a tag or a full commit SHA, and a pinned URL is served immutably and cached indefinitely. A branch reference deliberately opts out of that. This is a distinct problem from a missing SRI hash: an integrity attribute would break on every legitimate push, so the fix is to pin the reference rather than to add a hash to a moving target.

How to fix it

  1. 1Pin the URL to a release tag or, better, a full commit SHA: cdn.jsdelivr.net/gh/owner/repo@<sha>/file.js.
  2. 2Add an integrity attribute once the URL is immutable.
  3. 3For anything you depend on seriously, vendor the file into your own build instead of loading it from a third-party repository.

Code examples

Pin to a commit and add SRI

HTML
<script
  src="https://cdn.jsdelivr.net/gh/owner/repo@3f2b9c1d5a4e8f70b1c2d3e4f5a6b7c8d9e0f1a2/dist/widget.min.js"
  integrity="sha384-REPLACE_WITH_REAL_HASH"
  crossorigin="anonymous"></script>

Compute the hash

bash
curl -s https://cdn.jsdelivr.net/gh/owner/repo@<sha>/dist/widget.min.js \
  | openssl dgst -sha384 -binary | openssl base64 -A

References

Detected automatically by VulnRadar. The check id is supply-chain-jsdelivr-gh-branch-reference, stable across every scan so you can filter or diff on it.

See every supply chain check

Questions

How severe is Script loaded from a jsDelivr GitHub branch reference?
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-jsdelivr-gh-branch-reference, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Script loaded from a jsDelivr GitHub branch reference 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 script loaded from a jsdelivr github branch reference

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

Script loaded from a jsDelivr GitHub branch reference | VulnRadar