Skip to content
Subdomain takeover Write-up Intermediate

More Than 1 000 Github Repositories At Risk How To Detect Repojacking Vulnerabilities

The researchers found that many GitHub repositories referenced by PyPI and NPM packages point to accounts that no longer exist but whose usernames can be re-registered. An attacker could claim such a username and replace the repository contents with malicious code, which dependent projects would then unknowingly use.

Denis Makrushin Follow

Published on infosecwriteups.com

In 2024, GitLab developers discovered two critical vulnerabilities in their system. Due to verification errors, attackers could hijack user accounts and modify repository contents.

Denis Makrushin, on infosecwriteups.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 platform allows deleted usernames to be re-registered, and dependent projects keep referencing the old repository path without checking that the owner is still the same.

Impact

An attacker could take over abandoned repository names and inject malicious code into projects that depend on them, potentially compromising many downstream applications.

What the attacker needed

A GitHub account; knowledge of vulnerable repository names; victim project depends on the abandoned repository

The fix

Developers should regularly check their dependencies for broken repository links and remove or replace any that return errors, and they should maintain an internal repository for dependencies.

How it was found

  1. Collect GitHub repository links from PyPI and NPM packages.
  2. Check which links return a 404 or 301 error, indicating a missing or moved repository.
  3. Test whether the associated GitHub usernames can be registered again.
  4. Cross-reference re-registerable usernames with repository links to count vulnerable repositories.

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 developer uses code from someone else's GitHub repository, their project depends on that repository staying under the same owner. If the owner deletes their account, the username becomes free. An attacker can then sign up with that same username and put harmful code in the repository, so every project that still points to it gets infected.

What is Subdomain takeover?

A company's DNS still points at a cloud service it no longer uses, so anyone can claim it and serve content on the company's domain.

Similar reports

View all

Same bug class and techniques, clearest first.

Subdomain takeover

The lesson behind this report.

A company's DNS still points at a cloud service it no longer uses, so anyone can claim it and serve content on the company's domain.