-
-
Phantom Imports: predict, block and explain the packages AI coding agents invent.
-
Autopsy page, demo mode: a ghost package gets a BLOCK verdict, the reasons, and the real package to use
-
The phantom-gate hook in Kiro, demo mode: the install is stopped before it runs, with a fix the agent can apply.
-
Autopsy of a booby-trapped package: the haunted house lights up where the code misbehaves, with file and line as proof.
-
The Séance: of 379 package names suggested by three models, 6.6% did not exist.
-
Benchmark: 23 ghost package names. Vulnerability databases flagged none. Phantom Imports blocked all 23.
Inspiration
AI coding agents invent package names. Different models can even invent the same ones: in our own harvest, two ghost names came back from both GPT models. Attackers register those names and wait. This is called slopsquatting. Agents now run npm install on their own, and a ghost name in an instruction file spreads to every project that copies it.
Our demo case is real: AI agents have been suggesting react-codeshift, a name that mixes up React with the real tool, jscodeshift. In January 2026, someone registered react-codeshift on npm.
What it does
Phantom Imports guards the door of your AI agent. Before a package is installed, it gives one verdict, ALLOW, REVIEW or BLOCK, with a diagnosis, the evidence and a fix:
- LIVING: healthy package
- GHOST: does not exist
- POSSESSED: exists, but is probably not what the agent thinks (lookalike name, install scripts, network calls, secret access)
- CURSED: known malware or vulnerability
- FOG: could not be verified, so never ALLOW
It works in three places:
- Inside Kiro: a
PreToolUsehook checks every install command before it runs and stops the agent. A second hook scanspackage.json,requirements.txtorpyproject.tomlright after the agent writes it. An MCP server (check_package,check_manifest,explain_verdict) lets the agent ask before it installs. - In the terminal: a CLI that checks one package (
check npm react-codeshift) or a whole manifest (scan package.json), with exit codes for scripts and CI. - On the web: an autopsy page shows the verdict card, the evidence, a haunted house where each room lights up for a risky behaviour found in the package code, and a timeline from the model's memory to the package's birth.
We measured it
We sent 100 code prompts to 3 models. 6.6% of the package names they suggested did not exist (25 of 379), up to 9.1% for gpt-oss-120b.
Then we tried existing tools on our 23 unique ghost names: OSV.dev flagged 0 of them, the deps.dev API flagged 0. Phantom Imports blocks 23 of 23.
How we built it
A TypeScript monorepo (pnpm). The engine is made of organs, each looking at one kind of fact: Registry, OSV, Name ("Did you mean"), Grimoire (known ghost names), Ledger, Clock (package born after the model's training cutoff), Medium (an LLM kept under control) and Eye (static analysis of the package archive, in memory, never executed). Only the Judge turns their signals into a verdict, with deterministic rules a human can read. A network error never gives ALLOW, and the LLM can never turn a bad fact into ALLOW.
The Séance is how we predict: we ask several models for packages, keep the ones that don't exist and store them in the Grimoire as SHA-256 hashes only, so we never publish a list of names to squat.
The whole project was built in Kiro, mostly spec-driven: 15 specs, 7 steering files, 6 hooks, 2 custom agents, an MCP server and property-based tests (Vitest + fast-check). We kept an honest journal of every Kiro session, with credits used and what review still had to fix.
Code: https://github.com/Hackaton-hub/kiro Live demo: https://kiro-web-xi.vercel.app
Challenges we ran into
- Our demo ghost turned out to be already registered on npm. Instead of hiding it, we made it the demo: the live gate still stops
react-codeshiftas POSSESSED and suggestsjscodeshift. - Kiro CLI in headless mode does not fire hooks, so we had to test the live block in interactive sessions.
- Property tests found a real bug: a tar entry with prefix
" "and name/etc/passwdcame out as an absolute path in the Eye. Nothing was written to disk, and it was fixed with regression tests. - Our own gate stopped our QA agent: the parser read the shell redirection
2>&1as a package name. We fixed it with a bugfix spec.
Accomplishments that we're proud of
- 1300+ tests green, including property tests on hostile archives (path traversal, gzip bombs, broken sizes).
- A gate that stops the real
react-codeshiftcase live, with "Did you mean: jscodeshift?". - Real numbers instead of claims, and a ghost list that cannot be used by attackers.
What we learned
Specs made three people work on one engine without stepping on each other: a shared contract (types.ts) and one spec per organ. PBT caught things unit tests missed, but sometimes the bug was in the test, not the code. And steering does not always win: Kiro still marked property tasks optional in one spec.
What's next
More ecosystems (crates, Go), a public feed of ghost-name hashes, and the gate as a GitHub Action for pull requests.
Built With
- esbuild
- fast-check
- github-actions
- groq
- kiro
- mcp
- node.js
- npm
- osv
- pnpm
- pypi
- typescript
- vercel
- vite
- vitest