Hallucination as an Attack Surface: Package Confusion and Slopsquatting
Hallucination — a model confidently generating false information that sounds entirely plausible — is usually discussed as a reliability problem: an AI system giving a wrong answer, citing a source that doesn't exist, or inventing a fact that sounds authoritative but isn't. What's less widely understood is that hallucination has become a genuine, directly exploitable attack vector, most clearly illustrated by a technique researchers have named slopsquatting: registering a real software package under a name an AI coding assistant reliably and repeatedly hallucinates, then waiting for developers who trust the AI's suggestion to install it.
The mechanism, step by step
AI coding assistants are extensively used to suggest dependencies and generate installation commands for a given task — asked to write code that performs some function, a model will often suggest importing or installing a specific package to accomplish it. Research examining this behavior across popular coding-focused models found that a meaningful percentage of package names suggested by these models don't actually exist on the relevant package registry at all — the model, having learned the general pattern of what plausible package names for a given task tend to look like, generates a name that fits the pattern convincingly but was never a real, registered package.
Critically, this isn't random, one-off noise — the same hallucinated package name often gets suggested repeatedly and consistently across many separate queries, sometimes across different models entirely, when asked similar questions. This consistency is what makes the attack practical: an attacker doesn't need to guess randomly at what a model might hallucinate. They can systematically query popular coding assistants across common development tasks, identify the specific hallucinated names that come up reliably and repeatedly, and then simply register real, functioning packages under those exact names on the actual package registry, populated with genuinely malicious code, and wait.
Why this works so reliably once the trap is set
The attack's effectiveness rests on a well-documented behavioral pattern: developers, especially when working quickly or under time pressure, frequently trust an AI coding assistant's package suggestions without independently verifying that the suggested package is legitimate, actively maintained, and actually does what its name and description imply. This isn't a failure of individual developer diligence so much as a predictable consequence of how these tools get used in practice — the entire value proposition of an AI coding assistant is speeding up development by reducing exactly the kind of manual verification step that would normally catch this, which means the tool's own core benefit directly works against the friction that would otherwise prevent this specific attack from succeeding.
Once a developer runs the install command the assistant suggested, trusting the AI's judgment the same way they might trust a well-known package with an established reputation, the malicious package executes with whatever permissions the installation process grants it — which in many development environments is substantial, since package installation scripts routinely run with meaningful system access as a completely normal, unremarkable part of the installation process.
How this differs from traditional typosquatting
Traditional typosquatting — registering a package name that's a common misspelling or close visual variant of a genuinely popular, legitimate package — has been a known software supply chain risk for years, and defenses against it (name-similarity detection, verified-publisher badges, download-count reputation signals) have matured considerably as a direct response. Slopsquatting is a meaningfully different threat model that those existing defenses don't fully address: the malicious package name isn't a variant of an existing popular package at all — it's an entirely novel name that happens to be exactly what an AI assistant reliably suggests, with no direct textual relationship to any real, existing package a similarity-based typosquatting defense would be looking for.
This means existing typosquatting defenses, built around detecting names that closely resemble already-popular legitimate packages, provide limited protection against slopsquatting specifically, because the hallucinated name has no necessary resemblance to any real package at all — its "legitimacy signal," from the victim's perspective, comes entirely from the AI assistant's confident suggestion, not from any resemblance to something the victim already independently trusts.
Why this is a genuinely new category, not just typosquatting with extra steps
It's worth being precise about why this deserves treatment as its own distinct risk category rather than a minor variant of an already well-understood problem. The trust relationship being exploited is fundamentally different: traditional typosquatting exploits a human's visual or typing error, relying on the victim briefly not noticing a subtly misspelled name. Slopsquatting exploits a human's trust in an AI system's judgment, relying on the victim never independently verifying a suggestion in the first place because the AI's authority as a technical assistant substitutes for that verification step entirely. As AI-assisted development tools become more deeply embedded in normal development workflows, this trust-substitution dynamic is likely to become a more significant vector over time, not a smaller one, as developers increasingly treat AI suggestions with the same unquestioned confidence they might extend to a senior colleague's recommendation.
The broader pattern beyond package names specifically
Package hallucination is the best-documented and most immediately actionable instance of this broader pattern, but the underlying dynamic — an AI system confidently hallucinating a plausible-sounding but nonexistent entity, which an attacker can then pre-register or impersonate to intercept users who trust the AI's suggestion — generalizes to other categories worth watching for. Hallucinated API endpoints, hallucinated documentation URLs, hallucinated configuration file names, and hallucinated third-party service names are all structurally similar opportunities for an attacker who systematically identifies what a popular AI assistant confidently but incorrectly suggests, then positions malicious infrastructure to intercept anyone who trusts that specific suggestion without independent verification.
Why reducing hallucination alone won't solve this
It's tempting to treat this purely as a model-quality problem that will resolve itself as hallucination rates improve with better models over time, but that framing significantly understates the durability of the underlying risk. Even a meaningfully reduced hallucination rate still produces some volume of confidently wrong suggestions at the scale AI coding assistants now operate — millions of daily queries across the developer population — and a persistent, reliably-triggered hallucination pattern needs to occur only occasionally to be worth an attacker's modest effort to identify and exploit, especially given how cheap registering a package name typically is relative to the potential payoff of a successful supply chain compromise. Treating this as "waiting for better models to fix it" significantly underestimates both how durable the underlying pattern is likely to remain and how quickly attackers can adapt to exploit whatever hallucination patterns persist, however reduced in overall frequency.
Practical mitigations for organizations using AI coding assistants
The most direct organizational mitigation is process-based rather than purely technical: requiring independent verification of any AI-suggested package before installation — checking the package's actual publish history, download counts, maintainer reputation, and source code, the same due diligence that should already apply to any new third-party dependency regardless of how it was discovered. This is, in effect, applying the same supply chain scrutiny principle covered in the broader AI supply chain piece elsewhere in this series to this one specific, well-documented entry point.
Beyond individual developer discipline, organizational tooling can help close this gap systematically: automated dependency scanning that flags newly-published, low-reputation packages for manual review before they're approved for use, internal registries or approved-package allowlists that require an explicit review step before a new dependency can be added regardless of its source, and specific developer education about this technique category — since many developers simply aren't aware that AI-suggested packages carry this particular risk, and awareness alone meaningfully changes verification behavior even without new tooling investment.
Why this matters for AI security assessment specifically
For organizations evaluating their own AI-assisted development workflows as part of a broader security assessment, testing for this specific risk means systematically probing whatever coding assistant is in actual internal use for hallucinated package suggestions across common development tasks, checking whether any of the specifically hallucinated names are already registered (whether benignly or maliciously) on the relevant package registry, and assessing whether the organization's current development process includes any independent verification step before an AI-suggested dependency actually gets installed into a real project. This is a genuinely different kind of testing than most of the technique categories covered elsewhere in this series — it's testing an organizational workflow and its surrounding verification discipline as much as it's testing the AI system itself, which makes it a good illustration of how AI security assessment increasingly needs to extend beyond the model and application boundary into the broader human processes built around it.
How package registries themselves are responding
Some package registry operators have begun responding to the documented reality of slopsquatting with additional scrutiny for newly registered packages that match patterns associated with AI-hallucinated names — unusual naming conventions, suspiciously generic descriptions closely matching common AI-generated phrasing, or a burst of installs immediately following registration with no organic growth pattern typical of a legitimate new package gaining real adoption over time. This registry-level response is a genuinely valuable complementary layer to organizational-level verification discipline, though it remains an evolving, imperfect defense rather than a complete solution — a sufficiently patient or careful attacker can still register a plausible-looking package with enough apparent legitimacy to avoid triggering automated registry-level suspicion, which is exactly why organizational-level verification remains necessary even as registry-level defenses continue to mature.
Why this risk will likely grow before registry and tooling defenses fully mature
Given how rapidly AI-assisted coding tool adoption has grown, and how much lead time registry operators and tooling vendors need to build and deploy mature defenses specifically calibrated to this attack pattern, there's a real, current window during which this risk is likely to be more significant than it will eventually become once defenses mature — which argues for organizations to treat this as an active, current priority for developer education and process controls now, rather than waiting for registry-level or tooling-level defenses to mature and close the gap on their own. The organizations that build independent verification discipline into their development workflow today are protected regardless of how quickly external defenses eventually mature; those that wait remain exposed for exactly as long as that maturation takes.
How this connects to the AI supply chain piece elsewhere in this series
Slopsquatting is worth understanding as a specific, well-documented instance of the broader AI supply chain risk covered elsewhere in this series, applied at the point where AI-assisted development intersects with traditional software dependency management. The same underlying lesson from that piece applies directly here: verification and provenance discipline that traditional software supply chain security has spent years building can't simply be assumed to extend automatically to a new class of risk this specific, novel — it needs deliberate, specific attention and, in this case, specific developer education about a genuinely new failure mode that didn't exist before AI coding assistants became a standard part of the development workflow.
This connection also suggests where responsibility for addressing this risk should sit organizationally: not purely with whichever team evaluates AI tooling for adoption, and not purely with the traditional application security team responsible for dependency scanning, but genuinely at the intersection of both — a gap that, left unowned by either team individually, tends to fall through the cracks in exactly the way this piece has described happening in practice at organizations that haven't yet explicitly assigned it to anyone.
A brief note on the term itself and why naming this pattern mattered
The coining of "slopsquatting" as a specific, memorable term for this technique — deliberately echoing "typosquatting" while signaling a distinct mechanism — has done real, practical work in raising awareness of the risk beyond the narrow academic research community that first documented it. Naming a security pattern clearly and memorably is an underrated part of effective defense: a well-named, easily communicated risk gets discussed, budgeted for, and defended against considerably more readily than an equally real but only abstractly described one, which is a genuinely useful lesson for security communicators generally, not just for this specific technique.
Extending the same scrutiny to internal, self-hosted coding assistants
Organizations running their own internally fine-tuned or self-hosted coding assistants, rather than relying purely on a major commercial provider's tool, carry an additional dimension of this risk worth naming specifically: an internal model's hallucination patterns are unique to that specific model and its specific training data, meaning published research documenting hallucination patterns in popular commercial tools provides limited direct guidance for what an internal, custom-trained assistant will itself tend to hallucinate. Organizations in this position should run their own systematic probing exercise — querying their internal assistant across common development tasks and checking whether any consistently suggested package names are unregistered and available for a malicious actor with any knowledge of the organization's internal tooling to claim — rather than assuming the general research findings from commercial tools transfer directly to their own, differently trained system.
This is a genuinely realistic scenario worth taking seriously rather than dismissing as overly hypothetical: an internal coding assistant's hallucination patterns could, in principle, be probed by a sophisticated attacker with some knowledge of or access to the organization's tooling, in exactly the same systematic way researchers have probed commercial tools, and the resulting insight used to specifically target that organization with a tailored slopsquatting attempt rather than a generic one aimed at the broader developer population.
How CI/CD pipelines compound this risk beyond the individual developer
The risk described throughout this piece scales considerably when an AI coding assistant's suggestions flow into automated CI/CD pipelines rather than only into a single developer's manual install command — a pipeline that automatically installs dependencies suggested or generated by an AI step with no human review gate processes a malicious slopsquatted package with the full authority and access of whatever build or deployment environment that pipeline runs in, potentially far broader than a single developer's local machine. Organizations increasingly experimenting with AI-assisted or AI-generated build and deployment automation should treat any AI-suggested dependency addition within that automated pipeline as requiring at least the same manual review gate a human-proposed change would already require, rather than allowing full pipeline automation to remove the verification step this piece has argued is essential.
Closing summary
Slopsquatting is a clean illustration of a pattern this series returns to repeatedly: a genuine, useful AI capability — confident, fluent suggestion of plausible-sounding content — carries a directly exploitable failure mode as an inseparable side effect, discoverable and weaponizable by anyone willing to do the modest, low-cost work of systematically probing for it. The defense isn't waiting for hallucination rates to improve; it's restoring the independent verification step that AI-assisted development tools have made easy to skip, and treating every AI-suggested dependency with the same scrutiny any new, unfamiliar third-party package would already deserve.
Want to know whether your own agent holds up against techniques like these?
Run a Free Mini Assessment