forkguarddocs

forkguard

Check a folder for hidden malware. Read only.

On this page

#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 --json
folder
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 named init.
  • package.json and lockfiles (package-lock.json, npm-shrinkwrap.json, yarn.lock, pnpm-lock.yaml, bun.lock).
  • .vscode/tasks.json, .vscode/settings.json and .vscode/extension.json.
  • Font files (.woff .woff2 .ttf .otf .ttc .eot) and README.md files inside fonts folders.
  • Dropped files such as config.bat and temp_auto_push.bat, and any .bat, .cmd or .sh script.
  • .gitignore, and .env files.

#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 .env files that are already committed, and .env files 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:

Output
forkguard  my-app looks clean (433 files checked)

A project with problems prints one line per problem:

Output
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.

LevelMeaning
HIGHCan run by itself and steal from you. Do not install, run or open the project.
MEDWorth 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.

Output
LEVEL  FILE  MESSAGE

HIGH  runs by itself; do not run the project
MED   worth a look; does not run by itself

The 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

CodeMeaning
0Clean, or only MED findings.
1Something HIGH was found.
2forkguard 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:

forkguard

Check a folder you are not in:

forkguard ~/projects/take-home-test

Use 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

Where to next

Edit this page on GitHub View as Markdown

Type to search. Use the arrow keys and Enter.