AI Invented This npm Package. Someone Registered It. (Slopsquatting)
Your AI assistant tells you to install a package. The name sounds right, but the package doesn't exist: the AI made it up. If an attacker registers that name first, the next npm install runs their code.
This attack is called slopsquatting.
Here's a real case, a harmless demo of why installing alone is enough, and a 10-second check you can run before installing anything an AI suggests. All registry numbers below were checked live on November 15, 2026.
Video version: How slopsquatting works
How slopsquatting works
- An AI model suggests a package name that doesn't exist. It sounds plausible, often a mix of two real names.
- Different models (and the same model, asked again) often invent the same fake names. Researchers have measured this across several frontier models, so the names are predictable.
- An attacker collects those names and publishes real packages under them, with malware inside.
- The next developer, or AI agent, who follows the suggestion installs it.
A name-similarity scanner won't help much here. The fake name isn't a typo of a real package; it's a brand-new name.
A real case: react-codeshift
AI-generated agent instructions ("skills") told people to run:
npx react-codeshift …
That command ended up in 200+ files on GitHub. But react-codeshift never existed. The AI had blended two real packages: jscodeshift (Facebook's codemod runner) and react-codemod (the React team's transforms).
On January 14, 2026, Charlie Eriksen, a security researcher at Aikido, noticed and registered the name first, as a harmless placeholder:
$ npm view react-codeshift description
🚫 Placeholder to prevent dependency confusion.
It's still downloaded about 31 times a week (59 times in the last month), most likely by agents and people following those instructions. If an attacker had claimed it first, every one of those installs would have run their code.
Installing is enough: postinstall
You don't even have to import a malicious package. npm runs lifecycle scripts such as postinstall automatically during npm install:
{
"name": "evil-demo",
"version": "1.0.1",
"scripts": {
"postinstall": "node -e \"require('fs').writeFileSync(require('os').tmpdir()+'/pwned-demo.txt','x')\""
}
}
I packed that harmless demo package and installed it with npm 11.4:
npm install ./evil-demo-1.0.1.tgz: the output showed onlyadded 1 package, but the marker file was created. The script ran silently, with full access to my environment variables (77 of them; a version that printedObject.keys(process.env).lengthshowed it).npm install ./evil-demo-1.0.1.tgz --ignore-scripts: no marker file. The script never ran.
A real attack would read ~/.npmrc, .env files, SSH keys or cloud tokens instead of writing a marker file.
The 10-second check
Before installing something an AI suggests, ask the registry three questions: does it exist, how old is it, and does anyone use it?
// check-pkg.mjs (Node 18+)
const name = process.argv[2];
const reg = "https://registry.npmjs.org/";
const res = await fetch(reg + name);
if (res.status === 404) {
console.log(`❌ ${name}: does not exist`);
process.exit(1);
}
const { time } = await res.json();
const days = Math.round((Date.now() - new Date(time.created)) / 864e5);
const api = "https://api.npmjs.org/downloads/point/last-week/";
const { downloads } = await (await fetch(api + name)).json();
console.log(`${name}: ${days} days old, ${downloads.toLocaleString("en-US")} downloads/week`);
$ node check-pkg.mjs jscodeshift
jscodeshift: 4254 days old, 7,656,282 downloads/week
$ node check-pkg.mjs react-codeshift
react-codeshift: 305 days old, 31 downloads/week
$ node check-pkg.mjs express-jwt-validator-pro
❌ express-jwt-validator-pro: does not exist
- The real package is over 11 years old with 7.6 million downloads a week.
- The hallucinated one is new and almost unused.
- A name that doesn't exist at all is the clearest red flag. Don't install it, and don't "fix" it by registering it yourself. Find the real package.
New and unpopular doesn't always mean malicious, but it does mean "look closer": check the repository link, the maintainers and what the code actually does.
For Python, the same check is pip index versions <name> (No matching distribution found means it doesn't exist) or https://pypi.org/pypi/<name>/json (a 404 means the same).
Checklist: before you install what AI suggests
- ✅ Check that it exists, its age, its weekly downloads and its repository.
- ✅ Prefer packages you already know, or the ones named in the official docs.
- ⚠️ Be suspicious of names that look like a mashup of two real packages.
- ✅ Review new dependencies in pull requests, including the ones an agent added.
- ✅ Don't let AI agents install packages without approval.
- ✅ Use
npm install --ignore-scripts(orignore-scripts=truein.npmrc) when you can. Some packages genuinely need install scripts, so test that your project still builds.
Has an AI ever suggested a package to you that didn't exist? 👇 I post one tested coding tip every day on YouTube at Refactorly. The 30-second version of this one is here.
Comments
No comments yet. Start the discussion.