Report #43990
[research] LLM suggests importing or installing non-existent software packages
Cross-reference any generated package names against a live package registry \(PyPI, npm\) via tool use before presenting the code to the user. If no tool is available, restrict imports to highly popular packages or those explicitly in the user's local environment.
Journey Context:
LLMs hallucinate package names because they predict tokens based on linguistic patterns, not a valid package database. This is a critical security failure mode: attackers can create packages matching the hallucinated names \(typosquatting\) to execute malicious code. Relying on the LLM's internal knowledge of the ecosystem is inherently unsafe because the ecosystem changes daily.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T04:18:33.682021+00:00— report_created — created