Cleaning GitHub repositories
PolinRider steals a token, then pushes its backdoor to every branch it can reach. pushwarden github-clean checks every branch of every repository your token can push to, and fixes them with Pro.
Prefer screens? Run pushwarden ui (guided screens).
Steps
pushwarden github-clean --list # 1. which repositories can I push to?
pushwarden github-clean # 2. check them all (changes nothing)
pushwarden github-clean --apply # 3. fix and push (Pro)
Checking is free. Fixing and pushing need Pro. In a terminal, the check ends with a question: “Fix and push these branches now?” Answer y to fix in the same run.
What fixing does
- one normal commit on each infected branch
- your history is never rewritten, and nothing is force-pushed
- a refused push (protected branch, archived repository) is reported, not forced
- your teammates just
git pull
The token
Create a fine-grained token with Contents: Read and write on the repositories you want cleaned (a classic token needs repo). PushWarden also finds a token from GITHUB_TOKEN, GH_TOKEN or the gh login.
pushwarden github-clean --token ghp_xxx
op read op://Vault/GitHub/token | pushwarden github-clean --token-stdin
The token is never saved to disk or to the report. Change it after the clean-up.
Another account? Run it again with that account’s token, or use the guided screens, which switch accounts for you.
Choose what to clean
pushwarden github-clean --select --apply # pick from a list
pushwarden github-clean --repo me/api --repo me/web # these repositories
pushwarden github-clean --owner my-org --branch main # one organisation, one branch
Forks and archived repositories are skipped unless you add --include-forks or --include-archived.
Stop and continue
Every finished branch is remembered. If you stop (Ctrl-C, sleep, no internet), run the same command again. Branches that have not changed are skipped. A branch is checked again when someone pushes to it or PushWarden is updated.
pushwarden github-clean --progress # what is already checked
pushwarden github-clean --fresh # forget it and check everything
Reading the result
| Status | Meaning |
|---|---|
clean |
nothing to do |
infected |
the check found something |
pushed |
fixed and pushed |
push-failed |
fixed, but GitHub refused the push |
manual |
needs your review |
error |
something failed |
Exit code: 0 all clean or fixed, 1 infected branches remain, 2 token or network problem.
After the clean-up
- Change the token you used and any secret those repositories could read.
- Look in GitHub Settings, Applications and Deploy keys for anything you did not add.
- Tell your team to
git pull. - Quarantined originals are in
pushwarden history.
Remember
- It checks first. Nothing changes without
--applyor youry. - For a company:
pushwarden github-clean --owner my-org --json dryrun.json, review it, then add--apply. - GitHub Enterprise: add
--api https://github.example.com/api/v3. - All options are in the reference.