What Is Typosquatting (Package Squatting)?

Typosquatting : A supply chain attack where an attacker publishes a malicious package with a name similar to a popular legitimate package, hoping developers will install it by mistake. Examples include ‘crossenv’ (malicious) vs ‘cross-env’ (legitimate), or ‘colouors’ vs ‘colors’. The malicious package often contains the legitimate functionality plus hidden malicious code.

Why It Matters for AI-Coded Apps

AI code generators are particularly susceptible to typosquatting. LLMs can hallucinate package names that are close-but-not-exact matches of real packages, or suggest packages from memory that have since been taken over. A developer who blindly installs AI-suggested dependencies without verification is at high risk.

Real-World Example

An AI suggests pip install python-sqlite3 for database operations. The legitimate module is sqlite3 (built-in). An attacker publishes python-sqlite3 on PyPI with a legitimate-looking description but includes code that exfiltrates environment variables on import. Developers following the AI’s advice install the malicious package.

How to Detect and Prevent It

Always verify package names, publishers, and download counts before installing AI-suggested dependencies. Check the package’s repository link and publication date. Use lockfiles to prevent accidental installation of different packages. Run SCA tools that detect known typosquatting packages. Prefer well-established packages with verified publishers.

Frequently Asked Questions

How common is typosquatting on npm?

Security researchers regularly find hundreds of typosquatting packages on npm. In 2025, over 600 malicious typosquat packages were removed from npm in a single month. The npm ecosystem’s lack of namespace requirements makes it especially vulnerable.

Can AI models be trained to avoid typosquatting?

Current LLMs cannot reliably distinguish legitimate packages from typosquats because they suggest packages from training data patterns, not from real-time registry lookups. AI-suggested package names should always be verified against the actual registry.

What happens if I install a typosquatting package?

Malicious typosquat packages typically run code during installation (postinstall scripts) or on import. Common payloads exfiltrate environment variables (API keys, tokens), open reverse shells, download additional malware, or mine cryptocurrency. If you suspect installation, rotate all exposed credentials immediately.

Scan your app for security issues automatically

Vibe Eval checks for 200+ vulnerabilities in AI-generated code.

Try Vibe Eval

AI Coding Security Insights.
Ship Vibe-Coded Apps Safely.

Effortlessly test and evaluate web application security using Vibe Eval agents.