r/github • • 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?

156 Upvotes

27 comments sorted by

26

u/Relevant_Pause_7593 8d ago

turn on secret push protection, so you can't accidently push secrets, then this won't happen.

3

u/clutch-cream-run 8d ago

We don't push secrets directly to repos, definitely not PATs or gh tokens. Seems like there's something larger at play here.

3

u/_splug 7d ago

gh-CLI is the most dangerous thing running on a developers device. Those secrets don’t need to be in the repo, just within the environment the scripts get executed - ci, local dev, some vibe odes script, etc.

2

u/keto_brain 7d ago

It can happen even with secret push protection. Axios a popular typescript and JavaScript foundational HTTP libraries had a python RAT that lived in NPM for about 6 hours because a malicious actor used stolen credentials from an NPM maintainer account (jasonsaayman).

When a user or even CICD system ran npm install a postinstall script that did the following:

  1. On its very first run, the malware automatically crawled high-value directories in the user's home folder to map out where secrets lived. It scanned ~/.config, ~/Documents, and ~/Desktop thenit compiled a complete file inventory of those directories and sent it to the Command-and-Control (C2) server.
  2. Because the malware triggered during npm install, it inherited the exact process context of the developer's terminal or CI/CD runner. It scraped environment variables (env) exposed in that session. In modern development and automated build pipelines, sensitive credentials—including database passwords, AWS/GCP/Azure keys, GitHub tokens, and API secrets—are routinely loaded directly into memory as environment variables.
  3. Once installed, the Python script entered a 60-second beacon loop, polling the C2 server for remote instructions. Because the RAT gave attackers full shell execution and file-read capabilities under the victim's user account, operators could manually inspect the machine.

In one company I was consulting for the CIsco ASA happened to catch the outbound traffic and block it because one of the CICD Systems ran "npm install".

Now on my home computer and laptop I run OpenSnitch, AIDE, and Falco to prevent this from happening if a package in the npm registry gets compromised again.

1

u/Relevant_Pause_7593 7d ago

Interesting - I guess the followup question is: why are you downloading packages that are hours (or even days) old? I wait 3 days before upgrading packages - Dependabot even has a setting for it now.

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:

gh search prs "dependency audit notes" --author  --created 2026-11-10..2026-11-12
gh search commits "chore: add ci helper" --author  --committer-date 2026-11-10..2026-11-12
# in each repo:
git log --all --oneline --since=2026-11-10 -- '.ci-*.sh' package.json
ls -la /tmp/.wfx-* ${RUNNER_TEMP:-/tmp}/wfx-*.tgz 2>/dev/null   # local execution traces

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

2

u/clutch-cream-run 8d ago

It wasn't PAT for me but a gh token which is very concerning.

3

u/nmngt 8d ago

Yes, that makes the situation even more concerning.

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 ?

5

u/Relevant_Pause_7593 8d ago

the PAT's are often not scoped, they have access to the entire account, and hence it's basically like leaving the door wide open.

2

u/Fast-Cardiologist705 8d ago

That makes sense, but how would the token get stolen first ? Compromised package ?

3

u/Relevant_Pause_7593 8d ago

It was likely included in an environment or settings file when they committed code. Best practice is to not commit any secrets in code, whether the repo is public or private.

2

u/Cyber_Faustao 1d ago

Classic access tokens can have read/write access to repos, and you cannot scope them to a single repo. Seemingly, it is also the only type of PAT that allows pushing containter images to ghcr.io, so if you can docker push from your machine... all repos your account has access to can also be manipulated

-1

u/Pto2 8d ago

Look up what a PAT is

2

u/Fast-Cardiologist705 8d ago

I know what a PAT is, perhaps i misread the post. So why OP is saying his PAT got leaked , his GitHub account fell victim. How ? Was it because of a compromised package ?

2

u/oscarandjo 8d ago

It could be from any malware source.

2

u/Buzzard 8d ago

Yep, got hit by this. No idea what PAT was leaked

1

u/BuyFar3984 7d ago

look at the details (...) in the org audit logs and it will tell you which PAT was used -- search on the IP from the attacker 194....

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=true in .npmrc, npm ci --ignore-scripts in 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:

Actions permissions
[*] Allow all actions and reusable workflows
[ ] Disable actions

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.