In June 2023, the research team at Vulcan Cyber described a supply-chain attack that depends on AI coding assistants. They called it “AI package hallucination.” The idea is simple: language models sometimes invent the names of software libraries that do not exist, and an attacker can register those names before a developer types install.
Ask ChatGPT how to solve a coding problem and it will often suggest installing a package to help. Usually the package is real. Sometimes it is a confident fabrication, a plausible-sounding name for a library that was never published. Follow-up research, including work from Lasso Security, found that models can return the same invented names across repeated questions. That repeatability makes a hallucinated name a reusable target.
The attack in three steps
- Harvest hallucinations. Ask an AI assistant many programming questions and record the package names it recommends that do not exist in registries such as npm or PyPI.
- Register the name. Publish a malicious package under that exact hallucinated name, so it now resolves to real, attacker-controlled code.
- Wait. The next developer who receives the same recommendation runs
pip installornpm installand pulls the attacker's package into their build.
pip install example-invented-package # illustrative name: invented by the model, then registered by an attacker
Why AI makes this worse than typosquatting
Registry typosquatting has existed for years and relies on mistyped package names. Vulcan described a different route: an assistant inside the developer's workflow suggests the malicious name with confidence, to every user who asks a similar question. Developers often paste AI suggestions straight into a terminal. The term slopsquatting came later and names the practice of registering package names that AI models hallucinate.
Defending the AI-assisted build
- Verify every dependency an AI suggests. Before installing, confirm the package exists as a maintained project with real history, downloads, and a source repository, not a package published last week with no provenance.
- Use allow-lists and internal mirrors. Pull dependencies through a curated registry so a brand-new, unvetted package cannot enter the build unreviewed.
- Scan and pin. Software composition analysis and lockfiles catch and freeze what actually gets installed, limiting surprise substitutions.
- Educate developers about the funnel. A package name from a chatbot deserves the same scrutiny as a link in an email, because a confident answer is not a verified one.
Vulcan's work demonstrated a technique and did not report mass exploitation. The mechanism works, though how often attackers use it in the wild is hard to measure. As AI assistants write more install commands, the gap between “the model said so” and “I verified it” becomes an attack surface. A dependency you did not choose deliberately is one you cannot vouch for, and a model is now choosing some of them.