Skip to content
Write-up Intermediate

Repo Jacking: Exploiting the Dependency Supply Chain

Projects that depend on GitHub repositories via direct URLs become vulnerable when the repository owner changes their username, because the old username can be re-registered by anyone. An attacker can then recreate the repository and serve malicious code to any project that still references the old URL.

blog.securityinnovation.com

Published on blog.securityinnovation.com

Three scenarios enable GitHub repositories to be hijacked. Linking directly to them may result in malicious code injection; don’t do it.

Indiana Moreau, on blog.securityinnovation.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the root cause is that projects use direct GitHub repository URLs as dependencies, and GitHub allows old usernames to be re-registered and redirects to break when a repository is recreated.

Impact

Over 70,000 open-source projects could be affected, allowing remote code injection into projects that depend on hijacked repositories.

What the attacker needed

Project depends on a GitHub URL; repository owner changes username; attacker registers old username

The fix

Projects should avoid direct GitHub URL dependencies and instead use a package manager with version pinning and lock files, or vendor dependencies.

How it was found

  1. Find a project that directly references a GitHub repository URL as a dependency.
  2. Wait for the owner of that repository to change or delete their username.
  3. Register the old username on GitHub.
  4. Recreate a repository with the same name as the original.
  5. Any project that depends on the old URL will now download code from the attacker's repository.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When a project uses code from a GitHub repository, it often links directly to that repository's web address. If the person who owns that repository later changes their username, the old username becomes free for anyone to take. An attacker can take that username, create a repository with the same name, and any project still using the old link will download the attacker's code instead of the original.

Similar reports

Same bug class and techniques, clearest first.