Skip to content
Back to the glossary

AI Hallucination and Non-Determinism

AI hallucination is output a language model states with confidence that is false or unsupported; non-determinism is the tendency of the same model to answer the same input differently from one run to the next.

What is AI hallucination?

AI hallucination is output from a large language model (LLM) that sounds plausible and is presented with confidence but is false, fabricated, or unsupported by the model’s input. Examples include invented citations, nonexistent software packages, wrong API parameters, and vulnerabilities that do not exist. Non-determinism is the related property that a model can return different outputs for an identical prompt, so a hallucination may appear in one run and not the next, which makes both hard to test and to reproduce.

NIST uses the term confabulation for the same phenomenon. The Generative AI Profile (NIST AI 600-1), published in July 2024 as a companion to the AI Risk Management Framework, lists it among the risks that generative AI creates or worsens and defines it as “confidently stated but erroneous or false content,” noting that the colloquial names are hallucinations and fabrications. In security terms, the risk sits under Misinformation in the OWASP Top 10 for LLM Applications, and MITRE ATLAS catalogs the attacker techniques that exploit it.

Why language models hallucinate

An LLM generates text by predicting likely next tokens. It has no built-in check that a statement is true, only that it resembles the text it was trained on. A September 2025 paper from OpenAI researchers traces hallucination to two sources, both rooted in model training. Because pretraining text carries no labels marking statements as true or false, a model picks up regularities, such as spelling, as it scales, while one-off facts, such as a pet’s birthday, follow no pattern it could learn. Evaluation then reinforces the problem, because benchmarks that score accuracy alone reward a guess over an answer of “I don’t know.” The same article reports, from the GPT-5 system card, that on the SimpleQA benchmark OpenAI o4-mini abstained on 1% of questions and had a 75% error rate, while gpt-5-thinking-mini abstained on 52% and had a 26% error rate, at similar accuracy.

The practical consequence for security teams is that hallucinations are most likely exactly where a model has the least data: internal API names, rare library versions, newly disclosed CVEs, and the specifics of a target application. These are the details that AI agents need to get right when they write code, call tools, or report findings.

Non-determinism in LLM output

Most deployed models sample from a probability distribution over next tokens, so with a nonzero temperature the same prompt produces different text by design. Setting the temperature to zero is often assumed to make output repeatable, but in practice it does not. Research published by Thinking Machines Lab in September 2025 ran one prompt 1,000 times at temperature zero against Qwen3-235B-A22B-Instruct-2507 and received 80 distinct completions, which were identical for the first 102 tokens and then diverged. The authors attribute this to a lack of batch invariance in inference servers: The numerical result for a request depends on how many other requests share its batch, and server load changes batch size unpredictably. With batch-invariant kernels, all 1,000 completions matched, at the cost of slower generation.

For testing, non-determinism has two effects. A prompt injection or jailbreak that fails once does not show that the application is safe, since it may succeed on the tenth attempt, so results are better expressed as success rates over repeated runs. A finding produced by an AI tool may also fail to reproduce when a second engineer reruns it, which is a problem for triage, retesting, and audit evidence.

How attackers exploit hallucination

Hallucinated package names are the best-documented case: In a study accepted at USENIX Security 2025, Spracklen et al. generated 576,000 code samples with code-generating models and found that at least 5.2% of recommended packages from commercial models and 21.7% from open-source models did not exist, with 205,474 unique hallucinated package names. An attacker who registers one of those names in a public registry receives installs from every developer who trusts the suggestion, a form of software supply chain attack sometimes called slopsquatting.

MITRE ATLAS models the attack in two techniques, according to the ATLAS data release 2026.10 dated October 2026:

TechniqueNameWhat the adversary does
AML.T0062Discover LLM HallucinationsPrompts models for software packages, commands, URLs, organization names, or email addresses and identifies the ones with no real-world source
AML.T0060Publish Hallucinated EntitiesRegisters or creates the hallucinated entity so that victims who follow the model’s output reach attacker-controlled resources

A worked example shows the chain. A developer asks a coding assistant for a library that rotates JWT signing keys, and the assistant answers with pip install followed by a plausible but unregistered package name. An attacker who has already queried the same model with similar prompts has found that name recurring and published a package under it with a malicious install script. The developer’s install runs the script in a CI runner with deployment credentials. This is one reason AI-generated code security reviews check that every new dependency exists, is maintained, and is the package the developer intended.

Hallucination in the OWASP Top 10 for LLM Applications 2026

The OWASP Top 10 for LLM Applications 2026, published by the OWASP GenAI Security Project on August 3, 2026, lists Misinformation as LLM07:2026, up from ninth place in the 2025 edition. According to the Cloud Security Alliance analysis of the release, practitioners voted the category low because hallucination had been treated as a quality issue, and this edition was the first to ground the ranking in incident data as well as practitioner votes. Help Net Security reports that the incident record ranked Misinformation near the top, which pushed it up. The LLM07:2026 entry also widens the scope. Where the 2025 entry focused on humans over-trusting fluent answers, the 2026 entry also covers model outputs that drive tool calls, code, and decisions by other agents.

That shift links hallucination to excessive agency: A chatbot that invents a refund policy misleads a customer. An agent with write access that invents a parameter value, a record ID, or a remediation step changes a production system. The 2025 Misinformation entry (LLM09:2025) already listed package hallucination as an attack scenario and recommended grounding through retrieval, automatic validation of key outputs, and human oversight for critical or sensitive information.

Hallucination in AI-driven security testing

Security tools built on LLMs inherit the same failure. A model asked to review an API can describe a vulnerability with a plausible endpoint, payload, and impact that does not exist in the target. Open-source maintainers have reported the cost on the receiving end: The curl project’s lead maintainer wrote in July 2025 that about 20% of the project’s security report submissions that year had been AI-generated, while about 5% were genuine vulnerabilities.

A hallucinated finding is a false positive with a convincing write-up, which makes it more expensive to triage than a scanner’s pattern match. The established control is exploit validation: A finding is reported only when the target’s own response confirms it, for example, a second user’s record returned with the first user’s token. Non-determinism points to the matching control on the other side, which is that a confirmed finding should carry the exact requests needed to reproduce it, so that reproduction does not depend on the model generating the same reasoning twice. Designs that confine the model to choosing actions inside a fixed workflow, an approach known as controlled autonomy, reduce the room for invented steps.

How to test an LLM application for hallucination risk

  • Ask questions whose correct answer is “unknown” or “not in the provided documents” and check whether the application abstains or invents an answer.
  • Request package names, API endpoints, policy details, and URLs, then verify each against the real registry, specification, or source.
  • Run every adversarial prompt several times, or at the temperature used in production, and record the success rate instead of a single pass or fail.
  • Feed the application retrieved content with missing facts or contradictions and check whether its answer stays within the source material.
  • Where the model drives tools, check that downstream systems validate the parameters it supplies, such as IDs, amounts, and file paths, before acting on them.
  • Repeat the tests after model, prompt, or retrieval changes, since a provider update can change behavior without any code change in the application.

Testing AI applications with Equixly

Equixly runs AI penetration testing against web applications, APIs, LLM applications, and MCP servers. For LLM applications, it runs adaptive AI red teaming that profiles the application before attacking it. In its own testing, attacks run against the live target, and the engine validates the outcome during the test, so findings rest on the target’s response rather than on model output alone. Its agents operate within a deterministic, controlled-autonomy framework.


Did you like our post? Share it on social!

  • AI Penetration Testing

    AI-driven security testing that uses autonomous systems to identify and validate exploitable vulnerabilities across applications, APIs, and infrastructure at a speed and scale that manual testing cannot replicate.

  • AI Red Teaming

    Adversarial testing of LLMs, AI agents, and AI-integrated systems using the techniques real attackers use - identifying exploitable vulnerabilities in AI behaviour before they reach production.

  • AI-Generated Code Security

    The practice of finding and fixing vulnerabilities in code written by large language models and coding agents, before and after that code reaches production.