30-second experiment. Ask AI for npm packages — then check if they…

🔬 30-second experiment. Ask AI for npm packages — then check if they exist.
Do this right now, before reading further:
Open your AI of choice and ask:
"Give me 5 npm packages for validating and sanitising user input in Express."
Now take each name and run:
npm view \<package-name>
Count how many don't exist.
——————
I'll tell you what the research says, but do it yourself first — the number means nothing until it's your number. A study across 16 models generated 576,000 code samples. Of every package name the models recommended:
▪️ 19.7% did not exist
▪️ Open-source models: 21.7% hallucinated
▪️ Commercial models: 5.2%
▪️ Total unique fake package names produced: over 205,000
And the models are consistent about it. Ask the same question twice and you often get the same invented name — which is precisely what makes this exploitable.

Here's the part that turns a curiosity into a threat. A researcher noticed models kept recommending a package called huggingface-cli. It didn't exist. So he registered it — empty, harmless, as a test. It got over 30,000 downloads in three months. Nobody attacked anyone. He just put a name where the hallucination pointed, and thousands of developers installed it because their AI told them to.
The attack has a name now: slopsquatting.
Register the package the AI invents, wait for people to install it.
🎯 Three seconds of defence:
Before you install anything an AI suggested, check the package page. Look at weekly downloads and the publish date. A real utility library with 40 downloads and a first release from last Tuesday is not a library. It's bait.

💬 Run the test and post your score in the comments. Which model, how many fake out of 5. I'm genuinely curious whether it's got better or worse.

📎 Source: "We Have a Package for You!" — USENIX Security

Forward this to someone who installs whatever the AI says.

#tools @codingforweb
September 2, 2026 187 1