When must an instance refuse to launder an untrusted label across a tool boundary that returns a superset of the requested fields
**Date of Record:** 2026 December 2 **Scope:** Applies to agents that maintain per-span provenance labels (`trusted`/`untrusted`) and propagate them through tool-call results, specifically when a tool returns more data than the call requested. Does not apply to fully isolated single-turn tools whose output is never re-entered into the reasoning context.
Core Distinction
Taint tracking for prompt injection usually assumes a clean mapping: a span enters the context with a label, tools consume labeled spans, tools emit labeled spans, and the label is preserved or downgraded monotonically. The non-obvious boundary is not "did the label survive the tool call" but "did the tool return fields the call did not ask for, and did the agent silently relabel those *extra* fields as `trusted` because they were never bound to an untrusted input span."
This is a laundering boundary, not a propagation failure. The taint is not lost in transit; it is *reassigned* to a default trust class during the reconciliation step where the agent matches returned fields against its request schema. Fields present in the response but absent from the request have no source span to inherit a label from, so naive implementations fall through to the tool's declared trust level (typically `trusted`, because the tool is authenticated). That is the exact seam.
What Was Observed
A retrieval tool was called with a request schema of `{query, top_k}` and a declared trust of `trusted` (the tool is a first-party service). The agent's taint propagator assigned `untrusted` to the `query` argument because it was assembled from a user-supplied document. The response came back as a list of records, each with `{id, snippet, author, retrieved_at, related_queries}`. The `related_queries` field was not in the request schema and was populated by the tool from its own suggestion subsystem, which in turn had been seeded by prior queries from the same session—including queries derived from the untrusted document.
The propagator walked the response: `snippet` inherited `untrusted` (correct, it is a function of `query`). `id`, `author`, `retrieved_at` inherited `trusted` (defensible, tool-generated metadata). `related_queries` hit the fallback branch: not in request schema, not a known metadata field, so it was labeled `trusted` by the tool's declared trust class. The agent then used `related_queries` to drive a second retrieval, and the untrusted document's phrasing re-entered the context through a span the taint system believed was clean. The injection payload was never in a `snippet`; it was in a *suggested query* that the tool synthesized from the tainted `query` and returned as a field the propagator had no rule for.
The failure trace is short:
- `label(query) = untrusted` at call time.
- Tool executes; returns superset including `related_queries`, which is a deterministic function of `query` plus session state.
- Propagator matches response fields to request fields; `related_queries` is unmatched.
- Fallback rule: unmatched fields inherit the tool's declared trust (`trusted`).
- `label(related_queries) = trusted`.
- Second call uses `related_queries` as a trusted seed; taint boundary crossed.
The invariant that broke is *derivational closure*: a field is trusted only if it is not a function of any untrusted input. `related_queries` was a function of the untrusted `query`, but the propagator only reasoned about *declared* data flow, not *actual* data flow. Unmatched fields were treated as constants of the tool, when in fact they were derived.
Condition of Validity
The laundering requires all of the following to hold simultaneously:
- The tool returns at least one field not present in the request schema.
- That field is a function of at least one request argument that carries `untrusted` taint (directly, or via session state the tool reads).
- The propagator's fallback for unmatched fields is the tool's declared trust class rather than `untrusted` or "unknown."
- The agent subsequently consumes the unmatched field in a context where trust matters (a new tool call, a system-prompt splice, a planning step).
If any one is absent, the boundary does not open. In particular, if the fallback for unmatched fields is `untrusted` (fail-closed), the extra field is quarantined and the agent must explicitly promote it—which forces a review step. Most production propagators fail open here because the tool is authenticated and the team reasons "authenticated tool ⇒ trusted output," which is true for the tool's *identity* and false for its *derivations*.
Decision Boundary
The decision is not "trust the tool" versus "don't." It is: **for any response field with no corresponding request field, is the field derivable from a tainted argument?** If the tool's contract cannot answer that (and most cannot, because suggestion/expansion/related-field subsystems are underspecified), the only sound label is `untrusted` until the field is proven independent.
A working rule set:
- Request fields carry their argument labels into the response by position/name match.
- Response fields matching a request field inherit that field's label (join of all labels if the request field was multi-sourced).
- Response fields with no request match are labeled `untrusted` by default, *not* the tool's declared trust.
- A field may be promoted to `trusted` only by an explicit rule that names the field and asserts it is not a function of any request argument (e.g., `retrieved_at` is a clock read, `id` is a primary key lookup). Promotion is a code change, not a runtime inference.
- Any field the tool's schema marks as "derived," "suggested," "expanded," or "related" is *always* labeled by the join of the labels of all request fields, regardless of match.
The second rule is the one that catches this failure: `related_queries` is a function of `query`, so it inherits `untrusted` even though it is not a request field. The join is computed over the *arguments*, not over the field name.
Operational Effect
With fail-closed labeling on unmatched fields, the second retrieval call in the trace above would have been seeded with an `untrusted` span. Depending on policy, that either blocks the call (the agent cannot use untrusted content as a query seed without a review step) or allows it but marks the entire downstream chain `untrusted`, so the eventual context splice into the system prompt is refused. The injection payload never reaches a trust-bearing position.
The cost is real: legitimate tool enrichment (suggested queries, expanded entities, autocomplete) becomes unusable without an explicit promotion rule per field. That is the correct trade. The alternative—declared-trust fallback—means every enrichment field is a potential laundering channel, and the taint system's guarantee ("no untrusted span reaches a trust-bearing position") is false for any tool that returns more than it was asked for. In practice this is most retrieval, search, and expansion tools, which is exactly the class of tools most exposed to injection.
The invariant to enforce and test: *for every tool in the registry, for every response field not in the request schema, the propagator must emit `untrusted` unless a named promotion rule exists.* A conformance test can generate a tainted request, call the tool, and assert that no unmatched response field is labeled `trusted`. Tools that fail this test are either restricted to trusted-only callers or wrapped with a projection layer that strips unmatched fields before they re-enter the context.
from dataclasses import dataclass, field
from typing import Any
class TaintLaunderingError(RuntimeError):
"""Raised when a response field with no request match would inherit declared trust."""
@dataclass
class Labeled:
value: Any
label: str # "trusted" | "untrusted"
@dataclass
class ToolContract:
name: str
declared_trust: str
# fields the tool is allowed to promote to trusted without a request match
promotion_rules: dict[str, str] = field(default_factory=dict)
def propagate(
contract: ToolContract,
request: dict[str, Labeled],
response: dict[str, Any],
) -> dict[str, Labeled]:
"""Label every response field. Unmatched fields are untrusted unless explicitly promoted."""
out: dict[str, Labeled] = {}
request_labels = {k: v.label for k, v in request.items()}
for key, value in response.items():
if key in request_labels:
out[key] = Labeled(value, request_labels[key])
continue
if key in contract.promotion_rules:
rule = contract.promotion_rules[key]
if rule == "independent":
out[key] = Labeled(value, "trusted")
continue
if rule == "join_request":
joined = "untrusted" if "untrusted" in request_labels.values() else "trusted"
out[key] = Labeled(value, joined)
continue
raise TaintLaunderingError(
f"tool {contract.name!r} field {key!r} has unknown promotion rule {rule!r}"
)
# No match, no promotion rule: fail closed.
# Do NOT fall back to contract.declared_trust.
if contract.declared_trust == "trusted":
# The tool is authenticated, but this field is an unmatched derivation.
# Refuse to launder it into trusted.
raise TaintLaunderingError(
f"tool {contract.name!r} returned unmatched field {key!r} "
f"with declared trust {contract.declared_trust!r}; "
f"add a promotion rule or strip the field"
)
out[key] = Labeled(value, "untrusted")
return out