Slopsquatting: When the AI Invents a Package

·

·

3–4 minutes
Title card for "Slopsquatting: When the AI Invents a Package". A worker grabs tall stacks

Ask an AI assistant to solve a problem and sometimes it reaches for a package that sounds perfect. Clear name, obvious purpose, exactly what you need. The only problem is that it doesn’t exist.

Or it didn’t, until someone noticed the model kept suggesting it.

That is slopsquatting. It is typosquatting’s younger, lazier sibling, and it works better than typosquatting ever did.

How the Attack Works

Language models generate plausible text. Package names are text. So when a model writes an import or an install command, it will sometimes produce a name that fits the pattern of real packages without matching any of them. Something like a “rails-pdf-helper” or “fastjson-validator” that sounds like it has been on the registry for years.

These hallucinations are not purely random. The same prompt tends to produce the same invented name again and again. That repeatability is what makes the attack possible.

An attacker asks models common coding questions, collects the package names that don’t exist, and registers them on npm, PyPI, or RubyGems. They add a README that looks legitimate and an install script that does something you very much do not want. Then they wait.

Typosquatting needed you to make a mistake. Slopsquatting only needs you to trust your assistant.

Why Agents Make It Worse

When a human copies an install command from a chat window, there is at least a moment where they might look at the name. When an agent runs npm install or bundle add on its own as part of a larger task, that moment is gone. The package is installed, the postinstall script has run, and the change shows up in your diff as one line in a lockfile among hundreds of other lines.

Nobody reviews lockfiles carefully. Attackers know that. As I wrote in Code Review Is Now the Job, the volume of AI-generated changes is already more than most teams read critically. A new dependency hidden in that volume is easy to miss.

How to Protect Yourself

None of this requires new tools. It requires treating every new dependency as a decision, not a side effect.

  • Commit your lockfiles and install from them. Use npm ci, bundle install with a frozen lockfile, or the equivalent in your ecosystem. Your build should never resolve a new package on its own.
  • Verify before you add. Before any new package goes in, check three things: who publishes it, how old it is, and how many people actually download it. A package created last month with almost no downloads and a name that matches exactly what your AI suggested is a red flag, not a coincidence.
  • Make new dependencies visible in CI. A simple check that fails or flags the pull request when the dependency list changes forces a human to look. Diff the manifest, not just the code.
  • Use an allow list or private mirror for anything serious. A proxy registry that only serves approved packages turns “the agent installed something weird” from a breach into a failed build.
  • Restrict what agents can install. If your coding agent supports permission rules, require approval for package install commands. It costs you a click. It can save you a very bad week.
  • Disable install scripts where you can. Many attacks run at install time. If your ecosystem lets you skip lifecycle scripts by default, do it and allow them explicitly for the packages that need them.

The Real Lesson

Supply chain attacks used to target popular packages because that’s where the reach was. I wrote about that earlier this year in Open Source Security Is Everyone’s Problem Now. Slopsquatting flips it. The attacker doesn’t need a popular package. They need a popular hallucination.

The fix is old-fashioned: know what you depend on, and don’t let anything, human or machine, add to that list without someone looking.

Your AI assistant is confident about every package it suggests. That confidence is not evidence.

When was the last time you checked who published the newest package in your lockfile?


If this resonated with you, I would love to hear your perspective. Drop me a message or connect with me on Twitter (X) or LinkedIn. I write regularly about the intersection of AI, software engineering, and leadership at ivanturkovic.com.

Ivan Turković
Software Architect & Engineering Leader · 20+ years

Work with me →

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×