Back to Handbook

Security · Advanced

Package Hallucinations

Supply Chain Attacks

The silent killer of Vibe Coding. How AI invents fake libraries, and how hackers weaponize them to steal your secrets.

01

The Mechanism: 'It Sounds About Right'

When AI doesn't know a library name, it invents one based on probability. It recommends 'arango-fastapi-connector' because those words often appear together, even if the package doesn't exist.

Security checkpoint

Verify generated packages, permissions, and sensitive data paths before shipping.

02

The Trap: The Listener

Hackers script bots to query LLMs for these hallucinations. When they find a fake name that AI recommends often, they register it on npm/PyPI and upload malware.

1. Detect

Hacker Scan

Hacker identifies common AI hallucinations.

2. Trap

Register

Hacker claims the package name on npm.

3. Exploit

Install

User vibes "npm install" blindly.

4. Theft

Exfiltrate

Malware sends .env to hacker server.

03

The Fix: Trust But Verify

You must add verification steps to your workflow. Blind trust is a vulnerability.

  • The Hover Check: Before installing, search the package. Does it have < 100 downloads? Is it brand new?
  • Use Built-ins: Prompt the AI to 'Prefer standard libraries over external dependencies'.
  • Audit: Run 'npm audit' regularly.

04

The .cursorrules Defense

Add this to your System Prompt to force the AI to be careful.

Prompt
# SECURITY PROTOCOL
- Before suggesting a new package, verify it is a standard, maintained library.
- If unsure, explicitly state: "I am verifying if this package exists..."
- PREFER: Built-in standard libraries.
- AVOID: Packages with low download counts.