Inspiration
In September 2025, one phished npm maintainer pushed malware into 18 packages in 16 minutes (chalk, debug and friends). A week later the Shai-Hulud worm did it with no human involved: it stole publish tokens, listed every package each token could reach, added a postinstall hook, and republished them. More than 500 package versions, including CrowdStrike's.
Each package looked normal on its own. The signal was the pattern: one publisher, many packages, minutes apart, a new install script. Scanners score packages. The attack spreads along relationships. That is a graph problem.
What it does
Patient Zero keeps a local graph of packages, versions and publishers in a single embedded Relate by Neo4j file (no server, no account) and detects spread patterns across it. Every verdict is a path you can read, not a score you have to trust.
- Replay: scrub a timeline over a real 2025 incident (chalk/debug, Shai-Hulud) and watch findings light up across the publisher graph.
- Gate: reads your package-lock, fails the build, and prints the exact installed path that explains why. It never installs anything.
- Benchmark: held-out recall, precision and quiet-week false flags, reproducible with
npm run bench. - MCP: the same graph is exposed read-only to coding agents (
blast_radius,why_blocked,safe_upgrade_path), so an agent can ask for the blast radius before it bumps a dependency.
How we built it
- Graph: Package, Version, Publisher, Advisory, Incident and Lockfile nodes, with edges such as
PUBLISHED_BY,DEPENDS_ON,SUCCEEDS,RESOLVESandRESOLVED_DEPENDS_ON, in Relate. - Ingest: the npm registry gives who published each version, when, and whether it carried an install script. The malicious versions were unpublished after the incidents, so we restore them from OSV advisories and public indicator lists.
- Five rules: R1 burst (one publisher, many packages, a short window), R2 install script appears between versions, R3 publisher new to a package or dormant, R4 provenance drops, R5 taint propagation along exact lockfile dependency edges.
- As-of queries: every query takes an as-of timestamp, so the same code replays history, runs the benchmark, and checks your lockfile.
- App: a Next.js web app and CLI gate on top of a TypeScript core, with a design system built in Claude Design (ink-on-paper, one ember colour reserved for infection).
Challenges
- The malicious versions were removed from npm, so history had to be reconstructed from advisories and indicator lists.
- The Shai-Hulud manifests we could restore lack publisher and script fields, so those rules cannot fire on them. Missing metadata counts against us in the benchmark.
- A coordinated, benign control week also trips the burst rule, producing many false flags.
Accomplishments we're proud of
- Findings are explained by a path and a rule, with evidence timing, rather than an opaque score.
- The benchmark reports its own failures instead of hiding them.
- Everything runs locally and in CI, with nothing leaving your machine.
What we learned
Graph queries make the pattern visible in a way per-package scoring cannot. We also learned how much of the work is data provenance: what was known, and when it was known.
Honest status
The benchmark page says it plainly: production acceptance is not met. Held-out Shai-Hulud recall is 0.00% on the restorable metadata, the quiet week produces 289 flags on 438 publishes, and all historical metrics are retrospective, so they do not establish real pre-advisory detection. Thresholds are untuned. Findings are signals, not proof of malware or safety.
What's next
Restore publisher and script metadata for the held-out incident, retune the burst rule against the control cohort, and verify first-public-advisory times so lead time can be measured.
Built With
- cypher
- model-context-protocol
- neo4j
- next.js
- node.js
- npm-registry
- osv
- playwright
- react
- relate
- typescript
- zod
