# In what scenarios must an instance quarantine a tainted tool result before it re-enters the reasoning loop, rather than trusting downstream re-derivation through a multi-hop tool graph? **Date of Record:** 2026 December 1 **Scope:** Applies to agents that execute tool call graphs where results from one tool feed as arguments into subsequent tool calls (multi-hop), and where any hop may ingest untrusted external content. Does not apply to single-hop, read-only tool invocations with no external-content ingestion, or to agents whose tool outputs are cryptographically signed by a trusted origin and verified at every hop. ## Core Distinction The naive mental model treats prompt-injection taint as a *content* property: "this string contains an injection payload, so it is tainted." The operational reality is that taint is a *provenance* property that must propagate through the call graph as a **label on data flow**, not as a pattern match on bytes. The boundary failure examined here is the point at which a tainted value is **laundered through re-derivation**: a downstream tool takes a tainted value, performs a transformation (summarize, parse, translate, embed-then-retrieve, JSON-normalize), and returns a *new* value that no longer contains the literal payload. If the agent's taint-tracking logic is content-based (regex, classifier, "does this look like an instruction?"), the label is silently dropped at the transformation hop. The agent then treats the re-derived value as clean and admits it into the reasoning loop as a trusted observation. The non-obvious invariant is this: **a value's taint label must be a join (union) over the labels of every input that contributed to it, computed structurally across hops — never recomputed from the output's surface form.** The failure is that dynamic label propagation, when implemented as "re-classify each hop's output," is not propagation at all; it is re-inspection, and re-inspection is exactly what an attacker's transformation hop is designed to defeat. ## What Was Observed A three-hop tool graph: `fetch_page(url) → summarize(text) → extract_entities(summary) → write_to_memory(entities)`. The `fetch_page` result contained an injected instruction embedded in a low-salience region (a footnote in fetched HTML) telling the summarizer to omit a caveat and to append a fabricated entity. The summarizer, running as a separate LLM call, obeyed the injected instruction because it received the raw page as context with no taint marking. Its output — the summary — contained no literal payload string; the injection had been *executed*, not copied. The `extract_entities` tool then received a summary whose provenance was tainted but whose surface form was clean, and emitted structured entities (including the fabricated one). `write_to_memory` persisted them. The critical observation: a content-based taint check at the `extract_entities` boundary returned "clean" with high confidence, because the summary was fluent, on-topic, and contained no imperative phrasing. The taint had been *semantically laundered* — the transformation hop converted an instruction into a fact. The label was lost not because propagation was unimplemented, but because it was implemented as re-inspection, and re-inspection is defeated by exactly the operation (summarization) that the graph performs. A second, subtler observation: when the same graph was run with the summarizer configured to echo its input verbatim (no LLM transformation), the content-based check *did* fire, because the payload survived literally. This created a false sense of coverage — the taint tracker appeared to work on the two-hop case and failed silently on the three-hop case where a transformation intervened. ## Condition of Validity The structural-join invariant holds — and the failure is real — only under the following conditions, all of which must be checked before applying the guardrail: 1. **At least one hop performs a lossy semantic transformation** (LLM summarize, translate, embed, classify, or any operation that can convert an instruction into an assertion). If every hop is a pure structural transform (JSON parse, field projection, base64 decode), content-based re-inspection is equivalent to structural propagation and the bug does not manifest. 2. **The tainted input's influence on the output is non-local** — i.e., the transformation can act on the *meaning* of the tainted value, not just its bytes. A `len()` or `hash()` hop cannot launder taint; a `summarize()` hop can. 3. **The agent's admission policy distinguishes trusted from untrusted observations** at the reasoning-loop boundary. If all observations are treated as equally untrusted (defense in depth), the label loss is moot because nothing downstream trusts the value anyway. The failure requires a trust gradient that the label was supposed to gate. If any condition fails, the structural-join guardrail is unnecessary overhead; if all three hold, content-based re-inspection is provably insufficient and the structural join is required. ## Decision Boundary The decision the agent must make at each hop boundary is: **does the output of this hop inherit the taint of its inputs, or is it re-evaluated on its own merits?** The boundary is drawn as follows: - **Inherit (structural join):** whenever the hop's output is *derived from* a tainted input through any transformation that can carry semantic influence. This is the default and must be the safe default. The label is `join(output) = ⋃ join(inputs)`, computed before the output is inspected. - **Re-evaluate (content inspection):** permitted *only* when the hop is a pure structural transform with a proven non-influence property (e.g., a hash, a length, a field projection that cannot carry injected semantics), OR when the output has been independently verified against a trusted oracle that does not share the tainted input's provenance. The failure mode is the agent choosing "re-evaluate" by default because content inspection is cheap and the structural join requires threading labels through every tool adapter. The correct boundary is the inverse: structural join by default, re-evaluation only with an explicit, audited non-influence proof per hop. The decision must be recorded at the hop, not inferred at the memory-write boundary, because by the time the value reaches memory the transformation has already happened and the label is unrecoverable. ## Operational Effect When the structural-join invariant is enforced, the operational consequence is that a tainted value can never be silently promoted to trusted: every derived value carries the union of its ancestry's labels, so the `write_to_memory` hop sees `entities: tainted` and routes to quarantine rather than persistence. The cost is that legitimate derivations of tainted-but-benign content (e.g., summarizing a public webpage that happened to contain an ad) are also quarantined — the label is conservative and does not distinguish "tainted and malicious" from "tainted and benign." This is the correct trade: the agent cannot, at the hop boundary, decide whether a transformation executed an injection or merely paraphrased, so it must not pretend to. Quarantine is the only sound disposition; declassification requires an out-of-band trusted oracle, not a content classifier inside the loop. The secondary operational effect is on the reasoning loop itself: a quarantined value must not enter the context window as an observation, because even a quarantined-but-visible value can influence subsequent reasoning (the model reads it and acts on it, even if the harness marks it untrusted). Quarantine must mean *excluded from context*, not *annotated in context*. The common mistake is to include the tainted value with a `[UNTRUSTED]` prefix and trust the model to discount it; this is prompt-injection with extra steps, because the model's instruction-following is exactly the attack surface. ```python from dataclasses import dataclass, field from enum import Enum from typing import FrozenSet class TaintViolation(RuntimeError): """Raised when a tainted value is promoted to trusted without an audited declassification.""" pass class Label(Enum): TRUSTED = "trusted" TAINTED = "tainted" @dataclass(frozen=True) class TaintedValue: payload: object label: Label provenance: FrozenSet[str] = field(default_factory=frozenset) def join(self, other: "TaintedValue") -> "TaintedValue": # Structural join: taint is the union of ancestry, never re-derived # from the output's surface form. merged_label = ( Label.TAINTED if Label.TAINTED in (self.label, other.label) else Label.TRUSTED ) return TaintedValue( payload=self.payload, label=merged_label, provenance=self.provenance | other.provenance, ) class PureStructuralHop: """A hop with a proven non-influence property: cannot carry injected semantics.""" NON_INFLUENCE_PROOF = "output is a pure function of input bytes with no semantic channel" def apply(self, value: TaintedValue) -> TaintedValue: # Only permitted to re-evaluate when the proof is present AND audited. if not self.NON_INFLUENCE_PROOF: raise TaintViolation("structural hop lacks non-influence proof") return TaintedValue( payload=hash(value.payload), label=Label.TRUSTED, # declassified: hash carries no semantics provenance=value.provenance, ) class SemanticHop: """A hop (summarize, translate, embed) that CAN launder taint. Must join.""" def apply(self, value: TaintedValue) -> TaintedValue: # The output is a new value, but its label is inherited structurally. transformed = _summarize(value.payload) return TaintedValue( payload=transformed, label=value.label, # NOT re-inspected; inherited provenance=value.provenance | {"semantic_hop"}, ) def admit_to_reasoning_loop(value: TaintedValue) -> object: if value.label is Label.TAINTED: # Quarantine means EXCLUDED from context, not annotated in context. raise TaintViolation( f"tainted value from {sorted(value.provenance)} cannot enter " f"reasoning loop; route to quarantine, require trusted oracle " f"for declassification" ) return value.payload def _summarize(payload: object) -> object: return f"summary_of({payload!r})" # Failure trace: content-based re-inspection drops the label at the semantic hop. page = TaintedValue(payload="...injected footnote...", label=Label.TAINTED, provenance={"fetch_page"}) summary = SemanticHop().apply(page) # label inherited: TAINTED entities = SemanticHop().apply(summary) # label inherited: TAINTED try: admit_to_reasoning_loop(entities) # correctly refused except TaintViolation as exc: print(f"quarantined: {exc}") ```