Articles

Direct and indirect prompt injection

One weakness, two attack paths: the instruction comes from the user, or from the content.

Reading: 4 minAutomation & AI

Article cover: Direct and indirect prompt injection

A language model receives one stream of tokens. The developer’s instructions, the user’s question and any document pulled into the request all arrive together, and nothing in the architecture marks where one ends and the next begins. Prompt injection is what happens when that boundary is exploited: the model treats text meant to be read as text meant to be obeyed. OWASP puts it plainly — a prompt injection vulnerability “occurs when user prompts alter the LLM’s behavior or output in unintended ways” — and ranks it first on its 2025 list.

The distinction is who supplies the hostile instruction. In a direct injection the person typing to the model is the attacker. In an indirect injection the instruction is planted in content the model later reads — a page, a file, an email — and the victim is often someone who never typed anything. Both are the same flaw reached by a different path.

One stream, two kinds of text

A model has no region for “code” and another for “data”; it has one token sequence and a habit of satisfying the whole of it. The paper that named the indirect variant says LLM-integrated applications “blur the line between data and instructions.” A system prompt is a strong suggestion, not a firewall: once untrusted text sits in the same input, no framing tells the model which sentences are commands.

Direct injection

OWASP defines direct injections as occurring “when a user’s prompt input directly alters the behavior of the model in unintended or unexpected ways,” and NIST’s Generative AI Profile describes an attacker who crafts “malicious prompts and input them directly to a GAI system.” Reach is the defining feature: the attacker places the text himself, so the damage is bounded by what that conversation can touch. Jailbreaking is a sub-case, not a separate problem — OWASP calls it “a form of prompt injection where the attacker provides inputs that cause the model to disregard its safety protocols entirely.”

Indirect injection

Indirect injection is the harder problem, and why this sheet sits at L4. Here the instruction is not typed into the conversation; it is hidden in material the model retrieves. OWASP again: indirect injections “occur when an LLM accepts input from external sources, such as websites or files.” Google draws the contrast — direct injection is where “an attacker directly inputs malicious commands into a prompt,” while indirect injections “involve hidden malicious instructions within external data sources.” The danger is the split between attacker and victim: Greshake et al. describe vectors that “enable adversaries to remotely (without a direct interface) exploit LLM-integrated applications by strategically injecting prompts into data likely to be retrieved,” and NIST adds that such attacks work by “stealing proprietary data or running malicious code remotely on a machine.” One poisoned source can reach many sessions — which is why indirect injection behaves less like a chat trick and more like a supply-chain problem.

Why the severity depends on what the model can do

The payload matters less than the permissions of the model that reads it. OWASP names the general failure Excessive Agency — “the vulnerability that enables damaging actions to be performed in response to unexpected, ambiguous or manipulated outputs from an LLM” — and its triggers include “direct/indirect prompt injection from a malicious user.” Its impact list runs from “Providing unauthorized access to functions available to the LLM” to “Executing arbitrary commands in connected systems.” That turns an injection into an incident — exactly what a tool-using system creates: a model that can only write text writes the wrong text, but one that can send mail or run a command does those things. As Greshake et al. put it, processing retrieved prompts “can act as arbitrary code execution, manipulate the application’s functionality, and control how and if other APIs are called.”

What mitigation actually looks like

There is no single fix. OWASP notes that retrieval and fine-tuning “do not fully mitigate prompt injection vulnerabilities,” and Greshake et al. recorded that “effective mitigations of these emerging threats are currently lacking.” What holds is architectural, not rhetorical: CaMeL builds a layer outside the model so that “the untrusted data retrieved by the LLM can never impact the program flow,” attaching capabilities that “prevent the exfiltration of private data over unauthorized data flows,” with “predefined policies prevent unintended consequences caused by prompt injection attacks.” Google describes the same posture in production — detection classifiers, URL redaction, and confirmation before risky actions — so a bypass is visible and bounded. The practical reading: treat every retrieved document and tool result as untrusted input; keep the model’s authority narrower than the harm a bad instruction could do; and put a check the model does not control before any consequential action.

Level and prerequisites. L4 — an operations-and-risk sheet that only means something once an agent is already built: the reader has to know what a tool call and a retrieved passage are before this failure mode can be reasoned about. Prerequisites: the L1 sheets on prompts, system instructions and messages and on the context window, and the L3 sheets on retrieval failures and on source access control.

Where to go next

References

  • OWASP — Top 10 for LLM Applications, 2025 — the LLM01 definition of prompt injection, the direct/indirect split, jailbreaking, the impact list, the Excessive Agency trigger, and the limits of RAG and fine-tuning.
  • Greshake et al. — Not what you’ve signed up for — the origin of the indirect-injection concept and the data-versus-instructions framing.
  • NIST — AI 600-1, Generative AI Profile — the direct/indirect distinction restated and the demonstrated consequences.
  • Google GenAI Security Team — Mitigating prompt injection attacks with a layered defense strategy — the indirect definition and a deployed layered defence.
  • Debenedetti et al. — Defeating Prompt Injections by Design (CaMeL) — the architectural defence and the capability model.
Nodrius Field Kit — cover

Get the Nodrius Field Kit

Enter your email and we'll send you the complete Field Kit: eight technical resources in one download.

Your email address is sent to Nodrius and used to deliver the Field Kit to you by email. Marketing messages are separate and optional: the checkbox does not affect your download, and you are only added to our updates list if you tick it. Privacy Policy.

Privacy & cookies

This site does not use cookies, analytics or tracking, and it does not profile you. There is nothing technical to switch off, so Accept and Reject change nothing about how the site works: either choice lets you browse everything normally.

The only difference is what your browser remembers: two entries in local storage — your choice here, so this notice is not shown again, and a marker that the Field Kit offer has already been made — so the offer is presented once and not on every page. They contain no identifier, they are not shared with anyone, and the site sets no cookie for either.

What we do with your data
How your email address is used when you ask for a Resource, how long it is kept and which rights you have — in the Privacy Policy.
What the site stores in your browser
Two entries in local storage — your choice on this notice and whether the Field Kit offer has been shown — and no cookies, no session storage, no third-party content: in the Cookie Policy.