When AI Recommends Libraries That Don’t Exist, and Why That Is Dangerous

When AI writes code for you, it often adds “install this library” along with the install command. Convenient — but have you ever checked that the name really exists?
AI invents names that don’t exist
Generative AI is good at producing plausible text, but it can also state untrue things convincingly (hallucination). Package names are no exception: research has reported AI producing names that sound real but are not.
What slopsquatting is
Attackers look for the non-existent names AI commonly produces, and publish malicious packages under those names in advance. Anyone who installs what the AI suggested lets dangerous code onto their computer or server.
The name is modeled on “typosquatting”, which targets typing mistakes; because this targets the sloppy output (“slop”) AI produces, it is called slopsquatting.
Why it is dangerous
- Some packages run code automatically at install time
- Secrets on your machine, such as API keys and passwords, may be stolen
- The damage may spread to the people who use your service
Countermeasures
- Check the official registry: on official sites such as npm or PyPI, check that the package page exists, how widely it is used and whether it is maintained.
- Look at publish date and downloads: be careful with packages published recently and barely used.
- Copy the name from official documentation: rather than using the name the AI wrote, use the one on the library’s official site.
- Pin dependencies: use a lock file so versions do not change on their own.
- Ask whether you really need it: check you are not adding a new package for something a few lines of code could do.
Summary
Especially when AI says “install this”, pause and check. One minute spent confirming a name can prevent serious damage.

