Repo Jacking: The Great Source-code Swindle
Source code management providers redirect old repository URLs after an organisation rename, and if the old name is released, an attacker can register it and fork the repository to serve malicious code. This allows compromise of software packages that reference the old URL, leading to remote code execution on systems that install them.
Published on snyk.io
In this post, we explore a powerful, yet widely unknown attack vector which has emerged in the last couple of years known as ‘Repo Jacking’. During our research, we discovered the enormous potential to compromise software components with tens of millions of downloads across the Terraform IaC (Infrastructure as Code)…
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 source code management provider releases the old organisation name for registration while continuing to redirect requests from the old URL, allowing an attacker to claim the name and serve a forked repository.
Impact
An attacker could execute arbitrary code on systems that install affected packages, potentially compromising CI/CD environments and production infrastructure, though the number of hijackable packages is a small fraction of each ecosystem.
What the attacker needed
Organisation renamed and old name released; attacker can register the old name; victim uses the old repository URL
The fix
The Terraform registry was fixed by pinning artifacts to commit SHAs and tying asset management to immutable GitHub IDs, and Packagist was fixed by blocking updates when the repository's unique ID changes.
How it was found
- Rename the GitHub organisation that owns the repository.
- Register the now-available original organisation name.
- Fork the original repository into the new organisation.
- Modify the forked repository to include a malicious payload.
- Create a release tag matching the version being requested.
- Run terraform init or composer require to trigger the payload.
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 company renames its account on a code hosting site like GitHub, the old web address still works because the site automatically redirects it to the new one. If the old name becomes available again, an attacker can take it and put their own copy of the code there. Anyone or any tool that still uses the old address will then download the attacker's code instead of the real code.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.