When AI invents packages that don't exist
AI coding tools regularly suggest software libraries while generating code that simply don't exist. Research puts the share of invented package names at roughly 20 percent of all suggestions. On its own, that would just be an annoyance – a failed install command, quickly noticed and fixed.
Why this turns into an attack pattern
The real risk factor is repeatability: 58 percent of invented package names recur across similar prompts – the same request or similarly worded ones reliably lead to the same, nonexistent name. Attackers exploit exactly this pattern: they deliberately register malicious code under invented but predictably recurring package names, expecting that developers will eventually actually install that name.
A risk that compounds with existing flaws
Slopsquatting rarely occurs in isolation: AI-generated code often also carries known vulnerability patterns (see the previous module) – insecure API calls, missing error handling, insufficient input validation. Combined with a hallucinated dependency that's been swapped for malicious code, this creates a compound risk for the entire software supply chain, not just a single line of code.
Practice section: three concrete countermeasures
Security researchers recommend three concrete countermeasures that fit directly into existing development processes: first, verify every AI-suggested package name against the official package registry before installing; second, pin versions firmly instead of allowing automatic updates; third, run hash checks on installed packages. All three are standard software supply chain security practices – with AI-generated code, they move from optional extra to necessity.