Home / patterns

AI-suggested packages that don't exist (slopsquatting)

Quick answer: Coding assistants sometimes import or tell you to install a package name that doesn't exist. Attackers can register those names with malicious code, so a copy-pasted npm install or pip install pulls malware into your app. Check every unfamiliar dependency before installing it.

Last updated October 19, 2026

Steps

  1. Before installing any package an AI suggested, look it up on the registry (npmjs.com or pypi.org). Check that it exists, who publishes it, when it was created, download counts and the linked source repo.
  2. Be suspicious of very new packages, near-duplicate names of popular libraries, and packages with no repository or documentation.
  3. Review your package.json or requirements file for dependencies you don't recognize, and remove ones your code doesn't use.
  4. Commit your lockfile and install with npm ci (or the equivalent) in builds, so dependencies don't silently change between deploys.
  5. Turn on automated dependency alerts (for example GitHub Dependabot) and run npm audit or pip-audit regularly.
  6. Use scoped package names for any private packages so a public package with the same name can't be swapped in.

Why it matters

Researchers studying 16 code-generating LLMs across 576,000 code samples reported that the average share of hallucinated packages was at least 5.2% for commercial models and 21.7% for open-source models, with 205,474 unique hallucinated package names (Spracklen et al., USENIX Security 2025). npm's own threat guide describes typosquatting and dependency confusion, where attackers publish look-alike or same-name packages to trick people into installing them.

Sources

Spracklen et al.: We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs (arXiv) — https://arxiv.org/abs/2406.10279

USENIX Security 2025 presentation page — https://www.usenix.org/conference/usenixsecurity25/presentation/spracklen

npm Docs: Threats and Mitigations — https://docs.npmjs.com/threats-and-mitigations

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

Free. Unsubscribe anytime. We'll never sell your email.