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
- 1Pin the URL to a release tag or, better, a full commit SHA: cdn.jsdelivr.net/gh/owner/repo@<sha>/file.js.
- 2Add an integrity attribute once the URL is immutable.
- 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
<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
curl -s https://cdn.jsdelivr.net/gh/owner/repo@<sha>/dist/widget.min.js \
| openssl dgst -sha384 -binary | openssl base64 -AReferences
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.
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 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.