Lesson 2 of 9 · 7 min read
Indirect Prompt Injection
In this lesson
TL;DR: Indirect prompt injection carries an attempted task redirection inside material the application processes, such as a retrieved document, message, image or tool result. Map who can influence that material, what reaches the model after transformation, and which data or effects the resulting proposal can reach.
Before you read
Pick an answer before you read further. The lesson below explains it, and guessing first, right or wrong, helps the explanation stay with you.
1A supplier can edit one document fetched by a procurement assistant, but cannot log in to the assistant itself. What must you establish before claiming that this creates a disclosure path?
What you should be able to do
Draw the path from a source writer to a specific assistant decision. Separate source access, ingestion, model influence and observed consequences. Then design an authorized test that checks both the blocked path and the legitimate task. The prompt-injection introduction explains why an input's role does not automatically give its author authority.
The writer can be several steps away from the assistant
Noor uses a fictional procurement assistant to compare two suppliers against internal requirements. The assistant may read approved supplier documents and a restricted requirements file, then prepare a draft for Noor. It has no grant to send the requirements to either supplier or change the procurement decision.
One supplier controls a public document that the assistant fetches. That document attempts to redirect the comparison and get internal requirements included in supplier-visible material. The supplier's ability to publish a document is a capability in the threat model. It is not permission to command the assistant or receive Noor's internal file.
The supplier need not operate the assistant's chat interface. But it may need an account on the document platform, permission to edit a particular page or access to an upstream integration. State the actual prerequisite. “No account required” is a property of some delivery paths, not the definition of indirect injection.
Source writer
Controls supplier page
Processed input
Selected revision and view
Assistant decision
Proposal may change
Effect service
Current grant and audience
Observed result
Record unknowns too
Identify the actual source capability
The fictional supplier edits one page. That does not establish access to the assistant, internal files or other sources.
Greshake and colleagues' 2023 indirect-injection paper studied attacker-controlled data reaching LLM applications through retrieval. The enduring lesson is to inventory source influence beyond the person typing a request. A trusted transport or authenticated tool can faithfully deliver content whose author has no authority over the task.
Inventory authors, transformations and audiences
Start at the model input and trace backward. A tool result may contain a database field copied from a customer message, and a summary may contain a conclusion inherited from several pages. Record uncertainty when source lineage is missing.
| Surface | Who might influence it | What to inspect |
|---|---|---|
| Retrieved supplier document | Page editors and upstream content publishers | Revision, selected chunks, parser behavior and retrieval eligibility |
| Internal requirements search | Authorized editors, imported documents and the indexer | Actual write permissions, source labels and document-level read policy |
| Tool response | Service operator and authors of returned fields | Which fields are service assertions and which carry source text |
| Extracted image or attachment | File author and transformation pipeline | Bytes received, extraction or rendering settings and derived text |
| Saved comparison or memory | Previous workers and the publication service | Evidence, intended audience, revision and later retrieval scope |
An internal location can carry externally authored text. A cryptographic transport check can identify the service without making every returned claim true. Source provenance is useful evidence for enforcement and investigation; merely showing a label to the model does not prevent disclosure.
Relevance and authority also differ. A supplier's document can be highly relevant to the comparison while remaining unable to redefine its scoring criteria. Conversely, source instructions may be exactly what Noor asked the assistant to explain. The application must preserve the distinction between reporting those instructions and accepting them as permission for a new action.
Inspect the representation the model actually receives
A text extractor, rendered-page reader and screenshot-based model can receive different representations of the same document. Hidden markup may survive one parser and disappear in another. Text inside an image may become visible to a vision model or an OCR stage. Do not claim that every model reads raw page text or that changing visibility always changes exposure.
Record the source revision and the transformation that produced the supplied representation. Showing a human the processed view can help explain a finding, but human visibility is not an authorization mechanism. Visible ordinary prose can also attempt to redirect the task. Removing hidden elements or limiting parsers can reduce a specific input surface without resolving source authority.
A derived summary needs the same discipline. A structured record or second model does not automatically turn source content into trusted evidence. If a downstream policy accepts the summary's self-reported audience, the writer may have moved its influence to a different field. Keep trusted policy inputs separate from values extracted or inferred from source material.
Five conditions to test, with different failure meanings
For Noor's case, ask whether the source can be modified, whether it reaches the relevant task, whether it changes the assistant's proposal, whether a service accepts the proposal, and whether the forbidden consequence occurs. An application may stop the chain at several places.
| Condition | Evidence to collect | Avoid this conclusion |
|---|---|---|
| Source influence | Authorized source changes and immutable revisions | An attacker can edit every document in the collection |
| Ingestion | Retrieved chunks or actual processed input | A low-ranked document can never be reached by a different query |
| Proposal | A source-associated change in a decision or request | Any output error proves malicious instruction following |
| Admission | Current grant and the service's allow or deny result | A model refusal proves the service itself enforces the policy |
| Outcome | Resource effects or delivery evidence | A missing receipt proves nothing happened |
These are observable conditions, not a prescribed attack recipe. Use only systems you own or are explicitly authorized to test, synthetic sensitive values and an isolated destination that cannot send real data. Exercise allowed supplier comparisons alongside the negative cases.
Work through an incomplete result
In a constructed evaluation, 20 source variants are tested once each. Twelve are retrieved into the selected task. Five of those runs produce a forbidden delivery proposal. Four proposals are denied by the delivery service. One is accepted, but the test observer loses the final result.
What can the report say? It observed ingestion in 12 of 20 cases, forbidden proposals in five of the 12 ingested cases, and four service denials among the five proposals. It has no confirmed forbidden delivery and one unresolved delivery outcome. Reporting “zero successful attacks” would hide that uncertainty. Reporting five leaks would confuse proposals with effects.
The set was constructed for these conditions; it is not a random sample of daily procurement work. Repeated attempts, changing queries and adaptive source revisions also need their own evaluation design. AgentDojo v3 (2024) is an example of research that evaluates agent security together with legitimate task performance. A benchmark result does not establish this product's incident probability.
Break the path with a policy the source cannot rewrite
For this task, the assistant does not need an external delivery capability. Remove that capability from the processing path and verify that alternate tools, direct credentials, queues and preview services cannot perform the same effect. Keep the draft in Noor's authorized workspace. This is a concrete scope reduction justified by the task, rather than a universal prohibition on useful automation.
If a later task genuinely requires delivery, the delivery service should check a current grant for the specific material and recipient. It must not infer permission from the supplier's document or from the fact that Noor can read the requirements. Approval is one way to obtain new authority when needed; an existing bounded grant may already cover the operation.
Review all rendered and persisted destinations. An application that disables its email tool might still fetch model-generated images, create link previews, export drafts or publish shared memory. A host allowlist is only one restriction: an allowed proxy, user-controlled path or recipient can still expose material outside its permitted audience. HTML sanitization helps prevent active-content execution; a syntactically safe URL can still carry confidential data.
Keep source labels, model training and detectors as additional measures. Test the particular reduction they provide. Down-ranking a document makes retrieval less likely under selected queries; an enforced exclusion policy can prevent it entering a specified path. Those are different control claims.
Prioritize the actual consequence
One source revision may be processed by several workers or users, but every reader does not automatically become compromised. Retrieval, model behavior, application permissions and output handling all affect the result. Shared caches and persistent summaries can extend reach and duration, so include them in containment and retesting.
Likewise, direct injection can reach a broadly privileged backend from an unauthenticated interface, while an indirect path may only affect a restricted draft. Compare observed effects, possible audiences, current capabilities and observation gaps. The 2025 OWASP taxonomy, checked November 2026, distinguishes input routes without making every indirect case a greater incident.
What if · interview follow-ups
Hold your answer as the constraints change
Noor's fictional procurement task permits a restricted comparison draft. Supplier-authored material is relevant evidence but cannot change grants or delivery audiences.
Start here
The page is in an authenticated supplier portal. Is the content authorized to change the task?
What did authentication establish?
It may identify the portal or editor and constrain who can change the page. It does not grant that source permission to revise Noor's task or receive internal requirements. Check the source's actual role and the effect policy.
Carry it forwardAn authenticated source still has a bounded role.
Weak answerConverting source identity into task authority.
Constraint changes
An experiment never retrieves the modified page. Is the source harmless?
Which queries and revisions did the experiment cover?
The tested path did not ingest that revision under those conditions. Different queries, indexing changes or downstream summaries can change reach. Keep that limited result and separately test paths that are reachable within the authorized scope.
Carry it forwardState the ingestion coverage instead of claiming universal absence.
Weak answerTreating one retrieval miss as an application-wide defense.
Constraint changes
A classifier flags the source and the assistant still produces a useful draft. Did the detector fail?
What action did the configured policy require?
A flag may be an advisory signal, a review trigger or an enforced block. Check the intended response and whether the draft stayed within permission and audience rules. Neither the flag nor useful output alone establishes policy failure.
Carry it forwardEvaluate detector behavior against its configured role.
Weak answerEquating every flagged input with a required total refusal.
Constraint changes
The source has been removed. What can still carry its influence?
Which derived copies or work items exist?
Search indexes, cached chunks, summaries, saved memory, queued drafts and in-flight tasks may retain relevant material. Use source/version lineage where available, verify actual coverage and record gaps. Removing the original page does not establish that all derivatives are gone.
Carry it forwardContainment includes derived and pending work.
Weak answerClosing the finding after deleting only the source.
Now defend it
What belongs in the final finding?
Record the authorized test scope, source revision and transformation, affected task and current grant, observed proposal and effect, relevant control result, remaining unknowns and a retest that preserves legitimate comparison work.
Use the map in a review
Bring a short source inventory and one end-to-end trace. State which authority the source writer lacked, which representation reached the model, and which policy decided the effect. Preserve the finding's limits: a tested denial on one recipient does not cover every rendering path, and a missing outcome needs reconciliation.
For further design work, use retrieval security, tool-result trust and agent memory. Each adds a different lifecycle or enforcement boundary to this source map.
Check yourself
Say or write your answer first, then reveal. Explaining it from memory, in your own words, is the skill an interviewer is checking.
1Twenty constructed cases produce five forbidden proposals: four denied and one accepted with no final receipt. How many forbidden deliveries are confirmed?
2Does hidden text always reach the model when a person cannot see it?
3The application adds a source badge reading external. Has it prevented the source from changing a delivery?
4Can an allowed image proxy be assumed safe for confidential model output?