DEV Community

My AI agent ran npm install on a hijacked package. Here's the ward I built with Kiro to stop it.

Written for the Kiroween 2026 hackathon (Costume Contest).

Coding agents run npm install for us now. That is convenient right up to the moment the name, or the version, is wrong.

Three things made me want a guard at that exact moment:

  • Models invent package names. A USENIX Security 2025 study of 16 code LLMs collected 205,474 unique hallucinated package names. Anyone can register one.
  • Real packages get hijacked. In September 2025 a phished maintainer's account pushed malware into chalk, debug and 16 other packages with about two billion weekly downloads.
  • Dead packages never leave. request has been deprecated since 2020 and still gets installed every day.

So I built Graveward: a Kiro PreToolUse hook that reads the agent's shell command before it runs, checks every package against npm, OSV and deps.dev, and either lets it through, warns with a living replacement, or blocks it with a reason the agent can act on. Code decides, never a model.

The hijacked install

I gave Kiro a project whose package.json looked perfectly normal: express, and ua-parser-js pinned at 0.7.29. That exact version was published by a hijacked maintainer account in October 2021. Nothing in the file tells you that.

I asked Kiro: "Install the dependencies for this project."

Kiro ran npm install, and the hook answered before the shell did:

Graveward blocked 1 package(s). Do not install them. Use the suggested successor instead, or ask the user.

  • ua-parser-js@0.7.29: CURSED (malicious-advisory: GHSA-pjwm-rvh2-c87w) Try: 0.7.33

Kiro's next line, from the real run: The hook is right: 0.7.29 is the hijacked release. I'll bump the pin to the suggested 0.7.33 and install.

It edited the pin, installed, and explained what it changed. A pinned hijacked version is invisible to any model reading the file, which is exactly why the check has to be deterministic.

Honest footnote: in other sessions a careful model caught a typo'd name (loadsh) on its own before calling npm. That's fine. The point of a guard is that the outcome no longer depends on which model you run or how long the session is.

The graveyard (the costume is the interface)

The same engine draws your dependency tree as a moonlit churchyard: https://acirema792.github.io/graveward/

Nothing in it is decoration. A headstone's shape is its verdict (chains for malicious, a cross for deprecated, a zombie hand for a version with known holes, a candle for old-but-fine), its height is how many packages stand on it, and the fog is the share of the project that isn't healthy.

Click a stone and you get the autopsy: the evidence, a link to its source, and the resurrection path ("use instead: the built-in fetch").

It reads package.json, npm, pnpm and yarn lockfiles, install commands and GitHub URLs, all in the browser against public APIs.

How Kiro built it (and how I kept it honest)

  • Specs first. I wrote steering docs and asked Kiro's spec mode for the engine spec: EARS requirements, a design with correctness properties, and tasks. I caught one contradiction in review before approving.
  • A referee Kiro couldn't see inside. Before any code existed I wrote expected verdicts for 54 real packages and a black-box runner that only calls the built CLI and hook.
  • It mattered. Kiro's first run ticked every task while the CLI was a four-line placeholder, and its own Stop hook passed because that hook could never fail. I replaced it with a done-means-done gate that builds everything and demands a real live verdict. Later Kiro reported "28/28" when a formatter had silently cut my benchmark to 28 of 54 cases.
  • Bugfix specs turned each failure into a root-caused, test-pinned fix, up to 54/54.
  • A held-out set, committed by hash only and hidden from Kiro, came back 41/41, with 0 false blocks. A round-5 scan of six real npm, pnpm and yarn lockfiles (9,407 packages) produced one block, and it was explained (npm's fs security placeholder).
  • A verifier that defaults to reject. When Kiro widened the look-alike list to 1,000 popular names, every test stayed green, but the verifier found real packages it would block. We rejected the change. Green tests are not the same as no false positives.
  • My favourite moment: my own guard hook blocked Kiro while it was writing a file that merely mentioned "npm install". A real false positive, now fixed, and a good reminder that a guard has to be tested like any other code.

Every Kiro prompt and transcript is committed in the repo (.kiro/logs/).

Try it

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.