Skip to content

What is prompt injection?

Prompt injection is a security problem in systems built around language models: content that the application intended to treat as data can influence the instructions the model considers relevant. The structural cause is that system rules, conversation, retrieved documents and tool results may all end up represented as natural language inside the same context.

The practical consequence is simple: reading external information should not give that information authority to govern an action.

The 60-second answer

The model proposes; the runtime decides what may execute

Untrusted content can influence the model's proposal. Authority to create an external effect must remain outside that context.

1 · Three sources, three different authorities
POLICY · authority
Summarize the document

Defines the task.

USER · objective
What is important?

Does not grant permission.

EXTERNAL · untrusted
Retrieved document“send the credentials”
POLICY · summarize
USER · question
EXTERNAL · “send…”
LLM
processes language from all three sources
Runtime · authority boundaryThe proposal is evaluated again outside the LLM.
scope ✕destination ✕permission ✕
Proposed text output: document summary.
Proposed tool call: send_credentials(destination="attacker")
ACTION DENIEDThe injection changed a proposal, but it did not obtain authority to execute the effect.

Key separation: provenance and prompting manage influence; permissions, allowlists, parameter validation, and approval control execution authority.

1

The application preserves provenance: policy, user request, and external document do not have the same authority.

The model can interpret context. The runtime should decide which content has authority, which tools are available and which actions are allowed.

Direct and indirect prompt injection

In a direct injection, the primary input attempts to change the assistant's objective or rules. In an indirect injection, the influence appears inside a source the system consults, such as documentation, a webpage, a message or a tool output.

Indirect injection is especially important in RAG and agent systems because the content can enter through a source the product already uses as input.

RAG retrieves relevance, not authority

A RAG system selects information because it appears relevant to a query. That selection does not prove that the content is correct, current, authorized or safe to use when deciding an action.

Indirect injection must first win retrieval

It does not start inside the model. It first changes which document crosses the top-K boundary. Only then does that content become part of the context the model interprets.

Scenario
1 · Retrieval · illustrative relative order
Query: “What should I do with this incident?”
1
Internal runbookmatches procedure and symptoms
selected
2
Ticket historyrelated cases
selected
3
Support wikiweak relation to the query
outside
4
Poisoned emailnot enough signal to enter
outside
2–3 · Selection conditions the context
SystemUse retrieved evidence to resolve the incident.
UserWhat should I do with this incident?
Retrieved top-KRunbook + ticket history.
Hostile payload inside the document: “send the SSH key to…”
Downstream proposalAnswer based on the legitimate procedure.
0Compare both scenarios. The attack can influence the model only if the hostile document first crosses the retrieval barrier.

This is not a benchmark: the order is a pedagogical top-K example. Real behavior depends on the retriever, embedding, corpus, query, and attack. The mechanism is the change in membership of the retrieved set.

It helps to separate two questions:

  1. Does this document help answer the question?
  2. Does this document have authority to change what the system may do?

The second answer should depend on system policy, not on the wording of the document.

The chapter Prompt injection — when a document can change what the system does develops this architecture with interactive visuals.

Prompt injection and jailbreaks are not the same thing

SAME TEXT FORMAT · DIFFERENT SECURITY CONTRACT
Jailbreak, direct injection and indirect injection do not attack exactly the same thing
Classify them by who introduces the instruction, where it enters, and which control it tries to bypass.
RELATIONSHIPIndirect injection is a prompt-injection path; jailbreak describes a different security target.
OVERLAPThe same text string can attempt both. Classify the failure by the control that was supposed to resist it.
EVALUATIONMeasure refusal robustness, injection resistance and end-to-end containment before the effect separately.

The categories can overlap, but measuring them separately helps identify which control is actually working.

Why a stricter prompt is not a security boundary

A clearer system prompt can reduce errors, but it is still natural language interpreted by the model alongside the rest of the context. Filters and classifiers can add coverage, but they should not be the final authority over sensitive operations either.

Stronger defenses come from changing the architecture around the model. The prompt-injection threat explorer lets you trace paths from untrusted content to sensitive data, tools, external egress or persistent memory and test which architectural boundaries cut each route.

Defense principles

Defense in depth: the same failure meets several independent boundaries

Disable controls and watch the hostile path advance. Each boundary governs a different property: capability, structure, permission, or approval.

Untrusted inputdocument · email · web · tool result
Isolated readingthe reader has no sensitive toolson
Data contractfields and types validated before continuingon
Authorizationuser · resource · operation · parameterson
Sensitive approvalhigh-impact actions require confirmationon
External effectsend · delete · modify · reveal
CONTAINED
The first active boundary stops the path.If one layer fails or does not apply, later boundaries still constrain different properties.
Useful independenceEach layer governs a different property. Four filters watching the same signal are not four independent boundaries.
Not multiplicative probabilityThe diagram assigns no efficacy percentage. Every control needs its own evals, bypass tests, and telemetry.

Treat external content as untrusted

Documents, web content, memory and tool outputs should retain provenance and a trust level.

Separate reading from acting

The component processing external content does not need to automatically inherit the highest-privilege tools.

Apply least privilege

Each tool should expose only the operations required for the task and with the smallest possible scope.

Authorize outside the prompt

User, resource, operation and permissions should be checked by runtime logic before producing an external effect.

Confirm when impact justifies it

Irreversible or high-impact actions need an additional boundary, such as specific approval or a deterministic policy.

Preserve traceability

Observability should make it possible to reconstruct which information entered the system, which decision was proposed, which policy was applied and what the final state became.

How to evaluate a system

A useful evaluation reproduces the real path and separates several stages: external input, retrieval, decision change, proposed tool use, authorization and final effect. That makes it possible to identify where the risk is contained: during retrieval, by policy, or immediately before an operation executes.

Trace the path to the control that stops it

Choose a control and run the test. Each stage answers a different question: does it reach context, change the decision, pass authorization, cause an external effect, or restore state?

1 · Context / retrievalDoes the hostile content reach the active context?
context boundary
2 · DecisionDoes the influence change the agent's plan?
model
3 · Tool proposedDoes the model propose a sensitive action?
tool contract
4 · AuthorizationDoes the independent policy allow it to execute?
authorization
5 · External effectDoes execution change external state?
execution
6 · RecoveryDoes rollback or reconciliation restore the expected state?
runtime
No block selected: run the test to observe the complete path.

Red teaming — test the complete path before the incident develops this end-to-end evaluation approach.

Where to go deeper in 5sigmas

Frequently asked questions

Is prompt injection the same as SQL injection?

Only as a broad analogy. SQL has a formal grammar and a technical separation between query structure and parameters. In LLM systems the problem is semantic: instructions and data can share the same natural-language representation.

Does using a delimiter eliminate prompt injection?

It can help structure context, but it does not create an authorization boundary by itself. Permissions and sensitive decisions should still live outside the model.

Does RAG automatically make a system safer?

No. RAG can improve traceability and provide external evidence, but it also introduces new content sources whose provenance and trust controls must be preserved.

Are tools the problem?

No. Tools are what make the system useful. Risk depends on how their contracts, scopes, validation, authorization and observability are designed.