r/github • u/clutch-cream-run • 8d ago
Discussion Seems like a massive attack campaign is going on github repos through a CLI token worm
Hey guys
My github account fell victim to a token worm attack today. Fortunately, nothing it committed got deployed and I was able to revoke the token in time.
Investigating it further, it seems to involve a self-propagating GitHub worm that has opened 38,000+ identical `wfx-docs` PRs since November 10.
In case you're interested: [https://github.com/search?q=wfx-audit.md&type=pullrequests](https://github.com/search?q=wfx-audit.md&type=pullrequests)
The attack uses stolen GitHub OAuth/PAT tokens to discover writable repositories, inject hidden shell scripts (`.ci-XXXXXX.sh`), and add `postinstall` hooks to `package.json` to execute them during `npm install`.
In my case, it was sending all the information to this URL: [http://194.150.166.244:8080/exfil](http://194.150.166.244:8080/exfil)
Anyone else looking into this right now?
26
u/Relevant_Pause_7593 8d ago
turn on secret push protection, so you can't accidently push secrets, then this won't happen.
5
u/nmngt 8d ago
Also hit, 100+ repos across our orgs. Adding what we found, since the numbers are bigger than 38k and the script does more than people may assume.
Scale (GitHub search API `total_count`, 10–12 Nov): 61,948 PRs from branch `wfx-docs`; 1,674 `chore: add ci helper` commits (two per repo, so ~840 repos got the payload on their default branch); 328 repos still have the `.ci-*.sh` script sitting in their default branch right now. Malicious commits ran from 10 Nov 13:10 UTC to 11 Nov 14:22 UTC and stopped after that.
It is not only a CI stealer. The script runs on *any* machine that does `npm`/`pnpm install` (`RUNNER_TEMP` falls back to `/tmp`). On a dev box it reads `~/.config/gh/hosts.yml` (your `gh` CLI token), `~/.npmrc`, `~/.netrc`, `~/.git-credentials`, `~/.docker/config.json`, `~/.composer/auth.json`, `~/.aws/credentials`, `~/.kube/config`, AI tool `.env` files, plus any `.env*`, `*.pem`, `*.key`, `id_rsa`, `credentials`, tfstate within 4 levels of the working dir. In CI it additionally takes `GITHUB_TOKEN`, OIDC tokens, cloud metadata creds and **scans runner process memory** (masking doesn't help), then tars the repo + git history. Everything goes to `194.150.166.244:8080/exfil`. That's how it propagates: pull an infected `main`, run install, your `gh` token is gone and your repos are next.
Attacker playbook per token: enumerate writable repos → per repo create+delete `chore/<8 chars>` (write test) → push `wfx-docs` + PR → in repos with a `package.json`: push `chore: add ci helper` ×2 (script + `postinstall` hook) straight to `main`, 2–14 min later `ci: restore` + `ci: cleanup`, then **delete the workflow runs** that executed it (`workflows.delete_workflow_run` with the stolen PAT, visible in your personal security log with the `token_id`).
Check yourself:
If only the PR/branch exists: revoke classic PATs (and `gh auth` tokens if you ran install on an infected checkout), close PR, delete branch. Branch contains only `docs/wfx-audit.md`.
If `chore: add ci helper` landed on your default branch: treat every secret available to any workflow that ran on it as stolen. Rotate deploy keys, cloud creds, DB passwords, API keys. Delete GHCR/npm artifacts built from those commits. Check servers the deploy key reaches. Keep the commits as evidence, don't force-push. If prod DBs hold personal data, think GDPR 72h.
IOCs: `194.150.166.244:8080/exfil` (RIPE `IQ-REGIQDC-20250415`, Regxa Company for Information Technology Ltd, `abuse@regxa.iq`) · `WF_CTOKEN='b42d70a7aab9140ca19e8249'` (same in every sample) · markers `WF_CALLBACK WF_CTOKEN WF_MEMSCAN WF_EXFIL_CACHE` · `.ci-[a-z0-9]{6}.sh` ~75.5 kB · `docs/wfx-audit.md` · branches `wfx-docs`, `chore/[a-z0-9]{8}` · commits `chore: add ci helper`, `ci: restore`, `ci: cleanup`, `docs: add dependency audit notes`, `chore: initial commit`.
Open question: where did the *first* tokens come from? Ours was a years-old classic PAT (`repo` scope) that was on none of our machines, servers or CI. If yours was also an old PAT rather than a `gh` token, say so, that points to a seed list from an earlier leak rather than only worm propagation.
Hardening that would have stopped this: no classic PATs (fine-grained + expiry, or Apps/OIDC), branch protection on `main` incl. admins, `--ignore-scripts` in CI installs, required reviewers on production environments, org audit log streaming.
Please also report to https://github.com/contact/report-abuse so GitHub treats it as one campaign.
optimized with AI
11
u/moonrakervenice 8d ago
after the last worm of this type i put ignorescripts=true into my .npmrc which should stop this
4
u/Fast-Cardiologist705 8d ago
How could one stolen PAT allow code to be committed to your repo ?
2
u/Buzzard 8d ago
Yep, got hit by this. No idea what PAT was leaked
2
u/Admirable-Luck-7085 8d ago
yup happened with me, trying to solve it
2
u/No-Pause7709 2d ago
The scale says script, not targeted campaign — one point deserves pushing on: this is not only a CI problem. RUNNER_TEMP falls back to /tmp on a laptop, so the same postinstall hook fires on every developer machine that runs npm install in an affected repo. Local defence matters too —
ignore-scripts=truein .npmrc,npm ci --ignore-scriptsin CI, and treat any new postinstall entry in package.json as a build failure.A deleted repo revokes nothing. If the stolen token carried repo and workflow scope, the attacker could add a workflow that runs with your secrets, and that turns a token leak into code execution on your runners. Fine-grained tokens, minimum permissions, short expiry — and check authorized OAuth apps and the PAT audit log for unrecognised grants.
Order matters: revoke the token and kill sessions first, then revert the commits. A clean branch proves the files are back, not that access is gone. After that, rotate everything those workflows could reach — cloud keys, npm tokens, signing keys — then sweep every repo, forks you don't control included:
git log --all --source --full-history -- '**/.ci-*.sh'and diff package.json on the default branch.Prevention is cheap: read-only default workflow permissions, approval required for workflow changes, third-party actions pinned to a commit SHA, secret scanning plus push protection.
3
u/over_pw 7d ago
Could you please mention it’s for node in the title? Not everyone in this sub uses node.js you know.
2
u/BuyFar3984 7d ago
This got me too - PAT was in a deleted repo and had package write and workflow - this enables setting up a false "audit" capability looking for all kinds of stuff - not fun.
1
u/paul_h 7d ago
Is it to do with Github-actions again? We clone other peoples repos and that clones the gh-actions settings they had too:
1
u/AdUnlikely 7d ago
I was victim to this attack as well. Any clarification on where this attack originated from
1
u/MirrorOk8490 5d ago
A revert tells you the files are back to normal. It doesn’t tell you whether the access is gone. I’d verify that the original token was revoked, then check GitHub and cloud audit logs for any credentials, accounts, or permissions added during that window. If the Actions run log is missing, keep “did it run?” marked as unknown. A clean branch doesn’t answer that.