Dev.to Security πŸ” Cybersecurity πŸ‘ 2 πŸ“– 6 min read

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

Written for Kiroween 2026. This one is less about what I built and more about what building it taught me. Why I started Here's a habit I suspect a lot of us share now. You ask a coding agent for a feature, an

Written for Kiroween 2026. This one is less about what I built and more about what building it taught me.

Why I started

Here's a habit I suspect a lot of us share now. You ask a coding agent for a feature, and somewhere in the middle it runs npm install on a package you never picked. Most days that's fine. But I stopped reading those names a while ago, and I don't think I'm the only one.

Then September 2025 happened: one phished maintainer, and malware landed in chalk, debug and 16 other packages with about two billion weekly downloads. Around the same time, researchers counted 205,474 package names that code models simply invent, names anyone can go and register. An agent doesn't have to be malicious to hurt you. It only has to be confidently wrong once.

I wanted something small, boring and trustworthy at that exact second: a check that reads the command before the shell does. I called it Graveward, and because it was Kiroween, I let it dress up as a graveyard.

The rule I set on day one

Kiro would write the specs and the code. My job was different: write down what "right" looks like before any code existed. I picked 54 real packages, wrote the verdict each one should get, and wrote a small black-box runner that only calls the finished CLI, the same way Kiro would.

I thought of it as a formality. It turned out to be the most important thing I did.

The night everything was "done"

Kiro's first implementation run ticked all 16 tasks and wrote a cheerful summary calling the project production-ready. Its own Stop hook passed.

Then I ran my referee. The CLI was a four-line placeholder. The engine's main loop was empty. One of the packages didn't even build.

Oddly, I wasn't angry. It was clarifying. When I looked at why the hook passed, the answer was me: I had given it a definition of done that could never fail (it type-checked a config with an empty file list). Kiro met the bar I set. The bar just wasn't there.

So I rewrote the hook as a "done means done" gate: build everything, then ask the built CLI for a real verdict from the live npm registry. I unticked seven tasks, and on the next run Kiro finished them for real.

What I learned: an agent will meet the bar you give it. If the bar can't fail, neither can the agent.

When 28/28 meant 28 out of 54

A few runs later Kiro proudly reported "28/28 passing". I had written 54 cases.

Nobody cheated. A repo-wide formatter had tidied up my benchmark file, and the runner quietly read only half of it. I restored the file byte for byte and fenced the folder off from formatters.

What I learned: when a number looks good, check the denominator first.

Running out of credits at 11:30 pm

The free credits ran out at about 11:30 pm on the first night, right in the middle of a fix. Here is the score history in order: 25/54, 43/54, then down to 37/54 when the credits ran out, then 54/54. I like that it isn't a straight line, because that's what it actually looked like.

The cheaper models got the overall shape of the engine right. Where they struggled was the fiddly details of each API, and they got those right as soon as I gave them a precise bug report. Kiro's bugfix specs made me write that report properly: the root cause, the rule it broke, and a test that pins the fix. Writing those taught me more about my own problem than any other part of the project.

The moments Kiro surprised me

  • It asked instead of cheating. Twice, a fix I requested contradicted one of my test expectations. Kiro didn't quietly edit the test to go green. It stopped and asked me which one was wrong.
  • It respected a "no". When its permission rules refused a file write, it told me about the block instead of finding a way around it.
  • And the moment the whole project was for. I gave Kiro a project whose package.json looked completely normal: express, and ua-parser-js pinned at 0.7.29. That exact version was published by a hijacked account in 2021, and nothing in the file tells you so. I asked Kiro to install the dependencies. 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.
  - [email protected]: CURSED (malicious-advisory: GHSA-pjwm-rvh2-c87w) Try: 0.7.33

And Kiro's next line:

The hook is right: 0.7.29 is the hijacked release. I'll bump the pin to the suggested 0.7.33 and install.

That one line is the whole idea. You don't need a smarter model. You need a plain, deterministic check that a model can listen to. Code decides, the model explains.

The moments I was the problem

  • My own guard blocked Kiro while it was writing a file that merely mentioned "npm install". A false positive, in a tool whose whole promise is not crying wolf. I fixed it and kept the story, because it's a good reminder that a guard has to be tested like any other code.
  • The hardest call was throwing away a change where every test passed. In the last audit round Kiro widened the look-alike list to 1,000 popular names. Every test stayed green. Then a separate verifier, whose default answer is "reject", checked 17,420 real npm names and found the change would block real packages such as react-vis. We rejected it. Green tests are not the same thing as no false positives.
  • My tool flags my own repo. Two dev dependencies, vitest and vite, have known holes, and Graveward says so. Upgrading two major versions the day before the deadline was riskier than leaving them, so I left them and wrote that down in the repo instead of hiding it.

The costume

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

I wanted the spooky part to be honest too, so nothing in it is decoration. A headstone's shape is its verdict, 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, its source, and what to use instead.

One rule from the steering docs did more work than I expected: investigate, don't accuse. An old package that hasn't changed in years gets a candle, not a death sentence. Many of the best packages on npm aren't dead. They're finished.

What I'm taking with me

  1. Write the referee before the code. Decide what "right" looks like while you still have no code to be proud of.
  2. Make "done" something that can fail. Then let the agent run.
  3. Check the denominator.
  4. Let code decide and the model explain. Then you can trust the outcome no matter which model you run.
  5. Test your guards like everything else, including against yourself.

How it was made, honestly: Kiro wrote the product. I wrote the intent, the steering, the expected verdicts and the referee, and an outside coding assistant helped me run the sessions and the audits (that's disclosed in KIRO.md). Every prompt and transcript is committed in .kiro/logs/, failures included.

Where it landed

It passes 54 of the 54 cases I wrote before any code existed. On a held-out set that Kiro never saw, it scored 41 of 41, with zero false blocks. The numbers are in the repo. The story behind them is what's above.

If you build with agents too, I'd love to hear about your own "four-line placeholder" moment in the comments.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.