# Hijacking GitHub Repositories by Deleting and Restoring Them

GitHub's popular repository namespace retirement could be bypassed by deleting a repo, renaming the account, then restoring it under the retired name, enabling repo jacking.

- Payout: $4,000
- Severity: high
- Program: GitHub
- Credited: Joren Vrancken
- Disclosed: 2022-12-04
- Write-up quality: 8/10
- Original: https://blog.nietaanraken.nl/posts/gitub-popular-repository-namespace-retirement-bypass/
- Library page: https://bugbountylibrary.com/r/blog%3Ablog-nietaanraken-nl-posts-gitub-popular-repository-namespace-retirement-bypass
- Tags: domain:web impact:integrity kind:bounty platform:blog sev:high tech:ci-cd technique:chained technique:incomplete-fix vuln:access-control vuln:business-logic

**Target:** GitHub repository namespace / repo restore feature
**Root cause:** Repository restore uses the account's current username rather than the name at deletion time, and no central check verifies the restored repo name isn't retired.
**Steps:**
1. Find a repo protected by popular repository namespace retirement, e.g. `victim/python-package`.
2. Register account `victim1` and create `victim1/python-package`.
3. Delete `victim1/python-package`.
4. Rename `victim1` to `victim` (possible since python-package no longer exists under victim1).
5. Wait 1 hour (restore cooldown).
6. Restore the deleted repo; it is recreated as `victim/python-package`, breaking the redirect.
**How found:** Researcher tested what happens when restoring a deleted repo after renaming the account back to the retired username, noticing restore uses the current username rather than the deletion-time name.
**Exploitation:** Attacker gains full control of the retired namespace `victim/python-package`, so downstream packages/CI cloning that path receive attacker code instead of the legitimate redirected repo, enabling supply-chain compromise.
**Escalation:** Single hijacked repo propagates to all direct and indirect downstream dependents via GitHub redirects, amplifying supply-chain impact.
**Insight:** When a platform enforces a namespace/name reservation on creation, test alternate creation paths (restore, transfer, rename, fork) that may skip the central check; here restore re-derived the owner from the current account name.
