Topic 2 of 5 · 5 min read
Slopsquatting and invented package names
Goal: Judge whether a dependency an agent added is real, maintained and the intended package before anyone installs it.
Slopsquatting is when an attacker registers a package name that AI models tend to invent, so that the next developer who installs the hallucinated name gets malware. The model's mistake becomes the attacker's delivery route.
Check yourself · 1 of 3
What makes a hallucinated package name a security problem and not only a bug?
Why it matters
When a model writes import fast_json_utils, there may be no such package. If nobody owns the name, pip install fails and you notice. If an attacker has registered it, the install succeeds and the attacker's code runs on your laptop or in CI, often at install time. Researchers who studied code-generating models found that package hallucinations are common across models and languages, and that many invented names repeat across runs, which is what makes them worth registering. See the paper and the Socket write-up in the references for the measured rates; this lesson does not quote a number.
Typosquatting relies on a human mistyping reqeusts. Slopsquatting relies on a model inventing a name and a human trusting it.
How to vet a new dependency
Before anyone runs an install for a name you did not choose yourself:
- Was it asked for? Does the task need a new package at all? The standard library or an existing dependency may already do it.
- Is it the one you meant? Compare the name to the official project's docs and repository link. Look for near-miss names:
python-dotenvversusdotenv-python,coloramaversuscolourama. - Look at its history. Registry page: publish date, number of versions, weekly downloads, maintainers, linked repository. A package created last week with one release, no repository and a name that matches your prompt is the pattern to fear.
- Does the repository match the package? The link should lead to a real project whose code matches what is published.
- Search the lockfile diff. Transitive dependencies are new names too.
The OpenSSF guide in the references gives a fuller checklist.
Before and after
requirements.txt (agent's change)
+ flask-jwt-simple==0.0.1
The name sounds like a real library. The registry shows one release from three weeks ago, no source link and a single anonymous maintainer. The reviewed change uses PyJWT, a long-lived project with a public repository, and the extra package is dropped.
What goes wrong
- Installing to find out. The install is the attack. Look it up first, in a browser or with a metadata command that does not run code.
- Trusting that the name exists. A name being present on the registry says nothing about who put it there or when.
- Trusting download counts alone. Counts can be inflated; read them with age and repository.
- Letting the agent run the install. The model that invented the name also runs the command, with no human in between.
Examples
The plausible JWT package
An agent adds flask-jwt-simple to fix a login task. The registry page shows 1 version, created 19 days ago, no repository link. The team's existing PyJWT already supports the task. Decision: reject the new dependency and use PyJWT.
The name that does not exist yet
A model suggests npm install react-form-validators-pro. The command fails with a 404. That is the good outcome. If the same name were registered next month by an attacker, the same command would succeed and run their install script.
Key points
- A hallucinated package name is dangerous when someone else registers it, because the install then succeeds.
- Check whether the package is needed at all before judging whether it is safe.
- Registry age, release history, maintainers and a matching repository are the quickest signals of a real project.
- Look the name up before installing; installing is the moment the attacker's code runs.
- Compare the name with the official docs to catch near-miss names for the package you meant.
Common mistakes
- Running the install command to see whether the package exists.
- Judging a package only by how plausible the name sounds.
- Treating a high download count as proof of safety without checking age and source.
- Ignoring new transitive packages that appear in the lockfile diff.
Check yourself · 2 of 3
An agent added flask-jwt-simple to requirements.txt. What should you do first?
Check yourself · 3 of 3
Which signal best suggests a package name might be a slopsquat?
Practice items, not counted towards your mastery.
Start here
- We Have a Package for You! Package hallucinations by code-generating LLMs (opens in a new tab)PaperFree
The study that measured how often code models invent package names, across languages and models.
- Slopsquatting: how AI hallucinations are fueling a new class of supply chain attacks (Socket) (opens in a new tab)ArticleFree
Explains the attack in plain terms and what defenders can do about it.
- Concise Guide for Evaluating Open Source Software (OpenSSF) (opens in a new tab)ArticleFree
A short checklist for judging whether a package is maintained, trusted and the one you meant.