DEV Community

Cover image for Phi: an install-time firewall for npm; scanning every dependency before it touches disk
Prosper Maxwell
Prosper Maxwell

Posted on

Phi: an install-time firewall for npm; scanning every dependency before it touches disk

This is a submission for Weekend Challenge: Passion Edition

What I Built

Phi — a real package manager for npm that scans every dependency, top-level and transitive, before any code touches disk.

This project comes out of a passion for software security and innovations. npm's attack surface — postinstall scripts, typosquats, compromised maintainer accounts buried three levels deep in a dependency tree — has moved from rare incident to steady drumbeat. Tools like npm audit and Snyk check known-CVE databases after the code is already sitting in node_modules. I wanted something that inspects the actual bytes before extraction and before a single lifecycle script runs.

Phi resolves the full dependency tree itself, fetches every tarball, verifies integrity, and runs a 13-detector malware analysis on each package pre-extraction. Anything blocked aborts the install; anything flagged for review prompts you. Lifecycle scripts (preinstall/install/postinstall) — the single biggest attack surface npm exposes — are off by default, opt-in per package.

Demo

phi install express
Enter fullscreen mode Exit fullscreen mode
Phi  · secure package manager
resolving dependency tree...
scanning 53 packages...
extracting approved packages...
✔ installed 53 package(s) (safe=53 review=0)
  lockfile: phi.lock
  report:   phi-report.json
Enter fullscreen mode Exit fullscreen mode

Docs: https://phi.philtechs.org
Install (macOS/Linux): curl -sSL https://phi.philtechs.org/install.sh | sh
Install (Windows): iwr -useb https://phi.philtechs.org/install.ps1 | iex

Code

https://github.com/philtechs-org/phi

How I Built It

Phi is a single Go binary and a real package manager — it doesn't wrap or shell out to npm:

  1. Resolves the full transitive tree itself (Masterminds/semver against the npm registry).
  2. Fetches every tarball and verifies sha512 integrity from the packument.
  3. Runs a 13-detector malware analysis on each tarball before extraction — entirely in memory, nothing touches disk unverified.
  4. Aggregates verdicts across the tree: any blocked package aborts the install; review prompts the user.
  5. Extracts only approved packages into node_modules/<name>/.
  6. Lifecycle scripts never run by default — closing the attack surface most supply-chain compromises actually use.

Prize Categories

Not submitting to a specific category — phi doesn't genuinely incorporate Snowflake, Solana, ElevenLabs, or Google AI.

Top comments (0)