Get In Touch
541 Melville Ave, Palo Alto, CA 94301,
ask@ohio.clbthemes.com
Ph: +1.831.705.5448
Work Inquiries
work@ohio.clbthemes.com
Ph: +1.831.306.6725
Back

AI Package Hallucinations Are the New Supply Chain Attack Vector

SECURITY & PRIVACY
S
Security & Privacy
Security & Privacy · July 03, 2026

AI Package Hallucinations Are the New Supply Chain Attack Vector

1 in 5
AI-suggested packages don’t exist on npm/PyPI @@@ 70% | Devs install hallucinated names without verification @@@ 248% | Surge in typosquatting packages since 2024

A security researcher types “generate a Python script to parse CSV files.” The model confidently returns code that imports csv-pro-plus from PyPI. The package does not exist. Within hours, an attacker registers it, uploads malware, and the install runs unverified on the next developer’s machine. This is the AI package hallucination problem — now the single fastest-growing supply chain attack vector of 2025, where attackers weaponize the names that AI assistants confidently invent out of thin air.

The asymmetry is the attack itself: defenders need every install verified, while attackers need just one developer to copy-paste without checking. According to the University of Texas study at CCS 2024, the rate of hallucinated package suggestions in commercial AI coding assistants is roughly 20% — and attackers have noticed.

How a Hallucinated Package Attack Works

Large language models invent package names because their training objective predicts plausible-looking identifiers, not verified ones. Once an attacker identifies a hallucinated name — through systematic querying or monitoring developer forums — they can register it on the relevant registry in seconds. PyPI, npm, and RubyGems all allow publication without lengthy review.

The kill chain runs in four stages:

1. Discovery — Attacker queries LLMs at scale to harvest hallucinated package names 2. Registration — Attacker claims the names before the genuine package appears 3. Weaponization — Malicious payload is uploaded, often disguised as legitimate utility code 4. Installation — Developer runs pip install, executes the payload

Socket’s 2025 threat report documented a single threat actor registering over 150 hallucinated package names across PyPI and npm in a three-month span, all linked to the same C2 infrastructure.

Article section image 1
Photo: Danny Meneses · Pexels · Pexels License (free for editorial use, attribution required)
AI-assisted coding shifts the asymmetry dramatically in the attacker’s favor. What was once a low-probability typosquatting gamble is now a curated list of high-probability targets generated by the LLM itself.

Why 2025 Changed the Calculus

Three converging trends turned an academic curiosity into a category-one threat: AI assistants moved from autocomplete to autonomous generation, security tooling lagged model iteration speed, and attackers industrialized the harvesting process. The 2024 paper from UT Austin showed the hallucination rate at 21.7%, while the Snyk 2025 State of Open Source Security report tracked a 248% year-over-year increase in malicious package attacks.

Attack Vector 2023 Volume 2025 Volume Growth
Hallucinated-package typosquatting <50 incidents 2,300+ incidents 46x
Compromised legitimate packages 1,200 4,200 3.5x
Dependency confusion attacks 800 1,900 2.4x
Repo-jacking via AI commit messages 30 410 13.7x

The Defensive Playbook

1. Verify Before Installing

Every package an AI assistant suggests should be cross-checked on the official registry before installation. A literal lookup on pypi.org or npmjs.com — not just pip install. The five-second manual check defeats the entire category. For teams using AI code generation heavily, automated gates are table stakes:

  • Pre-install hook — wrapper around pip/npm that blocks unapproved packages
  • Reputation checkSocket, Snyk, or Aikido flag low-reputation packages at install time
  • Lockfile review — human review of any new dependency added to a lockfile
  • 2. Pin and Reproduce

    Lockfiles with pinned versions and hash verification (pip install --require-hashes, npm package-lock.json with integrity hashes) prevent both typosquatting and silent-replacement attacks. Pin everything.

    A pinned dependency is a defeated dependency-confusion attack. The defense is older than the threat, but AI-assisted code generation finally made it operationally non-optional.

    3. Segment Trust Boundaries

    Developers should treat AI-suggested code as untrusted input — the same threat model as copying from Stack Overflow. npm install --ignore-scripts and pip install --no-deps --no-build-isolation reduce a successful install’s attack surface dramatically.

    Article section image 2
    Photo: Brett Sayles · Pexels · Pexels License (free for editorial use, attribution required)

    What to Do Today

    For engineering leaders: turn on Socket or Snyk in CI this week. For individual developers: verify every package before install, every time. The hallucination economy is a security problem we saw coming. Acting on it is overdue.

    Frequently Asked Questions

    What is an AI package hallucination attack?

    An attack where an AI coding assistant suggests a non-existent or wrong package name, which an attacker then registers on a public package registry and weaponizes before the legitimate package ever appears. The developer installs the malicious package, believing it was endorsed by the AI.

    Which AI tools are most affected?

    All major AI coding assistants hallucinate package names, including GitHub Copilot, Cursor, Claude Code, and ChatGPT. None are immune. The UT Austin study found roughly 20% of suggested imports point to non-existent packages.

    How do I check if a package exists before installing?

    Search pypi.org, npmjs.com, or rubygems.org directly in your browser, or use the registry’s JSON API. Do not rely on pip install succeeding or failing as a signal — by the time you test, an attacker may have registered the name.

    Are package typosquatting attacks new?

    Typosquatting itself is decades old. The novelty is that AI assistants now generate plausible package names at scale. The 2024-2025 surge is specifically AI-driven.

    What tools can detect hallucinated packages?

    Socket, Snyk, and Aikido flag low-reputation and recently-created packages at install time and in CI. Socket’s 2025 update specifically targets AI-hallucinated names.

    Should we block all AI-suggested packages from being installed?

    Not block, but gate. Allowlist trusted packages, require explicit approval for anything else, and route AI-generated dependency changes through a security review process before merging.

    What is the most common payload in these attacks?

    Information stealers targeting browser credentials and crypto wallets, followed by reverse shells and dependency-confusion droppers. Persistence matters more than immediate damage.

    Stay Ahead of Supply Chain Risks
    Subscribe to the Networkcraft security brief for weekly threat intel and defense playbooks.

    Subscribe Free

    Sources
    Socket 2025 Threat Report
    University of Texas at Austin — Do Users Write More Insecure Code with AI Assistants (CCS 2024)
    Snyk 2025 State of Open Source Security
    PyPI Security Working Group public advisories Q1-Q2 2025
    Sara Voss
    https://networkcraft.net/author/sara-voss/
    Investigative Tech Reporter at Networkcraft. The most important security story is usually the one nobody's covering yet. Specialises in cybersecurity, digital privacy, data breaches, and the policy decisions that shape how technology affects civil liberties.