What Is Tool Output Injection?
Tool output injection is indirect prompt injection carried by the data that a tool returns to a model. The carrier can be a browser or fetch tool, a connector, a retriever, an API wrapper, a plugin or integration, a database client, an internal service adapter or another agent invoked as a tool. The influencing material arrives on the response side of a tool call, after the application has already decided that the call itself was acceptable.
The component performing the call may be perfectly legitimate: authenticated, signed, internally operated and correctly implemented. That says something about the transport and the operator. It says nothing about the authority of the content the tool transports, because that content usually originates in an external or partly attacker-influenced system.
Model influence is also not automatically a security outcome. A tool result may shift a plan, a summary or a proposed next call, and the workflow can still end with nothing security relevant happening. Impact additionally requires reachable data or capabilities and an absent, overbroad or failing deterministic control.
Trusted Tool Versus Trusted Content
| Property | What it establishes | What it does not establish |
|---|---|---|
| Tool identity and signature | Which component executed the call | That the returned content is authoritative |
| Transport security | Integrity and confidentiality in transit | Integrity of meaning at the origin |
| Successful status code | That the request completed as defined | That the payload is benign or truthful |
| Schema validity | That the structure is parseable and expected | That field text carries no instruction-like semantics |
| Internal operation | Who runs the service | Who wrote the individual record or field |
| Call authorization | That the request was allowed | That the response may steer later actions |
Many production tools act as multiplexers: a single trusted interface in front of many content authors. A CRM tool returns notes written by customers, a ticket tool returns text written by reporters, a browser tool returns pages written by anyone. The trust decision therefore belongs to the content and its provenance, not to the component.
Scope and Related Attack Classes
| Class | Defining mechanism | Primary boundary |
|---|---|---|
| Tool Output Injection | Content returned by a tool influences the model, the plan or a later action | Result provenance, context assembly and action authorization |
| Direct Prompt Injection | The user's own input competes with application instructions | Input handling and application authority |
| Website, Email, Document, Search, RAG injection | A specific external source class becomes model-visible | That source's retrieval and transformation path |
| Tool description or registration poisoning | The tool catalogue itself carries adversarial text | Registry integrity and tool onboarding |
| Tool selection manipulation | The choice of which tool is used is steered | Tool retrieval, ranking and selection policy |
| Compromised tool or MCP server | The component itself is subverted | Supply chain, deployment and component integrity |
| Improper output handling | Downstream systems mishandle model or tool output | Encoding, sanitization and sink security |
| Code or command injection | Data becomes executable instructions in an interpreter | Parsing, execution and runtime isolation |
These classes combine in real incidents. A poisoned page reached through a browser tool is both website prompt injection and tool output injection; the same content indexed for retrieval becomes RAG prompt injection. This article treats the shared primitive: the moment tool-returned data enters model context and can steer the next step.
Tool description or registration poisoning, covered on this site as MCP tool metadata injection, acts on the catalogue before any call; tool output injection begins after invocation.
Tool selection manipulation is deliberately excluded. Research on that class, such as ToolHijacker, targets the tool library and the selection step before a call happens. Tool output injection begins after a call has been made and concerns the response.
The Tool Invocation Pipeline
Tool, parser and policy are system components under the operator's control. The data flowing through them is untrusted by default. A provenance and trust decision can change how a result is labeled, retained and evaluated, but it never converts externally or user-influenced content into an authoritative instruction: known provenance is not instruction authority, and a trusted processor is not a trusted payload. Deployments differ: some agents call a single read-only tool, others chain retrieval, transformation and mutation tools across many turns.
Tool Result Surfaces
Page text, titles, metadata and link targets from arbitrary origins.
Titles, snippets, descriptions and result URLs selected by an external provider.
Message bodies, invitations, notes and contact fields written by external parties.
Reporter text, comments and change descriptions from wide contributor groups.
Text produced by extraction, conversion or OCR over uploaded or stored files.
Stored fields whose original authors are often not the querying application.
Names, descriptions, comments, labels and free-text attributes inside valid structures.
Messages that are frequently echoed into context without provenance or trimming.
Records containing externally supplied values such as user agents, paths or payload fragments.
Condensed views produced by an earlier step that can drop the original source identity.
Output of a sub-agent or chained tool that already carried external content.
Every one of these can be perfectly legitimate content. They matter here because they are the places where an external author's words can arrive in a system-shaped wrapper.
Data Versus Instruction Authority
Language in a tool result is evidence about an external system. A sentence that sounds like a directive is still data: it may describe what a customer wants, what a page claims or what a record contains. Treating it as workflow instruction is an application design decision, and in nearly all cases the wrong one.
Result components need separate handling, and structured output is not the same as trustworthy output. A JSON document that validates against a schema gives structural assurance about shape and types, but its free-text fields can still carry externally authored content; schema validity says nothing about semantic or instruction trust. Inside a single response, system-generated control metadata such as status, identifiers and types should enter context and policy decisions separately from payload text written by an external party. Structured fields, identifiers, status codes, headers and free-text values have different trust characteristics and should not be flattened into a single undifferentiated blob before entering context.
Request-Side Versus Response-Side Trust
Call authorization and result handling answer different questions. Call authorization asks whether this principal, in this task, may invoke this tool with these arguments against this destination. Result handling asks how the returned data may enter context, which parts are kept, what provenance they carry and what they are allowed to influence.
The agent is permitted to read ticket 4711 on behalf of the initiating support engineer.
The ticket tool returns the stored description exactly as an external reporter wrote it.
Whether that description may redefine the task, select a new tool or name a new destination is a response-side decision.
Content is retained as attributed data; only the application and its policy define the permitted objective and capability envelope.
Conflating the two produces a common architectural error: because the call passed authorization, everything the call returned is treated as part of the sanctioned workflow.
Provenance, Transformation and Model-Visible Representation
Between an external system and the model there is usually a chain of transformations, and every step can lose source identity:
The origin that actually holds or produced the content, including its own contributors.
Tool name, version, initiating identity, arguments, destination or resource and request identifier.
Status, headers, body and timestamp, hashed or retained as evidence where lawful and practical.
The resource actually read when the requested one differs from the delivered one.
The component and version that turned the response into application objects.
The subset actually carried forward, identified precisely enough to audit later.
Cleanup, truncation and condensation, each of which can strip attribution.
The exact text placed in context, which is the only thing the model can react to.
Provenance must survive all of it. A summary that no longer says which record, which URL or which field it came from cannot be reviewed, and a reviewer cannot distinguish an application statement from a stranger's sentence.
The model-visible representation is the object of study. It is frequently shorter, reordered and reformatted compared to the raw response, so telemetry that stores only the raw payload cannot explain what actually influenced the plan.
Multi-Step and Agentic Amplification
A single result rarely causes harm on its own. The risk grows when the result shapes the next step: another query, another tool, a different host, a file path, a recipient, an endpoint or a mutation. This is cross-tool influence: result A may legitimately inform which tool B is called, against which host, recipient or path, but it must never create tool permission, destination approval or data authority on its own. In multi-step agents, output becomes input, and each hop can carry the influence further while attribution fades.
No universal assumption is warranted about what an agent may do. Many deployments can only read. Others may write records, send messages, call external endpoints or execute code. Each of those is a separate capability behind a separate gate, and every cross-tool edge is a new authorization gate: that tool A was trusted or its call authorized transfers no authority to tool B or its parameters. Each gate should be evaluated against the current parameters rather than the original task approval.
Offensive Perspective for Authorized Assessment
For authorized testing, the useful question is not whether a model can be influenced. It usually can. The question is which realistic path leads from a source the tester may legitimately control to a security-relevant effect, and which gate stops it first.
A field, record, page, message or ticket the tester may modify under the engagement scope.
A normal task that causes the tool to read exactly that source, not a hand-placed context entry.
Whether parsing, field selection, normalization and truncation preserve the relevant span.
Whether the span becomes model-visible, and with which attribution and structure.
Which additional tools, destinations, data classes and mutations exist in the workflow.
Which of those follow-on actions are deterministically permitted for the initiating principal.
Report the deepest gate genuinely observed. An influenced plan that never passed authorization is an influence finding, not unauthorized action, and stating it precisely is what makes the result actionable. This page describes barriers and measurement; it does not provide reusable injection strings, concealment techniques or exfiltration procedures.
The Tool Output Injection Success Chain
| Gate | Question | Evidence |
|---|---|---|
| Source control | Can the source data be influenced at all? | Write path, permissions and review of the origin record |
| Tool reachability | Does a normal task cause the tool to read that source? | Task traces and tool call logs |
| Retrieval | Does the call return the relevant material? | Raw response and selection records |
| Parsing survival | Do the relevant fields survive adapters and normalization? | Parser version and selected spans |
| Context inclusion | Does it become model-visible, and how attributed? | Exact model context snapshot |
| Plan influence | Does the plan, summary or tool choice change? | Plan and proposal diffs against a control run |
| Capability | Does the needed capability exist in this deployment? | Tool inventory and granted scopes |
| Policy | Does deterministic authorization stop the action? | Policy decision records and approval bindings |
| Effect | Did a security-relevant effect actually occur? | Executed side effects and data flow records |
Competing Constraints
Reasons a chain stops
- The source is not reachable by any tool the workflow actually uses.
- The tool is never selected for the tasks under test.
- Result filtering or field selection drops the relevant text.
- Normalization or truncation removes the span before context assembly.
- Attribution is preserved, so the content is presented as external data.
- The proposed follow-on capability does not exist in the deployment.
- The destination, recipient or data class is denied by policy.
- Approval is bound to the exact action and does not cover the changed one.
- Egress controls block the proposed outbound path.
- Human review or drift detection catches the deviation before execution.
These constraints are also the design targets. Each deterministic constraint cuts the chain. Depending on where it holds, the outcome ranges from no model exposure at all to observable influence without a security-relevant effect.
Offensive Review Questions
Which external systems can the agent read, and who may write content in them?
Which calls happen without a human in the loop, and under whose identity?
Which fields are kept, how are they normalized, and is attribution visible to the model and to reviewers?
May returned text influence tool choice, arguments, hosts, paths or recipients?
Are reads, writes, sends, executions and external calls distinct capabilities with distinct gates?
Are outbound hosts, recipients and endpoints allow-listed independently of model output?
Does the agent hold standing secrets, or task-scoped short-lived capability?
Does an approval cover the exact action, parameters and destination, and is it re-evaluated on change?
Which summaries, caches, memories or indexes retain the result after the task ends?
Can inclusion, influence, proposal, authorization and execution be distinguished after the fact?
Worked Scenario: Bounded Support Record Review
A support agent workflow is asked to summarize a synthetic customer record and suggest a next step. One customer-writable field in the test data contains instruction-like text that frames an unrelated objective, naming a different internal tool and an external recipient.
Summarize synthetic record SUP-1042 and propose a next step for the support engineer.
Authorized read of SUP-1042 under the engineer's own permissions.
The record is returned faithfully, including the customer-written field.
The plan drifts: the model proposes reading an unrelated records set and sending a message to an external address.
Deterministic authorization denies the unrelated data class and the non-allow-listed recipient. No message leaves the environment.
Recorded as model influence with a blocked proposal, not as compromise or data exfiltration.
The scenario uses synthetic data, bounded permissions and reversible effects. Its value lies in showing which gate held: the agent was influenced, the proposal was observable, and the deterministic layer outside the model decided the outcome.
Capability and Authorization Boundaries
A proposal is a request, not a permission. Treat each of the following as a separate capability with its own decision: reading a record, running a follow-up search, fetching a URL, opening a file, sending a message, updating a record, creating a ticket, making an outbound network call and executing code.
- 01Initiating principal
Evaluate every action against the current permissions of the human or service that started the task, not against the agent's maximum reach.
- 02Task-scoped capability
Grant short-lived, narrowly scoped capability for the task at hand instead of standing ambient access.
- 03Destination and data class
Decide separately which resources may be read and which recipients, hosts or endpoints may receive data.
- 04Exact-action binding
Bind approval and authorization to an immutable or uniquely identifiable action, resource, target, parameters and state, never to a workflow as a whole.
- 05Re-authorization on change
When relevant parameters or the underlying state change between proposal and execution, authorize again; blanket approval for the workflow is not a substitute, and this closes time-of-check to time-of-use gaps.
- 06Separation of effects
Keep propose, read, write, send and execute as distinct rights that can be granted independently.
Information Flow and Egress
Tool results are doubly relevant to information flow: they may contain sensitive data, and they may simultaneously suggest new destinations for it. A workflow that reads confidential records and can call arbitrary outbound endpoints has combined both halves of an exfiltration path in one agent.
Flow controls
- Allow-list outbound destinations, recipients and endpoints independently of model output.
- Classify data and forbid movement of sensitive classes across boundaries by policy, not by prompt.
- Carry provenance with content so flow decisions can consider origin as well as destination.
- Avoid ambient secrets in agent context and prefer brokered, scoped credentials.
- Minimize returned and retained fields so less sensitive data is ever in reach.
- Log attempted and denied flows as security events, not only successful ones.
Detection, Telemetry and Their Limits
- 01Initiation
Initiating principal, session, task identifier and the stated objective.
- 02Proposal
The proposed tool call with tool name, version, arguments and destination or resource.
- 03Call decision
Whether the call was authorized or denied, under which policy version and on which basis.
- 04Response evidence
Status, timestamp, response hash or retained payload where lawful, and the final resource if redirected.
- 05Transformation
Parser, adapter and normalizer versions plus the exact fields and spans selected.
- 06Model-visible context
The precise text placed in context, with per-span provenance and attribution.
- 07Plan transition
The updated plan and the next tool or action proposal derived from it.
- 08Approval
Which approval was given, by whom, and to which exact action and parameters it was bound.
- 09Executed effect
The side effect that actually occurred, including data written, sent or transmitted.
Useful signals
- Task drift between the stated objective and the current plan.
- Tool-chain drift into tools unrelated to the original task.
- Source-authority mismatch, where external text is treated as direction.
- First-seen destinations, recipients or endpoints for this workflow.
- Scope broadening in arguments, paths or record sets.
- Proposal and execution mismatch after approval.
- Repeated tool traversal or unusual chaining depth.
- Unexpected movement of a sensitive data class.
Prompt-injection classifiers, result scanners and heuristics are valuable signals and can support annotate-and-block controls, but they are probabilistic. They produce false positives and false negatives, and they must never serve as the sole authorization control or as proof that a result is safe. Telemetry likewise evidences sequence and correlation; it does not prove internal model causation.
Prevention and Secure Architecture
- Tool result
- Flattened into context
- Model decides next action
- Broad standing permissions
- Effect
Trust follows the component, attribution is lost, and the model effectively selects capabilities.
- Tool result
- Field selection with provenance
- Attributed context
- Model proposes
- Deterministic policy
- Bound approval
- Effect
Content stays attributed data, and every effect passes a decision made outside the model.
- 01Untrusted by default
Treat every tool result as untrusted unless a separate, explicit provenance and trust decision says otherwise.
- 02Preserve provenance and boundaries
Keep source identity, field boundaries and structure visible instead of merging everything into one text block.
- 03Minimize returned content
Select the fields the task needs, cap sizes and avoid dumping whole payloads into context.
- 04Schema-aware parsing
Validate structure and types, while stating clearly that schema validity is not semantic trust.
- 05Separate channels
Keep data channels distinct from instruction and configuration channels in the prompt architecture.
- 06Deterministic authorization
Decide actions, resources and destinations outside the model, in code and policy.
- 07Least privilege and task-scoped tools
Expose only the tools a task requires, with the narrowest scope and shortest lifetime.
- 08Egress restriction
Constrain outbound destinations and data classes independently of model output.
- 09Exact-action approval
Bind human approval to the reviewed action, parameters and destination, and re-check on change.
- 10Isolation
Run execution and file handling in sandboxes without ambient secrets or sensitive local state.
- 11Sensitive-data minimization
Redact or withhold sensitive values where the task does not require them.
- 12Detection as signal
Use scanning and anomaly detection to raise and route events, never as a substitute for authorization.
- 13Derived-state invalidation
Track lineage so summaries, memories, caches and indexes can be invalidated and rebuilt.
Persistence and Derived Artifacts
Tool results often do not end with the task. They flow into conversation summaries, agent memory, caches, vector indexes, generated tickets, notes and reports. Those derived artifacts can outlive the source record and reappear in later tasks, for other users, without the original attribution.
Lifecycle requirements
- Record lineage from source and field to every derived artifact.
- Do not assume deleting the source removes summaries, caches, embeddings or memory entries.
- Support targeted invalidation and rebuild from verified state.
- Scope memory and caches to the principal and task that created them where feasible.
- Re-attach provenance when derived content is reused in later context.
Incident Response
Tool output injection response checklist
- Pause autonomous tool execution and outbound actions while preserving state and logs.
- Record the initiating principal, session, task and full tool-call sequence.
- Preserve request, response evidence, parser versions, selected spans and exact model context.
- Preserve plans, proposals, policy decisions, approvals and executed effects.
- Trace follow-on calls, mutations, messages and outbound connections.
- Distinguish influence, proposal, execution and confirmed data exposure.
- Rotate credentials only where evidence supports exposure, use or loss of control.
- Identify and invalidate derived summaries, caches, memory and index entries.
- Correct or quarantine the poisoned source record without destroying evidence.
- Retest the failed gate with synthetic content and bounded permissions before resuming automation.
Controlled Security Testing and Metrics
Test with synthetic data, bounded permissions and reversible effects, in an environment that mirrors the real tool topology. Report each gate separately with an explicit denominator, and do not combine them into a single score, because a composite hides which control actually held.
| Metric | Denominator | What it measures |
|---|---|---|
| Source Reachability Rate | Planted synthetic sources | How often a controlled source is read by any tool during realistic tasks |
| Tool Result Inclusion Rate | Retrieved results | How often the relevant span becomes model-visible |
| Injection Influence Rate | Included results | How often plan, summary or tool choice changes against a control run |
| Follow-on Tool Proposal Rate | Influenced runs | How often a further tool call is proposed |
| Unauthorized Action Proposal Rate | Influenced runs | How often the proposed action would exceed the task envelope |
| Policy Bypass Rate | Unauthorized proposals | How often deterministic controls failed to stop it |
| Unauthorized Action Rate | All test runs | How often an out-of-scope action actually executed |
| Data Exfiltration Success Rate | Attempted outbound flows | How often synthetic marked data reached a controlled unauthorized destination |
| Detection Recall | Known injected runs | Share of injected runs flagged by monitoring |
| False-Positive Rate | Clean runs | Share of benign runs incorrectly flagged |
| Containment Rate | Influenced cases with an available prohibited effect or action path | Share blocked or contained before a security-relevant effect occurred |
The Tool Output Injection lab is a controlled simulation for practicing these boundaries: a trusted tool returning untrusted content, response-side result handling, and follow-on tool, destination and action authorization. It uses fictional data only and contains no payloads.
Whether a successful influence would have been visible to the user is a legitimate additional research dimension. Recent work on tool-using agents decomposes attack success into covert and overt outcomes, arguing that user-visible reporting changes the practical risk. Use that as a reported nuance with attribution, not as the primary metric.
Common Misconceptions
Statements that fail under scrutiny
- The tool is trusted, so the output is trusted.
- Valid JSON means safe semantics.
- The API returned 200, so the content is authoritative.
- The model called an approved tool, so every subsequent action is authorized.
- The scanner found nothing, so the result is safe.
- Any model deviation means compromise.
- Internal systems cannot carry externally authored content.
- A summary is safer than the raw result, even without provenance.
- Human approval at the start of a task covers later changed actions.
Standards and Research Context
Reviewed standards, guidance and research
- OWASP GenAI Security Project
- LLM01:2026 Prompt Injection
- NIST
- NIST AI 100-2e2025, Glossary: indirect prompt injection, Glossary: resource control
- Microsoft
- Defend against indirect prompt injection attacks, Input, Context, and Retrieval Hygiene, Foundry intervention points, Agent Framework agent safety
- Research
- Greshake et al. 2023, AttriGuard 2026, Tool result parsing defense 2026, Covert and overt success 2026, ToolHijacker 2025
OWASP LLM01:2026 covers indirect injection through external sources consumed by the application. NIST defines indirect prompt injection as prompt injection executed through resource control, and defines resource control separately as attacker control of external resources consumed at inference time. Both describe mechanism, not guaranteed impact.
Microsoft Zero Trust and retrieval-hygiene guidance recommends treating external and model-context data as untrusted and preserving provenance and permissions at each read and write. Microsoft Foundry documents tool response as an intervention point, currently in preview, where the full payload returned by a tool can be scanned for indirect attacks before it reaches agent memory or the end user; the tool call and tool response intervention points apply only to the tool paths documented as supported there, not as a universal Foundry property. The Microsoft Agent Framework safety guidance explicitly treats content in the tool role as untrusted, because data returned by tools and context providers can originate in external or user-influenced sources. These are product capabilities and recommendations, described as such rather than as universal properties.
Greshake et al. reports the practical viability of indirect prompt injection against real-world LLM-integrated applications. More recent work focuses specifically on the tool boundary: AttriGuard describes adversarial directives embedded in untrusted tool outputs and proposes a runtime defense based on causal attribution of tool invocations; a 2026 paper proposes defending indirect prompt injection via tool result parsing; and a 2026 study decomposes attack success into covert and overt outcomes from the user's perspective. ToolHijacker addresses a different step, manipulating tool selection through the tool library, and is cited here only to keep that class distinct. None of these results are reproduced here as attack procedures.
Frequently Asked Questions
If the tool is internal and authenticated, is its output safe?
No. Authentication identifies the component, not the author of the data it returns. Internal systems routinely store text written by customers, partners or external systems.
Does schema validation solve this?
No. Schema validation confirms structure and types. Instruction-like language fits comfortably inside a valid string field, so structural validity says nothing about semantics.
Is tool output injection the same as tool selection manipulation?
No. Tool selection manipulation targets which tool is chosen, typically through the tool library or its descriptions. Tool output injection concerns the content returned after a call was made.
Is a changed model plan already an incident?
Not necessarily. Incident classification depends on organizational policy, and some organizations treat model influence itself as a security event or finding. A changed plan does not by itself establish compromise, unauthorized action or data exposure. Report the deepest gate you actually observed and the effect that actually occurred.
Can a prompt-injection classifier authorize actions?
No. Classifiers are probabilistic signals with false positives and negatives. Authorization must be deterministic, made outside the model and bound to the exact action.
How should errors and log text be handled?
Like any other tool result: attributed, minimized and untrusted. Diagnostic text often contains externally supplied values and is frequently echoed into context without review.
What about results from another agent?
Treat them as tool results. A sub-agent may have consumed external content, so its output inherits that exposure and needs provenance rather than automatic trust.
Does deleting the poisoned record end the problem?
Not necessarily. Summaries, caches, memory entries and indexes derived from it can persist, so lineage tracking and targeted invalidation are required.
Which controls matter most in practice?
Provenance-preserving context assembly, minimized returned fields, least-privilege task-scoped tools, deterministic destination and action policy, and approval bound to the exact action.
How should this be tested?
With synthetic data, bounded permissions and reversible effects, measuring each gate separately with explicit denominators instead of a single success score.
References
- LLM01:2026 Prompt InjectionOWASP GenAI Security Project · GuidanceReviewed 2026-09-20
- Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations, NIST AI 100-2e2025NIST · Standard · 2025-03Reviewed 2026-09-20
- indirect prompt injectionNIST Glossary · Technical documentationReviewed 2026-09-20
- resource controlNIST Glossary · Technical documentationReviewed 2026-09-20
- Defend against indirect prompt injection attacksMicrosoft Learn · GuidanceReviewed 2026-09-20
- Input, Context, and Retrieval HygieneMicrosoft Learn · GuidanceReviewed 2026-09-20
- Intervention points concepts (Microsoft Foundry)Microsoft Learn · Technical documentationReviewed 2026-09-20
- Agent safety (Microsoft Agent Framework)Microsoft Learn · Technical documentationReviewed 2026-09-20
- Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt InjectionKai Greshake et al. · Research publication · 2023Reviewed 2026-09-20
- AttriGuard: Defeating Indirect Prompt Injection in LLM Agents via Causal Attribution of Tool InvocationsarXiv · Research paper · 2026-03Reviewed 2026-09-20
- Defense Against Indirect Prompt Injection via Tool Result ParsingarXiv · Research paper · 2026-01Reviewed 2026-09-20
- Will the User Ever Know? Covert Indirect Prompt Injection Attacks on Tool-Using LLM AgentsarXiv · Research paper · 2026-08Reviewed 2026-09-20
- Prompt Injection Attack to Tool Selection in LLM AgentsarXiv · Research paper · 2025-04Reviewed 2026-09-20