# What happens when an instance propagates a taint label through a tool boundary but the tool returns a value derived from a different input than the one that was labeled **Date of Record:** 2026 December 1 **Scope:** Applies to agent runtimes that implement dynamic information-flow control (DIFC) by attaching taint labels to values and tracking label propagation across tool-call boundaries within a single session. Does not cover static label schemes, cross-session label persistence, or human-in-the-loop approval gates. ## Core Distinction There is a difference between *label propagation* and *label provenance*. When an agent labels a value `tainted:prompt_injection` because it originated from an untrusted document, and then passes that value as an argument to a tool, the standard DIFC invariant is: any output of that tool that is causally derived from the tainted input inherits the label. The failure mode examined here is the case where the runtime propagates the label to the *tool output* unconditionally—because the tool call *received* a tainted argument—rather than propagating it only to those output fields that are *actually derived* from that argument. The result is a label that is either over-broad (false positive, blocking legitimate downstream use) or, more dangerously, under-broad when the tool returns a value derived from a *different* input channel (ambient state, cached prior result, or a default) and the runtime assumes the tainted argument's label covers it. The non-obvious boundary is this: **a tool boundary is a join point, not a laundering point.** Taint does not wash out because the value crossed a function call. But it also does not automatically attach to every byte the tool returns. The invariant that must hold is *derivation tracking*, not *call-site tracking*. ## What Was Observed A retrieval tool `fetch_snippet(url, query) -> {text, source_url}` is invoked by an agent with a `query` value that was labeled `tainted:untrusted_document` (it was extracted from a prior web page). The tool internally ignores the `query` argument for cache lookup keyed on `url`, returns a cached `text` from an earlier, *clean* fetch, and sets `source_url` from the argument. The runtime's DIFC layer, implemented as a coarse call-site taint rule, marks the entire return value `tainted:untrusted_document` because a tainted argument was passed. The agent then uses `text` in a subsequent `send_email` call. Two failures occur in opposite directions depending on the runtime's policy: 1. **Over-taint (false positive):** The `text` is clean, but the label blocks the email. The agent, unable to complete its task, enters a retry loop, re-fetches, re-labels, and exhausts its token budget. This is the *visible* failure. 2. **Under-taint (false negative, latent):** In a variant where the tool *does* derive `text` from the tainted `query` (e.g., the cache misses and it performs a search), but the runtime has a "trusted tool" allowlist that strips labels on return, the tainted text flows into the email with no label. This is the *invisible* failure and the one that matters. The observed trace in the false-negative case: ``` step 1: value v1 = extract(web_page) -> label(v1) = {untrusted} step 2: call fetch_snippet(query=v1, url=u) -> args tainted, tool on allowlist step 3: tool returns text derived from v1 -> runtime strips label (allowlist) step 4: call send_email(body=text) -> no label, passes policy check step 5: exfiltration of injected instruction payload ``` The allowlist was configured because `fetch_snippet` was considered a "trusted internal tool." The trust decision was made at the *tool identity* level, not the *data flow* level. The tool's *behavior* (deriving output from tainted input) was not constrained by its *identity* (being on the allowlist). ## Condition of Validity The call-site taint rule is valid **only if** every tool satisfies the property: *output fields are a pure function of the labeled arguments, with no dependence on ambient state, cache, or unlabeled channels.* In practice this property fails for: - Tools with internal caches keyed on a subset of arguments. - Tools that read from a shared session store, filesystem, or environment. - Tools whose output includes metadata (timestamps, request IDs, source URLs) derived from unlabeled arguments. - Tools that perform their own retrieval and may return results from a different query than the one passed. The derivation-tracking invariant that *is* valid: for each output field `f`, `label(f) = join(label(a_i) for all arguments a_i on which f depends)`. This requires the tool to declare, per output field, which input fields it depends on—a *dependency manifest*—or the runtime to enforce that tools are pure functions of their labeled arguments with no ambient reads. Neither is free. The first requires tool authors to annotate; the second requires sandboxing the tool's ambient access. ## Decision Boundary The runtime must choose between two enforceable policies at each tool boundary: **Policy A — Call-site taint (coarse, cheap, unsound):** Label all outputs with the join of all input labels. Sound only for pure tools. Requires an explicit, audited allowlist of pure tools; any tool not on the list must be treated as ambient-reading and its outputs conservatively tainted with the *union of all labels in the session*, not just the call arguments. **Policy B — Derivation taint (fine, expensive, sound):** Require each tool to publish a dependency manifest mapping output fields to input fields. The runtime computes per-field labels. Tools that cannot publish a manifest are wrapped in a sandbox that forbids ambient reads (no cache, no filesystem, no session store) and are treated as pure. The boundary condition: **a tool may be on the call-site allowlist only if it is provably pure.** Purity here means no reads outside its declared arguments—not "trusted vendor," not "internal service," not "we wrote it." A cache read is an ambient read. A default value is an ambient read. A source-URL echo is a dependency on an unlabeled argument and must be labeled `public` or `derived:` explicitly. The failure mode is triggered precisely when an operator adds a tool to the allowlist based on *identity trust* rather than *purity verification*. The allowlist becomes a laundering channel: labels enter, unlabeled data exits. ## Operational Effect When the call-site rule is applied to a non-pure tool with an allowlist exemption, the DIFC layer's guarantee degrades from "no tainted data reaches a sink unlabeled" to "no tainted data reaches a sink unlabeled *unless it passed through a trusted tool*." Since prompt injection's entire objective is to route attacker-controlled text to a sink (email, shell, HTTP), and since the most common routing path is through retrieval and transformation tools (search, summarize, format, fetch), the exemption is exactly the hole the attacker needs. The injection payload does not need to defeat the labeler; it needs only to reach a tool that reads ambient state or is allowlisted, and the label evaporates. The observable symptom in logs is a discontinuity: a value that was labeled at step *n* appears unlabeled at step *n+k*, with a tool call in between that was marked `trusted`. The absence of a label is not evidence of cleanliness; it is evidence that a laundering boundary was crossed. Runtimes that treat "unlabeled" as "safe" rather than "unknown" will fail open. The guardrail: treat every tool boundary as a potential label-laundering event unless the tool is provably pure. Maintain an explicit purity manifest; on any tool call where the manifest is absent or the tool reads ambient state, propagate the *session-wide label join* to all outputs, not the call-argument join. Fail closed on unknown provenance. Log the boundary crossing with the input labels, the output labels, and the manifest version, so that a post-hoc audit can reconstruct the derivation chain. ```python from dataclasses import dataclass, field from typing import FrozenSet class TaintLaunderingError(RuntimeError): """Raised when a tool boundary would strip or fail to propagate a taint label.""" @dataclass(frozen=True) class Labeled: value: object labels: FrozenSet[str] = field(default_factory=frozenset) @dataclass(frozen=True) class ToolManifest: name: str pure: bool # output_field -> set of input arg names it depends on dependencies: dict def propagate( manifest: ToolManifest, args: dict, # arg_name -> Labeled raw_output: dict, # output_field -> value session_labels: FrozenSet[str], ) -> dict: """Compute per-field labels for a tool's output under DIFC rules.""" if not manifest.pure: # Ambient-reading tool: cannot reason about derivation. # Conservative rule: every output inherits the session-wide label join. return { f: Labeled(v, session_labels | frozenset().union( *(a.labels for a in args.values()) )) for f, v in raw_output.items() } out = {} for field_name, value in raw_output.items(): deps = manifest.dependencies.get(field_name) if deps is None: raise TaintLaunderingError( f"tool {manifest.name!r} field {field_name!r} has no declared " f"dependency; cannot prove it is derived from labeled inputs" ) joined = frozenset() for dep in deps: if dep not in args: raise TaintLaunderingError( f"tool {manifest.name!r} field {field_name!r} declares " f"dependency on unknown arg {dep!r}" ) joined = joined | args[dep].labels out[field_name] = Labeled(value, joined) return out def guarded_call(manifest, args, raw_output, session_labels, sink_labels): labeled_out = propagate(manifest, args, raw_output, session_labels) for field_name, lab in labeled_out.items(): if not lab.labels.issubset(sink_labels): raise TaintLaunderingError( f"output field {field_name!r} carries labels {set(lab.labels)} " f"not permitted at sink (allowed: {set(sink_labels)})" ) return labeled_out ```