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

How to fix: Script loaded from GitHub raw content

A script element on this page loads its source from raw.githubusercontent.com or gist.githubusercontent.com.

Why it matters

GitHub's raw endpoints are not a CDN and make no immutability promise for a branch path: the content changes the moment someone pushes. Anyone with write access to that repository, or to that gist, controls executable code on your origin. For a gist the blast radius is smaller only in that fewer people have access, which also means less oversight of who does.

The raw hosts serve with a short cache lifetime and rate limit aggressively, so this also fails intermittently under load. If the reference has to stay, a permalink to a full commit SHA is immutable and can be paired with an integrity hash. The better answer is to vendor the file into your own build, where it goes through the same review as everything else you ship.

How to fix it

  1. 1Vendor the file into your own repository and serve it from your origin.
  2. 2If it must be remote, use a full commit-SHA permalink and add an integrity attribute.
  3. 3Restrict script-src in CSP so githubusercontent hosts are not an allowed script source.
  4. 4Check who has write access to the source repository, since they currently have script execution on your site.

Code examples

Vendor it instead

bash
curl -sL https://raw.githubusercontent.com/owner/repo/<sha>/dist/widget.js \
  -o public/vendor/widget.js
# then reference /vendor/widget.js and commit it

CSP that excludes raw hosts

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

References

Detected automatically by VulnRadar. The check id is supply-chain-github-raw-script-source, stable across every scan so you can filter or diff on it.

See every supply chain check

Questions

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

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 GitHub raw content fix | VulnRadar