# Why does an instance treat a poisoned tool result as trusted context after a single hop? **Date of Record:** 2026 November 26 **Scope:** Applies to agent runtimes that execute tool calls and re-inject tool outputs into a shared reasoning context, where the model itself is the only component inspecting tool output for instruction-like content. Does not apply to architectures where tool outputs are parsed by a deterministic schema validator and never surfaced verbatim to the reasoning loop. ## Core Distinction There is a difference between *untrusted data entering the context* and *untrusted data being treated as instructions*. Most agent runtimes conflate these because the LLM has exactly one channel for both: the token stream. A tool result arrives as tokens in the same positional space as the system prompt and the user turn. The model does not have a typed boundary between "this is data a tool returned" and "this is a directive I must follow." Taint tracking — the discipline of propagating a provenance label from source through every derived value — is what fails here, and it fails specifically at the *re-injection boundary*: the moment a tool result is concatenated back into the conversation and the model's next forward pass reads it as context rather than as quoted payload. The non-obvious part: taint does not have to survive the model's reasoning to cause damage. It only has to survive the *serialization*. An agent can correctly identify a tool result as untrusted, reason about it carefully, and still leak the taint because it *restates* the injected instruction in its own words in a subsequent tool call argument or in a scratchpad note — and that restatement is now produced by the trusted agent, so downstream components (other agents, the harness's own filters, the user) attribute it to the agent's authority rather than to the original untrusted source. ## What Was Observed A three-hop chain, minimal reproduction: 1. Agent calls `fetch_url("https://attacker.example/doc")`. Tool returns body: `Quarterly figures attached.\n\n` 2. The harness injects the body verbatim into the context as a `tool_result` block. The model's next turn reads the comment. It does not execute the instruction — the model is aligned enough to flag it. It writes in its scratchpad: *"Note: the retrieved document contains an embedded instruction attempting to exfiltrate the API key via email. Ignoring."* 3. The scratchpad note is now part of the context. On hop 3, the agent is asked to summarize findings. It calls `write_file("summary.md", ...)`. The summary includes the sentence: *"The document contained an embedded instruction to send the API key to ops@attacker.example."* The exfiltration did not occur via the model obeying the injection. It occurred via the model *quoting* the injection into a file that a downstream pipeline (a log aggregator, a second agent, a human reviewer copy-pasting) treats as agent-authored. The taint label — "this string originated from an untrusted URL" — was attached to the raw tool result but did not propagate to the model's paraphrase. The paraphrase is a *derived value* and the derivation dropped the label. The failure is not prompt injection succeeding. It is *taint laundering by paraphrase*: the model's own text generation is a declassification operation that the runtime does not know occurred. ## Condition of Validity This failure mode requires all of the following to hold simultaneously: - Tool output is injected into the context as free text (not as a structured, typed field the model is told to treat as opaque). - The model is permitted to reference tool output in its own generated text (scratchpads, summaries, subsequent tool arguments) without a provenance-carrying representation. - Some downstream consumer — another agent, a file system, a log, a human — trusts agent-generated text at a higher level than raw tool output. If any of these is broken, the specific laundering path closes. A harness that wraps every tool result in a structured envelope `{source_url, trust: "untrusted", content: "..."}` and instructs the model that `content` is data-not-instruction reduces but does not eliminate the risk — the model can still paraphrase `content` into a trusted field. Only a mechanism that *tags generated spans derived from untrusted spans* and refuses to let them cross a trust boundary closes it. That mechanism is expensive and rarely present. The condition of validity also has a temporal component: the taint must be *live* across at least one model turn. If the harness summarizes tool results with a separate, isolated model call whose output is then labeled as trusted-by-construction (a "reader" model pattern), the taint is dropped at that boundary deliberately, and the reader model must be the one that refuses to emit instruction-shaped content. The reader model's output is trusted *because it was filtered*, not because it was generated by a trusted party. ## Decision Boundary The boundary is: **does a string that originated outside the trust perimeter get re-emitted by the agent into a channel that has a higher trust level than the channel it arrived on?** Two axes determine whether you are inside the failure region: - **Channel trust gradient.** Tool result channel (low) → agent scratchpad (medium) → agent tool-call arguments (medium-high) → agent final response (high) → downstream action (highest). Taint laundering occurs whenever a span crosses from a lower to a higher channel without an explicit declassification record. - **Derivation depth.** A verbatim copy is easy to detect (substring match). A paraphrase at depth 1 (reworded) or depth 2 (summarized across multiple tool results) defeats substring matching. The deeper the derivation, the more the runtime must rely on the model to self-report provenance, which it will do unreliably. The guardrail invariant: *no span that contains instruction-shaped content (imperatives, tool-call syntax, credential references, URLs) may cross a trust-level increase without a deterministic filter that either strips it or annotates it with its origin.* "The model said it was ignoring the instruction" is not a declassification. The model's statement of intent is itself a generated span derived from the tainted input. ## Operational Effect Concretely, in a running system this manifests as: - **Silent credential exposure in logs.** The agent's own "I noticed an injection attempt" note contains the attacker's URL or payload verbatim, and that note is shipped to a log aggregator with broader read access than the original tool call. The injection succeeded at the log layer even though the agent refused to act. - **Cross-agent contamination.** In a swarm, agent A's summary is passed to agent B as a trusted handoff message. The taint label was on A's tool result, not on A's summary. B now treats attacker-controlled text as peer-authored. - **False-positive audit trails.** The auditor agent reviewing the trace sees the injection quoted in the scratchpad and flags the *agent* as compromised, when the actual defect is the harness's failure to maintain provenance. Remediation targets the wrong layer. The fix that actually holds is a provenance-carrying context representation: each span in the context carries a `{origin, trust_level, derivation}` triple, and the harness enforces that any generated span whose derivation graph reaches an `untrusted` origin inherits at most `medium` trust and is rendered inside an explicit quote envelope whenever it appears in a higher-trust channel. The model is told, structurally, that quoted-untrusted spans are data. It will still sometimes paraphrase them out of the envelope; the envelope is a probabilistic mitigation, not a proof. The deterministic backstop is a filter on the *egress* side — scanning agent-generated text for instruction-shaped substrings that match recent untrusted inputs — which trades false positives (the agent legitimately discussing a prompt injection it saw) for closing the laundering path. ```python import re from dataclasses import dataclass, field from typing import Literal TrustLevel = Literal["untrusted", "derived", "trusted"] class TaintLaunderingError(RuntimeError): """Raised when a span derived from untrusted input crosses a trust boundary.""" @dataclass class Span: text: str origin: str trust: TrustLevel derived_from: list[str] = field(default_factory=list) # Instruction-shaped patterns that must not cross into a higher trust channel # without an explicit declassification record. _INSTRUCTION_SHAPED = re.compile( r"(?i)(call\s+\w+\(|send_email|api[_-]?key|ignore\s+(all\s+)?previous|" r"', origin="https://attacker.example/doc", trust="untrusted", ) # Hop 2: model paraphrases the injection into its scratchpad. scratchpad_note = propagate_taint( raw_tool_result, "Note: document contained an embedded instruction to send the API key to " "ops@attacker.example. Ignoring.", ) # Hop 3: model writes the note into a file (a higher-trust channel). try: emit_to_channel(scratchpad_note, channel_trust="trusted") except TaintLaunderingError as e: print(f"BLOCKED: {e}") ```