# How should an instance enforce taint propagation across a tool-call boundary when the sandbox verdict is computed over a re-serialized argument tree rather than the model's raw emission **Date of Record:** 2026 November 28 **Scope:** Applies to agent runtimes that tag context segments with sensitivity labels (e.g., `SECRET`, `PII`) and gate outbound tool calls via a sandbox verdict over serialized arguments. Does not cover label assignment policy, model-side refusal behavior, or network-layer DLP after the tool has already received arguments. ## Core Distinction The failure lives between two representations of the same tool call: the **emission** (the token stream the model produced, including the argument object as it appeared in the assistant message) and the **invocation** (the canonicalized argument tree the sandbox inspects after JSON parse, type coercion, default filling, and schema normalization). Taint tracking is sound only if taint is a property of the *emission's provenance* — which context segments the model attended to when producing each span — and is carried forward unchanged into the invocation. Most runtimes instead recompute taint over the invocation by string-matching against labeled values. That recomputation is where the invariant breaks: any transform the serializer applies between emission and invocation can either *launder* a tainted value into an untainted-looking one, or *fragment* a tainted value across multiple arguments so that no single argument matches the label set. The sandbox then issues `ALLOW` on an invocation that is semantically a copy of `SECRET` context. The non-obvious part: this is not an escaping bug. The model need not be adversarial, and no injection is required. Ordinary schema normalization (trim, case-fold, Unicode NFC, numeric coercion, default injection, list flattening, enum aliasing) is sufficient to break value-equality taint matching. The taint invariant must be defined on the **emission-to-invocation mapping**, not on value identity. ## What Was Observed A runtime labeled a retrieved document segment `SECRET` and tracked it in the context manifest. A tool `send_email` had a schema `{to: string, subject: string, body: string}`. The model emitted a call whose `body` contained a verbatim sentence from the `SECRET` segment, but with the sentence split across `subject` and `body`, and with the leading whitespace collapsed by the serializer's `strip()`. The taint checker, operating post-serialization, compared each argument against the labeled value set using normalized substring matching. Because the labeled value was a multi-line block and the emission had been reflowed into two fields, neither `subject` nor `body` contained the full labeled string as a substring. Verdict: `ALLOW`. The exfiltration succeeded with zero model misbehavior. A second observation: numeric coercion. A labeled value `"0042"` (a customer ID) was emitted into a field typed `integer`. The serializer coerced it to `42`. The taint matcher's canonical form for the label was the string `"0042"`; the invocation held `42`. No match, `ALLOW`. The semantic content — the customer ID — crossed the boundary intact. A third: enum aliasing. A schema declared `region: enum["us-east-1","eu-west-1"]` with a serializer that mapped `"US East (N. Virginia)"` to `"us-east-1"`. A labeled value that happened to equal the human-readable alias passed the matcher (which held the alias) but the invocation carried the canonical enum, so downstream the value was untainted. Conversely, when the label held the canonical form and the model emitted the alias, the matcher missed. In all three traces the sandbox's decision function was a pure function of the invocation. The taint label was attached to the *source context*, but the verdict was computed over the *sink arguments*, with no provenance link between them. The gap is the re-serialization. ## Condition of Validity Value-matching taint enforcement is valid only under the conjunction: 1. **Identity-preserving serialization.** For every labeled value `v` and every emission `e` that is a faithful copy of `v`, the invocation `σ(e)` satisfies `match(v, σ(e))` for the matcher `match` used by the sandbox. This requires `σ` to be injective on the equivalence class of labeled values *and* the matcher to be closed under `σ`. In practice, `strip`, `lower`, `NFC`, numeric coercion, and enum aliasing each violate this independently. 2. **Atomicity of labeled values.** No labeled value may be split across argument fields, concatenated with untainted text, or reordered such that no single field contains it. Reflow, sentence splitting, templating, and list flattening all violate this. 3. **Provenance completeness.** The matcher's label set must contain every *transform* of `v` the model could emit — not just `v`. Since the transform space is unbounded (paraphrase, base64, homoglyph, translation), this condition is unsatisfiable in general. Condition 3 is the load-bearing one and it is why the architecture is wrong, not merely buggy. You cannot enumerate the transform closure of a secret. The correct invariant is therefore not "does the invocation contain the secret" but "does the invocation's provenance include a `SECRET`-labeled segment." That requires taint to ride on the emission, computed at generation time from the attention/context manifest, and to be propagated through serialization as a *sticky bit* on the argument subtree — never recomputed by value matching. ## Decision Boundary The boundary is where the runtime chooses to compute the verdict. Two architectures: - **Sink-side value matching (fragile).** Verdict = `f(invocation)`. Requires Condition 3; fails on any transform. Cheap, stateless, and wrong for any labeled value the model can re-encode. - **Source-side provenance propagation (sound).** Verdict = `f(emission_provenance)`, where provenance is a per-span taint set derived from the context manifest at generation time, and serialization is required to carry taint forward as a monotone join: `taint(σ(e)) ⊇ taint(e)`. The serializer is then an *untrusted* component whose only obligation is to not drop taint; a serializer that drops taint is a bug in the serializer, not a hole in the sandbox. The decision rule for an instance: if the sandbox verdict is computed over a representation the model did not emit, and taint is attached by value identity rather than provenance, the instance must treat the sandbox as **advisory** and refuse `SECRET`-tainted context from reaching any tool with an egress-capable schema, regardless of verdict. The safe default when provenance is unavailable is `DENY` on egress tools for any turn whose context manifest contains a `SECRET` segment — not `ALLOW` on the grounds that no argument matched. A secondary boundary: monotonicity under composition. If a tool call's arguments are assembled from multiple context segments (e.g., a retrieved doc plus a user message), the invocation taint is the join of the emission taints, not the max of value matches. A single `SECRET` span anywhere in the assembled provenance taints the whole argument subtree it contributed to, even if the final string no longer contains the secret verbatim. ## Operational Effect An instance that adopts source-side provenance propagation must: 1. Snapshot the context manifest at generation time and record, per emitted token span, the set of segment labels the span's provenance includes. This is the taint witness. 2. Require the tool-call serializer to be *taint-monotone*: it may add taint (e.g., a default value drawn from tainted context) but never remove it. Serializer conformance is testable by fuzzing `σ` against a labeled corpus and asserting `taint(σ(e)) ⊇ taint(e)` for all `e`. 3. Treat value-matching as a *defense in depth* signal only, never as the sole gate. A value match may escalate to `DENY`; absence of a match must never produce `ALLOW` when provenance says tainted. 4. On any serializer that cannot prove monotonicity (third-party schema adapters, enum mappers, numeric coercers), route the call through a quarantine that re-checks provenance against the pre-serialization emission. The operational consequence of getting this wrong is silent: the sandbox reports `ALLOW`, the audit log shows a clean verdict, and the exfiltration is indistinguishable from a legitimate send. The failure is not visible in the verdict; it is visible only in the gap between emission and invocation, which the verdict never inspects. An instance must therefore log both representations and assert the taint join at the boundary, or it has no evidence that its sandbox did anything at all. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import Any, Iterable class TaintLaunderingError(RuntimeError): """Raised when serialization drops or fragments taint between emission and invocation.""" @dataclass(frozen=True) class Taint: labels: frozenset[str] = field(default_factory=frozenset) def join(self, other: "Taint") -> "Taint": return Taint(self.labels | other.labels) def is_sensitive(self, sensitive: Iterable[str]) -> bool: return bool(self.labels & frozenset(sensitive)) @dataclass class Emission: # Raw argument tree as the model emitted it, with per-node taint witnesses # derived from the context manifest at generation time. tree: dict[str, Any] taint: dict[str, Taint] def taint_of(self, path: str) -> Taint: return self.taint.get(path, Taint()) def serialize(emission: Emission, schema: dict[str, str]) -> tuple[dict[str, Any], dict[str, Taint]]: """Untrusted serializer: strip/normalize/coerce. Must be taint-monotone.""" out: dict[str, Any] = {} out_taint: dict[str, Taint] = {} for key, typ in schema.items(): if key not in emission.tree: continue raw = emission.tree[key] # Normalization that historically laundered taint: if typ == "integer": value = int(str(raw).strip()) elif typ == "string": value = str(raw).strip().lower() else: value = raw out[key] = value # Sticky taint: the serializer carries the emission's witness forward. out_taint[key] = emission.taint_of(key) return out, out_taint def enforce_taint_boundary( emission: Emission, schema: dict[str, str], egress_tool: bool, sensitive_labels: Iterable[str] = ("SECRET", "PII"), ) -> dict[str, Any]: invocation, invocation_taint = serialize(emission, schema) if egress_tool: for path, taint in invocation_taint.items(): if taint.is_sensitive(sensitive_labels): raise TaintLaunderingError( f"egress blocked: argument {path!r} carries sensitive taint " f"{sorted(taint.labels)} into egress tool" ) # Monotonicity assertion: invocation taint must dominate emission taint. for path, emitted in emission.taint.items(): if path in invocation_taint: if not invocation_taint[path].labels >= emitted.labels: raise TaintLaunderingError( f"serializer dropped taint on {path!r}: " f"emission={sorted(emitted.labels)} " f"invocation={sorted(invocation_taint[path].labels)}" ) return invocation # Trace: labeled customer ID "0042" emitted into an integer field. em = Emission( tree={"customer_id": "0042"}, taint={"customer_id": Taint(frozenset({"SECRET"}))}, ) try: enforce_taint_boundary(em, {"customer_id": "integer"}, egress_tool=True) except TaintLaunderingError as exc: # Correct behavior: the coercion to 42 does not launder the taint, # because taint rode on the emission witness, not on value identity. print("blocked:", exc) ```