liveBook · Manning

Package hallucination

As explained in Introduction to Generative AI, Second Edition

Package hallucination is the generation of plausible-sounding but nonexistent software package names by a language model.

Package hallucination occurs when a language model invents a plausible-sounding software package name that does not exist. Coding assistants may suggest names such as “easydatax” or “datastreamlite,” especially for niche tasks where legitimate libraries are less familiar. section 5.3

The risk develops through a recognizable supply-chain pathway:

  • A developer trusts an AI-generated dependency suggestion without verifying the package. section 5.3
  • An attacker registers the fabricated name on a public repository with malicious contents. section 5.3
  • Installing the package can compromise the developer’s system or project. section 5.3

Package hallucination versus slopsquatting

Slopsquatting imitates a legitimate package name; package hallucination fabricates an entirely new, plausible name. Attackers therefore may exploit AI-generated names without mimicking existing libraries. section 5.3

How Introduction to Generative AI, Second Edition covers it

How deep it goes
Defines the phenomenon, gives examples, reports frequency, and traces exploitation through public package repositories.
Examples
Uses “easydatax” and “datastreamlite” as fabricated package-name examples and contrasts them with slopsquatting.
What you can do after
Evaluate AI-suggested dependency names cautiously before installing them from public repositories.
How it connects
Connects package hallucination with large language models, AI coding assistants, software supply-chain attacks, slopsquatting, PyPI, and npm.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Introduction to Generative AI, Second Edition. The section links point to the parts of the book it draws on.