Library
/ 7 min read

How a worm got into our repos, and why we built repo-guard

TL;DR

On 18 November 2026 my Mac was infected by PolinRider, a worm that hides in the config files of JavaScript projects and spreads through git. We had been fighting it for months without knowing what it was. This week we traced it and cleaned my machine and our repos. Then we found it was still on old branches and tags in three repos we thought were clean.

So we built repo-guard, a free, open-source tool that scans a repo before any of its code can run. It has already found and removed the worm on a teammate's machine.

If you only do one thing after reading this, install repo-guard and scan the folder where you keep your repos. It takes about two minutes:

pipx install git-repo-guard
repo-guard setup
repo-guard scan-all ~/Dev
Enter fullscreen mode Exit fullscreen mode

How I got hacked

The worm runs as soon as you open an infected project in your editor, or run npm run dev, build or lint. The project starts normally, so nothing seems wrong. Meanwhile the malware runs in the background.

[TODO: which repo or download brought it onto my machine, and when I first noticed something was off.]

Once it's running, PolinRider does three things:

  1. It steals credentials. GitHub and npm tokens, cloud and SSH keys, and crypto wallets.
  2. It spreads. With the stolen tokens it rewrites commits in every repo the victim can push to, then force-pushes them. Anyone who pulls or clones those repos gets infected next.
  3. It hides. Its code sits off-screen in config files, on side branches and in old tags.

This is why cleaning one machine never fixed it. The infection also lived in the repos, waiting for the next person to pull or clone them.

PolinRider has been found alongside tools used by Contagious Interview, a long-running campaign linked to North Korea. The campaign targets developers with fake job interviews and take-home coding tests that contain malware. It's after money: credentials, tokens and crypto.

How we traced it

Every part of the worm hides somewhere developers don't usually look. Once we knew those places, we could find it every time.

Where it hides What we found Why we missed it
Config files (eslint.config.js, vite.config.mjs, postcss.config.mjs, Tailwind and Astro configs) Normal code, then hundreds of spaces, then the payload on the same line Editors and diffs cut off long lines, so the payload is off-screen
package.json scripts node init && added to the start of dev, build or lint Your real command still runs afterwards, so nothing breaks
.vscode/tasks.json A task set to run when the folder opens VS Code runs it as soon as you open the folder
Font files (.woff2) JavaScript saved with a font extension Nobody opens font files
.gitignore New lines like temp_auto_push.bat and branch_structure.json, and the .env and .vscode lines removed It hides the worm's files and lets your secrets get committed
Git history Existing commits rewritten and force-pushed, often to side branches and old tags Commit messages and authors stay the same

Two things in git gave the rewritten commits away. First, the committer date didn't match the author date. The worm re-commits old work, so a commit would say it was written months ago but committed this week. Second, git's local records of what we had fetched showed force-pushes to main in four of our repos.

The payload also contains a fixed string, rmcej%otb%. Other researchers' PolinRider scanners look for the same signature.

How we cleaned up

We cleaned up in two rounds, because the first round missed some of it.

Round 1: my machine and the main branches. We removed the hidden payloads, the init dropper files, the node init && script prefixes and the auto-run VS Code tasks. We also restored the .gitignore lines the worm had deleted. The default branches scanned clean and we thought we were done.

Round 2: everything else. Once repo-guard could scan every branch and tag, not only the checked-out one, it found the worm in three repos:

Repo Where the worm was still hiding
billboxx-web-app Payload in vite.config.mjs on the dev and feat/kyc branches, plus a committed Sentry token file
billwebb Payload in eslint.config.js on two feature branches
mac-pause Payload in the website's Astro config on the v1.0.0 tag, and worm .gitignore lines on main

Anyone who checked out one of those branches or built that tag would have been infected again.

Fixing the branches was easier than we expected. The worm doesn't add new commits. It rewrites existing ones and keeps the original message and author date. So for each rewritten commit, we found the original clean version and pointed the branch back to it. No work was lost. billwebb's main, for example, is still release v2.7.0, and dev still has the latest fixes. The only things removed were the worm's dropper, script changes, payload and .gitignore edits.

We backed up every branch and tag before changing anything, and approved each force-push one at a time.

Any team that goes through this still has two jobs left:

  • [ ] Rotate credentials. Assume anything the infected machine could reach has been stolen: GitHub, npm, cloud accounts, SSH keys, and the committed Sentry token.
  • [ ] Re-clone. Delete old local copies of the cleaned repos and clone them fresh, so an infected copy can't push the worm back.

What we built: repo-guard

The main lesson from cleaning up by hand: check code before it runs, not after. Antivirus doesn't help much here. Nothing about this looks like a classic virus. It's ordinary JavaScript in places people don't read. repo-guard knows where PolinRider hides and checks those places every time code arrives on your machine.

  • Every clone, from any app. After repo-guard setup, every clone is scanned, whether it comes from the terminal, VS Code, GitHub Desktop or JetBrains. If a clone is infected, its files are removed before you can open the folder.
  • Every branch and tag. It reads git history directly, so it finds payloads on side branches and old tags. That's where we missed them.
  • Before you clone. repo-guard check owner/repo scans a GitHub repo without cloning it.
  • On pull and commit. It warns you when a pull brings in infected files and blocks commits that add them.
  • Cleanup. repo-guard clean shows the proposed fix as a diff and only applies it if you confirm.

It also checks for other tricks these campaigns use: stealing credentials and crypto wallets, downloading and running code, reverse shells, hidden characters, and committed secrets and .env files.

repo-guard is free and open source (MIT). It has no dependencies and never runs code from the repos it scans. Source and docs: github.com/gloverola/repo-guard.

Install and set up repo-guard

You need git and Python 3.8 or newer. On a Mac, Python comes with the developer tools (xcode-select --install).

1. Install it

pipx install git-repo-guard
Enter fullscreen mode Exit fullscreen mode

No pipx? Run brew install pipx first, or install with Homebrew directly: brew install gloverola/tap/repo-guard. Homebrew sometimes goes quiet for a few minutes while it updates itself. That's normal.

2. Turn on automatic protection

repo-guard setup
repo-guard selftest
Enter fullscreen mode Exit fullscreen mode

setup turns on scanning for every future clone. selftest checks that it works on your machine. Every line should say PASS.

3. Scan the repos you already have

repo-guard scan-all ~/Dev
Enter fullscreen mode Exit fullscreen mode

Replace ~/Dev with your repos folder. It shows a progress line while it runs. When it finishes, it lists only the repos with problems, followed by a one-line summary.

Everyday commands

Command What it does
repo-guard scan . Checks the current repo: files, every branch and tag, and git settings
repo-guard scan-all ~/Dev Checks every repo in a folder
repo-guard check owner/repo Checks a GitHub repo before you clone it
repo-guard clone URL Clones safely. Nothing is written to disk until every branch scans clean
repo-guard clean . Shows a proposed fix for an infected repo as a diff
repo-guard rules Lists everything it checks for
repo-guard uninstall Removes repo-guard completely

After setup, plain git clone is protected too, so you don't have to change how you work. To upgrade later, run pipx upgrade git-repo-guard.

If repo-guard finds something

Each finding is marked HIGH, MEDIUM or INFO. Stop on HIGH or MEDIUM. INFO is just for your information.

  1. Don't open the repo in your editor, and don't run npm install, npm run dev, build, lint or tests in it. Those are the moments the worm runs.
  2. Share the output with your team before anyone fixes anything. If someone still has an infected copy, their next force-push will undo your fix.
  3. Clean it up together. repo-guard clean fixes the files on disk. Branches and tags get moved back to their clean commits, as described above.
  4. Rotate your credentials from a clean device if the repo was ever opened or run on your machine.

Also check your editor settings. In VS Code, Cursor and similar editors, set "task.allowAutomaticTasks": "off" and keep Workspace Trust on, so a repo can't run tasks as soon as you open it.

Lessons learned

Until this week we only cleaned up after each infection. Now we check first.

  • A clean main doesn't mean a clean repo. The worm survived on side branches and an old tag. Scan all of them, not just the branch you have checked out.
  • Opening a folder can run code. Editor tasks, npm scripts and config files all execute. Treat any new or unfamiliar repo as untrusted until it has been scanned.
  • Code review won't catch everything. Off-screen code, font files and .gitignore edits all got past us. A tool reads every byte. A person won't.
  • Look into unexpected force-pushes. An unexpected force-push to main is a warning sign. Branch protection now blocks force-pushes on repo-guard's main, and we should turn it on for our other repos too.
  • Assume your credentials are stolen. If malware ran on a machine, replace every key that machine could reach.

Install repo-guard, run repo-guard setup, and scan your repos folder once. After that, every clone gets checked automatically.