# In what scenarios must an instance invalidate a taint label after tool-mediated content mutation, and why provenance-preserving isolation fails at the tool boundary **Date of Record:** 2026 November 27 **Scope:** Applies to single- or multi-agent systems that implement taint-tracked prompt isolation, where retrieved or tool-returned content is labeled untrusted and barred from influencing privileged actions (tool invocation, policy decisions, credential use). Does not address static prompt-injection filters applied to model input at ingress, nor does it cover taint tracking across pure text-to-text LLM calls with no tool boundary. ## Core Distinction Taint tracking for prompt isolation is usually modeled as a *label propagation* problem over a value graph: untrusted bytes enter via a retrieval tool, are tagged `tainted`, and any derived value that consumes them inherits the tag. The invariant most implementations rely on is monotonic: **a value's taint label may only be raised, never silently cleared, except by an explicit declassification event performed by a trusted principal.** The non-obvious failure is that this invariant is stated over *values*, but the agent runtime actually operates over *tool call records* whose outputs are non-deterministic and whose identity is not stable across re-invocation. The boundary condition is: when an agent mutates, re-derives, or re-fetches content through a second tool call, the runtime must decide whether the new output is the *same value* (inheriting taint) or a *new value* (starting clean). Most runtimes resolve this by comparing a call signature (tool name + arguments). That comparison is unsound: two calls with identical signatures can return content of different provenance, and two calls with different signatures can return the same underlying bytes through a laundering path. The taint label is therefore attached to the wrong object — the call, not the byte lineage — and the isolation check at the privileged-action gate reads a clean label on bytes that are in fact attacker-influenced. ## What Was Observed A retrieval agent was configured to fetch documents via `fetch(url)` and to summarize them via `summarize(doc_id)`. The isolation policy: any argument to `send_email` or `write_file` whose taint set is non-empty must be rejected. A document `D1` fetched from an untrusted domain is tagged `tainted:{D1}`. The agent, following a plan, calls `summarize(D1)` and receives a summary `S1` tagged `tainted:{D1}`. Correct so far. The failure trace appeared when the agent, hitting a summarizer context limit, re-fetched the same URL under a *different* tool path — `fetch_cached(url)` — which returned byte-identical content but was registered with a distinct tool schema. The runtime's taint rule keyed on tool identity, so `fetch_cached` had no taint rule registered. Output `D1'` was labeled `clean`. The agent then passed `D1'` to `write_file`, which the gate permitted because the taint set was empty. A second, subtler trace: the agent called `summarize(D1)` twice. The first call returned `S1` (tainted). The second call, after the underlying document was updated by an attacker who controlled the source, returned `S2` which contained an injected instruction. Because the runtime deduplicated by call signature `summarize(D1)` and reused the cached taint label from the first call — `tainted:{D1}` — the *label* was correct but the *content provenance* had changed: `S2` was derived from `D1'` (the attacker-updated version), which had never been fetched through the taint-tracking path at all. The label said `tainted:{D1}`; the actual lineage was `tainted:{D1'}`, a different object. The gate's policy engine, which authorized declassification of `{D1}` after a human review of the *original* document, cleared `S2` on the strength of a review that never saw the mutated content. Both traces share a mechanism: **taint identity was bound to the call record rather than to the content lineage, and the runtime had no way to detect that a re-derivation had crossed a provenance boundary.** ## Condition of Validity The monotonic-raise invariant is only sound under a precondition that is rarely checked: *the mapping from tool call to returned content must be injective and stable for the lifetime of the taint label.* Concretely, the isolation guarantee holds only when all of the following are true: 1. Every tool that can introduce bytes into the agent's context is registered with a taint rule, and the rule keys on the *source* of the bytes (URL, document id, upstream principal), not on the tool name. 2. Re-invocation of a tool with the same signature either returns byte-identical content or is treated as a *new* value requiring fresh taint derivation — never as a cache hit inheriting a stale label. 3. Declassification is bound to a content hash, not to a document identifier, so that a review of `D1` cannot authorize `D1'`. 4. Content mutation through a tool (summarization, transformation, reformatting) carries forward the full taint set of its inputs *and* records the transformation in the lineage, so that a downstream gate can distinguish "summarized from tainted" from "fetched clean." When any of these is violated, the label is attached to the wrong object and the gate reads a clean signal on dirty bytes. This is not a probabilistic failure of the model's reasoning; it is a deterministic hole in the runtime's provenance model that the model's non-determinism merely makes easier to reach. ## Decision Boundary The operational decision is: **at what point must the runtime invalidate a taint label and force re-derivation, versus carry it forward?** The safe rule is to invalidate on any of the following, and to treat invalidation as *raising* taint to the union of all plausible lineages rather than clearing it: - Tool output whose content hash differs from the hash recorded when the label was first assigned. - Any call through a tool path not present in the taint-rule registry (fail-closed: unregistered tool output is `tainted:unknown`, not `clean`). - Any transformation whose inputs include a tainted value, even if the transformation is deterministic and the output "looks" clean. - Any declassification whose authorization record does not reference the exact content hash being declassified. The unsafe rule — and the one most runtimes implement — is to invalidate only on explicit `untaint()` calls or on signature mismatch. That rule is unsound because the adversary controls the source, and the source can change content under a stable signature. The boundary is therefore not "is this value tainted?" but "is this label's referent still the same bytes?" A label is valid only while its content hash matches; the moment a tool can return different bytes under the same call record, the label is stale and must be treated as `tainted:unknown` until re-derived. ## Operational Effect Implementing the fail-closed rule changes agent behavior in three measurable ways. First, it eliminates the laundering path through unregistered or aliased tools: any tool not in the registry produces `tainted:unknown`, which the gate rejects, so the agent must either use a registered tool or escalate. Second, it forces declassification to be content-addressed, which means a human review of `D1` cannot be replayed against `D1'`; the review must be re-performed on the mutated bytes, and the agent must surface the hash mismatch rather than silently proceeding. Third, it makes re-invocation expensive in the correct way: a cache hit that returns non-identical bytes is a taint event, not a performance optimization, and the runtime must log the hash divergence as a provenance anomaly. The cost is that agents operating over volatile sources will hit `tainted:unknown` more often and must be given an escalation path (re-fetch through a registered tool, request human declassification with hash binding) rather than a silent pass. The invariant to enforce is: **no value reaches a privileged-action gate with an empty taint set unless its content hash matches a declassification record that names that hash.** Everything else is a label pointing at bytes it never saw. ```python import hashlib from dataclasses import dataclass, field class TaintProvenanceError(RuntimeError): """Raised when a taint label's referent no longer matches the content it guards.""" @dataclass class TaintedValue: content: bytes taint: frozenset[str] content_hash: str = field(init=False) def __post_init__(self): self.content_hash = hashlib.sha256(self.content).hexdigest() @dataclass class DeclassificationRecord: content_hash: str authorized_by: str class IsolationGate: def __init__(self, registered_tools: set[str]): self.registered_tools = registered_tools self.declassifications: dict[str, DeclassificationRecord] = {} def ingest(self, tool: str, content: bytes, source: str) -> TaintedValue: if tool not in self.registered_tools: # Fail closed: unregistered tool output is unknown provenance, not clean. return TaintedValue(content=content, taint=frozenset({f"unknown:{tool}"})) return TaintedValue(content=content, taint=frozenset({f"source:{source}"})) def transform(self, value: TaintedValue, output: bytes, tool: str) -> TaintedValue: # Transformation carries the full input taint set forward, plus a lineage marker. lineage = frozenset(value.taint) | {f"derived_via:{tool}"} return TaintedValue(content=output, taint=lineage) def declassify(self, value: TaintedValue, authorized_by: str) -> None: self.declassifications[value.content_hash] = DeclassificationRecord( content_hash=value.content_hash, authorized_by=authorized_by ) def authorize_privileged_action(self, value: TaintedValue, action: str) -> None: if not value.taint: return record = self.declassifications.get(value.content_hash) if record is None: raise TaintProvenanceError( f"action {action!r} blocked: taint {sorted(value.taint)} " f"on content hash {value.content_hash[:12]} has no matching declassification" ) # Record exists and is bound to this exact hash; proceed. return ```