Skip to content

A Model Invents a Name, a Stranger Registers It, CI Passes

I ran ruff, mypy, pip and a small gate on one hallucinated import, before and after a name got registered. Only an age and release check still failed.

· · 11 min read
Grid of PASS and FAIL cells showing which of six checks stop a hallucinated import in three states of the package name

I wanted to see the moment a hallucinated import stops being an error: a model invents a name, a stranger registers it, and the red goes away. So I wrote a file that imports a package that shouldn't exist, ran the usual tools on it, then let a fake registry "register" the name and ran them again. Same code. Different answers.

Nothing here touches a real registry. I uploaded nothing and installed nothing suspicious.

What did the tools say while nobody owned the name?

The test file is 10 lines. It imports datefmt_plus, an old and established package in my local registry, and zb_jsonmend, the name a model "suggested". The registry is a 93-line stand-in for PyPI's simple API that re-reads its state file on every request, so I can register a package mid-run.

State one, the name exists nowhere:

  • pip install zb-jsonmend stops with "No matching distribution found".
  • python raises ModuleNotFoundError.
  • mypy 1.19.1 reports Cannot find implementation or library stub with the code import-not-found.
  • ruff 0.16.6 says "All checks passed!".

That last line deserves a second look. I reran ruff with --select ALL and got three findings: a missing docstring, a missing __init__.py, a missing copyright notice. None about the import. As far as I can tell ruff has no rule that asks whether an imported module exists, so it was never going to be the gate here. Why would anyone expect it to be?

What changed when somebody registered it?

I rewrote the registry state: one release, uploaded two days ago, no py.typed marker. Then I ran everything again.

Grid of PASS and FAIL cells showing which of six checks stop a hallucinated import in three states of the package name
Six checks against one import in three states of the name. FAIL is exit code 1. Source: run_demo.py in the example folder.

pip installed it. Python imported it. ruff still passed. mypy still failed, but with a different message: module is installed, but missing library stubs or py.typed marker. It had moved from "doesn't exist" to "exists, untyped".

Then I gave the package a py.typed file, one empty file in a wheel, and mypy printed Success: no issues found in 1 source file. Third column, all green except the last row.

One honest detour. My first run kept a mypy cache, and after the install mypy went on answering import-not-found as if nothing had changed. For a moment I read that as "type checkers don't notice a newly installed package". They do. The cache was stale, and the example now passes --cache-dir=/dev/null. If you try this at home, that's the line to copy.

What I take from the grid: every check that went green was asking whether the name resolves. Resolving was true the moment the name was registered, by anyone, for any reason.

How often does a model invent a name worth registering?

I didn't measure this. Spracklen and colleagues did, and the paper is open. They generated 576,000 code samples with 16 models, in Python and JavaScript. The models recommended 2.23 million packages, of which 440,445 (19.7 percent) didn't exist, spread over 205,474 distinct names.

That 19.7 percent is a share of recommended packages, not of code samples, and it's easy to misquote. The abstract's averages are at least 5.2 percent for commercial models and 21.7 percent for open-source ones.

Bars: 19.7 percent of recommended packages did not exist; 43 percent of fake names repeated in ten of ten queries
Figures from sections 5.1 and 5.3 of the paper. The bars share a scale, not a denominator.

The number that matters for squatting is repetition. In their sample of 500 prompts, each queried 10 times, 43 percent of the hallucinated names came back in all ten queries and 58 percent came back more than once. A name that returns is a name an attacker can predict, and prediction is the whole economics of the thing.

Fixing it on the model side costs capability. In the paper's mitigation table, fine-tuning cut DeepSeek's hallucination rate from 16.14 percent to 2.66 percent, and its pass@1 on code quality fell from 51.4 to 25.3 percent. You don't control that dial anyway.

Has anyone actually installed one of these?

Two public cases, both from researchers rather than attackers. Lasso Security saw models recommend a Python package called huggingface-cli, published an empty package under that name, and in a write-up dated March 2024 reported more than 30,000 downloads over three months. They add that installation instructions for it appeared in the README of an Alibaba research repository.

Aikido's Charlie Eriksen traced react-codeshift, a blend of jscodeshift and react-codemod, to a commit of 47 LLM-generated agent skills from October 2025. He registered the npm name himself on 14 January 2026. By his count 237 or more repositories referenced it, and the placeholder got about 74 downloads on day zero, then a trickle of one to four a day. Typical phantom packages, he writes, get 60 to 100 on day zero from mirrors and scanners and then nothing. The trickle suggests agents were really running the command.

Neither package carried a payload. That's the lucky part.

What does a gate that survives registration check?

Existence can't be the test. So my script, gate.py, 98 lines of standard-library Python, asks four separate questions:

  • declared: is every third-party import pinned, with a hash, in the lockfile?
  • exists: is every locked name on the registry?
  • age: is its first upload at least 30 days old?
  • releases: does it have at least 3?

It parses imports with ast, so the check runs on a pull request before anything is installed. The age test is five lines:

age = (datetime.now(timezone.utc) - facts["first_upload"]).total_seconds() / 86400
if "age" in checks and age < args.min_age_days:
    bad.append(f"FAIL {dist}: first upload {age:.1f} days ago, floor is {args.min_age_days:g}")

And here's the result in state two, after the developer adds the name to the lockfile the way a tool would:

gate, lock updated: exists only    exit 0  ok: 2 third-party import(s), 2 locked
gate, lock updated: all checks     exit 1  FAIL zb-jsonmend: first upload 2.0 days ago, floor is 30
                                           FAIL zb-jsonmend: 1 release(s), floor is 3

Exists-only passes. All four fail. That's the entire argument in two lines of output.

Every check that went green only asked whether the name resolves. None asked whether anyone should trust it.

SHARE Post on X Bluesky

Two details on the registry side, because they shaped the script. PyPI's JSON API has no download count: the docs say the downloads field is always -1 and shouldn't be used, and they mark the releases key deprecated. So the gate reads the Index API instead, where each file carries an upload-time. And I wouldn't use downloads as a trust signal even if I could. Lasso's empty package collected 30,000 of them. Downloads measure habit, not safety.

What does an age floor buy, and what doesn't it?

It buys exactly what the grid shows: a name registered last week is refused. Is that worth having? Yes, because it's the lazy attacker's case. It doesn't buy more than that.

Timeline of 0 to 60 days: the gate refuses a name up to day 30, so a day-2 registration fails and one that waited passes
The rule in gate.py with its default floor. An illustration of the logic, not measured data.

Remember the 43 percent. If a model keeps inventing the same name, an attacker doesn't need to react to your pull request. They can register early, ship one boring release, and sit on it for a month. At day 31 my gate waves them through. I'd rather say that plainly than sell the floor as protection.

So here's the opinion some readers won't like: an age floor is a speed bump, and the control is a person. A new name in a lockfile diff should need an explicit approval, the same way a new eval call or a new CODEOWNERS entry does. The age and release checks exist to make that review short and to catch the case where nobody was looking. OWASP's A03:2025 entry on software supply chain failures says to take components only from official sources and prefer signed packages. The prevention list I read doesn't mention hallucinated names, and signing does nothing for a package whose signer really is the squatter.

My gate is also narrow, and you should know where. It reads Python imports, and an alias file maps import names to distribution names (yaml is PyYAML), which means someone has to maintain it. It checks direct imports only. And I tested Python and npm. The paper covers the same two ecosystems, so what happens with a hallucinated crate or Go module path in the same situation is something I haven't looked at.

Can your package manager do the age half for you?

Partly, and I only ran one of the three.

I ran pnpm 12.8.1 against a second fake registry whose single package was published two days ago. With minimumReleaseAge: 0 it installed. With 43200 (minutes, so 30 days) it stopped:

Error: ERR_PNPM_NO_MATURE_MATCHING_VERSION
  1 version does not meet the minimumReleaseAge constraint:
    zb-jsonmend-js@0.0.1 was published at 2026-10-21T14:55:37.000Z, within
    the minimumReleaseAge cutoff (2026-09-23T14:55:37.820Z)

Per pnpm's documentation, the default has been 1440 minutes (one day) since version 11. A short delay like that is aimed at poisoned releases, the same argument the radar entry on Dependabot's three-day cooldown makes. It does nothing about a name registered a month ago.

For the other two I'm quoting documentation, not experience. uv's exclude-newer takes timestamps or durations such as 1 week or 30 days. npm documents min-release-age in days, and before takes an absolute date and wins when both are set. My local npm is 10.9.9, the docs I read are for v11, and I didn't run either option.

One limit applies to all three. They look at a version's age, not at the package's first appearance, so they behave differently from my gate's age check. If a squatter published version 0.0.1 a month ago and you install it today, it's mature by every one of those rules.

What would I do this week?

A short list, in order:

  • Make the lockfile the only way a dependency enters, and fail CI on an import that isn't pinned with a hash.
  • Add a first-seen check for every new name: age, release count, and a link to the source repository a human has actually opened.
  • Turn on a release-age setting in the package manager you already use.
  • Tell your AI tools to propose a dependency in the pull request description, so it's a visible line rather than a surprise in a diff.
  • Read your last ten AI-assisted pull requests for names you don't recognise. That takes ten minutes and tells you whether this is theory.

None of this replaces the older gates, and the CI gate list I put together earlier still has the right order for them. What changes is where the dependency step sits. The Dependabot triage post is about packages you already trust, and this one is about the first day a name appears. An archived-dependency audit covers the opposite end of a package's life, when the repository is read-only and the registry still serves it.

Model-side dependencies drift too, and the same instinct applies to the retirement dates of the AI models your review gate quietly depends on. A green lint run also tells you less than it seems to, which is the point of the lint rule that never ran.

Who in your team would notice a new name in a lockfile diff? If the honest answer is nobody, the CI gate audit shows which gates a pipeline file is missing. The code for this post lives in the blog's examples/hallucinated-import-gate folder, and python3 run_demo.py reproduces the grid on your machine in a few seconds.

Frequently Asked Questions

What is slopsquatting?
Slopsquatting is registering a package name that an AI model tends to invent, then waiting for someone to install it. The model's mistake supplies the name, so nobody has to guess a typo. The attack only works where a registry lets anyone claim a free name, which includes PyPI and npm.
Does a linter catch a hallucinated import?
Not in my run. ruff 0.16.6 with every rule selected reported three unrelated findings and nothing about the unknown module. mypy did flag it, but only while the module was missing or lacked a py.typed marker. Once the package was installed and shipped a py.typed file, mypy passed too.
How can CI block a freshly registered package?
Check what a name's history looks like, not just that it exists. Fail when a new dependency's first upload is younger than a floor (30 days in my script) or it has fewer than a few releases, and require a person to approve every new name in the lockfile. pnpm's minimumReleaseAge, uv's exclude-newer and npm's min-release-age do the age half at install time.