Skip to content

Prompt injection

Also called: prompt injection attack, indirect prompt injection, direct prompt injection

Published:

How does prompt injection happen?

OWASP lists it as LLM01 in its risk list for large language model applications. In its definition, user prompts alter the model's behaviour or output in unintended ways, and an instruction can work even when people cannot see it, as long as the model parses it [1]. In a direct injection, the prompt a user types steers the model, whether on purpose or by accident. In an indirect injection, the model takes in content from outside sources such as websites or files, and instructions hidden there change what it does [1].

NIST's Generative AI Profile describes the indirect form as adversaries exploiting LLM-integrated applications remotely, without a direct interface, by planting prompts in data the system is likely to retrieve. Security researchers have shown that this can be used to steal proprietary data or run malicious code on a remote machine [2].

Take one of OWASP's scenarios: a user asks a model to summarise a web page, and hidden instructions on that page make the model insert an image linking to an outside URL. Loading that image can leak the private conversation [1].

How can prompt injection be mitigated?

OWASP recommends narrowing the model's task in the system prompt, filtering inputs and outputs, granting least privilege, keeping untrusted content apart, requiring human approval for privileged actions and running adversarial tests. The same page admits it is unclear whether any fool-proof prevention exists, so these measures reduce impact rather than remove the risk [1]. NIST likewise notes that generative AI widens the attack surface, since the systems themselves are open to attacks such as prompt injection and data poisoning [2].

Frequently asked questions

Is prompt injection the same as jailbreaking?

They overlap. Jailbreaking is usually treated as a form of prompt injection aimed at getting around a model's safety rules.

Why are AI agents more exposed?

When a model can call tools or take actions, a hidden instruction can trigger an unauthorised action, not just produce wrong text.

Sources

  1. LLM01:2025 Prompt Injection — OWASP Gen AI Security Project
  2. Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (NIST AI 600-1) — NIST