forkguard
Check a folder for hidden malware. Read only.
#Name
forkguard checks a folder for malware hidden in it. It only reads files. It never changes anything.
forkguard - check a folder for hidden malware
#Synopsis
forkguard
forkguard path/to/project
forkguard path/to/project --jsonfolder- The folder to check. Optional. Defaults to the folder you are in.
--json- Print the results as JSON instead of text.
forkguard [folder] [--json]#Description
Checks every file in the folder that this malware is known to use, and reports each problem with a level, a file and a plain-words message. It takes well under a second for a typical project.
#What it reads
- JavaScript and TypeScript files (
.js .mjs .cjs .ts .mts .cts .jsx .tsx .vue .svelte) and any file namedinit. package.jsonand lockfiles (package-lock.json,npm-shrinkwrap.json,yarn.lock,pnpm-lock.yaml,bun.lock)..vscode/tasks.json,.vscode/settings.jsonand.vscode/extension.json.- Font files (
.woff .woff2 .ttf .otf .ttc .eot) andREADME.mdfiles inside fonts folders. - Dropped files such as
config.batandtemp_auto_push.bat, and any.bat,.cmdor.shscript. .gitignore, and.envfiles.
#What it skips
node_modules, .git, .next, .nuxt, .svelte-kit, .turbo, .vercel, .output, dist, build, out, coverage, .cache, .parcel-cache, vendor, __pycache__, .venv and venv. These hold generated code rather than yours, and skipping them is what keeps the check fast. Files larger than 6 MB are skipped too.
#When the folder is a git repo
- Reports
.envfiles that are already committed, and.envfiles git is not ignoring. - When a HIGH problem is found, also checks whether your latest commit was rewritten after it was made (same moment, different timezone).
#Always
Checks whether npm itself on your computer is infected, because an infected npm would bring the malware back after every cleanup. It reads npm’s files directly and never runs npm to do it.
Scans the folder for known PolinRider artifacts. Read only.
Reads source files, package.json, lockfiles, .vscode files, fonts, scripts, .gitignore and .env files. Skips node_modules, .git, build output and files over 6 MB.
In a git repo, also reports committed or unignored .env files and a rewritten HEAD commit. Always checks the npm installation on this machine.
#Output
A clean project prints one line:
forkguard my-app looks clean (433 files checked)A project with problems prints one line per problem:
forkguard my-app
HIGH init Code hidden after 776 blank spaces on line 35
HIGH package.json "dev" runs a hidden file called init before your real command
MED .gitignore Hides config.bat, a file this malware drops
3 problems found. Do not run npm install, npm run dev or open this folder in VS Code yet.
Run forkguard fix to clean it, or forkguard pr to clean it and open a pull request.Each line shows the level, the file and what is wrong. Problems are sorted with the most serious first.
| Level | Meaning |
|---|---|
| HIGH | Can run by itself and steal from you. Do not install, run or open the project. |
| MED | Worth a look. Does not run by itself. |
When a problem can be fixed automatically, the last line points you to forkguard fix and forkguard pr.
LEVEL FILE MESSAGE
HIGH runs by itself; do not run the project
MED worth a look; does not run by itselfThe final line states the number of problems and what to do.
#Options
--json- Print
{ root, checked, findings }as JSON. See JSON output. --help,-h- Print all commands.
--version,-v- Print the version.
- --json
- machine readable output
- -h, --help
- usage
- -v, --version
- version
#Exit status
| Code | Meaning |
|---|---|
0 | Clean, or only MED findings. |
1 | Something HIGH was found. |
2 | forkguard itself could not run, for example a folder that does not exist. |
The same codes work in scripts and CI. See Exit codes.
0 clean, or MED findings only
1 a HIGH finding
2 error (for example a folder that does not exist)#Environment
NO_COLOR=1- Turn off colors in the output.
- NO_COLOR
- disable colors
#Examples
Check the folder you are in:
forkguardCheck a folder you are not in:
forkguard ~/projects/take-home-testUse it in a script, and stop if something dangerous is found:
forkguard --json > report.json || echo "stop: forkguard found something"forkguard
forkguard ./app
forkguard ./app --json#See also
- `forkguard owner/repo`: check a repo without cloning it
- `forkguard fix`: clean what was found
- What it catches: every rule
- Reading the results