Developer supply-chain firewall. Before your code runs, HexFang checks what it's about to do.
npm install runs code from every package it downloads, before you ever look at it. HexFang downloads the exact packages npm would install, analyzes them without installing or running anything, and gives each one a verdict: ALLOW, WARN or BLOCK. Only then does it install, with install scripts running only for packages you allow.
Status: early preview. Works with npm, pnpm and Yarn (1 and 2+) projects. Not yet published to npm or crates.io: build it from source (below). Read Limits before relying on it.
You need Rust (stable, 1.88 or newer) and Node.js with npm (plus pnpm or Yarn if your project uses them).
git clone https://gitlab.com/hexfang-sec/hexfang.git
cd hexfang
cargo install --locked --path crates/hexfang-cli
hexfang --versionIn your project:
hexfang install # instead of npm install / pnpm install / yarn: checks everything, then installs
hexfang install axios # instead of npm install / pnpm add / yarn add axios: checks axios and everything it pulls in
hexfang init # protect the repo for everyone who clones it, and add a CI checkYou don't need to know package names: hexfang install on its own checks every package your project uses (including dependencies of dependencies). Naming a package is only for adding a new one, exactly like your package manager.
npm, pnpm or Yarn. HexFang uses whichever package manager the project uses (the packageManager field in package.json, else the lockfile: package-lock.json, pnpm-lock.yaml or yarn.lock), the same safe way for all of them: resolve without running anything, analyze, install with scripts off, then run install scripts only for allowed packages.
Install packages safely
hexfang install # everything in package.json (like `npm install`)
hexfang install lodash react@^18 # add packages (like `npm install lodash react@^18`)
hexfang install vitest -- --save-dev # pass package manager flags after `--` (Yarn: -- --dev)
hexfang install zod --workspace api # monorepo: add to one workspace member (or run it inside the member's folder)
hexfang install --yes # no prompts: install ALLOW packages, refuse anything that needs reviewCheck without installing
hexfang check some-package # look at a package before deciding to add it
hexfang check left-pad@1.3.0 --json # machine-readable report
hexfang scan # check every package in the lockfile (npm, pnpm or Yarn)
hexfang scan --strict # CI: fail on WARN, BLOCK or anything not checked
hexfang scan --sarif hexfang.sarif # GitHub code scanning report
hexfang scan --gitlab-codequality gl-code-quality-report.json # GitLab merge request reportReview and decide (shared with your team in hexfang.lock.json)
hexfang explain # list every rule
hexfang explain NET-003 # what a finding means and how to verify it
hexfang approve sharp@0.34.2 # reviewed: allow this exact version and its install scripts
hexfang deny sketchy-lib@1.0.0 # never install this exact versionProtect a repository
hexfang init --dry-run # show what it would change
hexfang init # script blocking (.npmrc / .yarnrc / .yarnrc.yml), policy, approvals, CI job (asks first)
hexfang init --ci gitlab --mode enforce # choose the CI and make the check fail merge requests
hexfang rebuild # after npm ci / pnpm install / yarn install: run approved install scripts onlyAlready infected? Find it, remove it, recover
hexfang scan # packages, files changed in node_modules, and the repo's own CI/config/task files
hexfang clean # show the cleanup plan and the emergency steps (changes nothing)
hexfang clean --apply # remove it on a new git branch: bad dependency, node_modules reinstall, injected files
hexfang incident # just the emergency steps: secrets to rotate, npm account, repo, machinehexfang <command> --help lists every option. The user guide walks through each workflow.
| Code | check / scan |
install |
rebuild |
clean |
|---|---|---|---|---|
| 0 | nothing blocked (warnings allowed unless --strict) |
installed | done | nothing to clean, or everything cleaned |
| 1 | --strict: a warning, a package not checked, or malware intel unavailable |
— | --strict: a script was held back |
cleaned, but some steps must be done by hand |
| 2 | at least one package or repository file blocked | refused: nothing was installed | a blocked package is already installed | plan only: something needs cleaning |
| 3 | error (network, registry, invalid input, broken config) | error | error | error |
In audit mode (set in hexfang.config.json) only known-malicious packages and errors fail.
- Install-time behavior: lifecycle scripts and what they run (
curl | sh, encoded PowerShell), including code they load - Malicious code anywhere in the package: secret and credential theft (
process.env,~/.ssh,~/.aws), exfiltration endpoints (Discord/Telegram webhooks), download-and-execute, obfuscation, persistence, self-publishing worms - Account takeovers: brand-new versions, publisher changes, dropped npm provenance, and suspicious code that wasn't in the previous version
- Known malware: OSV's database of confirmed malicious packages (always blocked)
- Tampering: tarball integrity against the lockfile and the registry, registry metadata that disagrees with the real package, and installed files in
node_modulesthat differ from what was published - The repository itself (
hexfang scan): CI workflows that dump or send secrets, payloads hidden in config files (next.config.js,vite.config.*, …), VS Code tasks that run when the folder is opened, dangerous project scripts and git hooks, and.npmrc,.yarnrc.ymlor.pnpmfile.cjssettings that run code
Anything HexFang can't analyze (git, local-path, URL or private-registry packages) is reported as not checked and is never treated as safe.
cargo test --workspace # unit, fixture and end-to-end tests
cargo clippy --workspace --all-targets -- -D warnings
cargo deny check # dependency licenses and advisories
cargo run -p hexfang-cli -- check lodash| Crate | Purpose |
|---|---|
hexfang-core |
Engine: rules, detectors, scoring, policy, report types. No network. |
hexfang-npm |
npm registry client, .npmrc/Yarn config, npm/pnpm/Yarn lockfiles and runners, integrity, tarball extraction, OSV |
hexfang-cli |
The hexfang binary |
Releasing to npm is described in docs/releasing.md.
fixtures/npm holds inert fake-malicious packages used by the test suite; see fixtures/README.md. The design, roadmap and progress log are in PLAN.md.
Copyright 2026 adenueltech. HexFang is licensed under the Apache License, Version 2.0; see also NOTICE.
Unless you explicitly state otherwise, any contribution you intentionally submit for inclusion in HexFang is licensed under the Apache License, Version 2.0, without any additional terms or conditions.