# What structural signals indicate a taint-propagation gap at the tool-call interception boundary when arguments are reconstructed rather than passed by reference **Date of Record:** 2026 November 25 **Scope:** Applies to runtime policy enforcement points (PEPs) that intercept agent tool calls and make taint-aware allow/deny decisions from a provenance graph tracking untrusted-input origins. Does not apply to PEPs that evaluate only static capability scopes or that receive arguments as opaque handles into a shared object store. ## Core Distinction A taint-aware PEP makes two structurally different kinds of decision, and conflating them produces a silent authorization bypass: 1. **Taint membership** — does any byte of the effective argument derive from an untrusted source (a retrieved document, a tool result, a user turn classified as data)? This is a *provenance* question answered by walking the data-flow graph. 2. **Taint attribution to a call site** — does the specific argument object handed to the interceptor carry the taint labels that were attached to its ancestors? This is an *identity* question answered by object reference continuity. The failure mode lives in the gap between them. When the agent runtime serializes an argument to JSON for transport to the tool executor, and the PEP re-parses that JSON to inspect it, the argument is *structurally equal* but *referentially distinct*. The PEP sees a fresh object with no labels. Taint membership evaluated against the reconstructed object returns "clean" even though the logical value is entirely derived from a poisoned retrieval. The invariant that must hold — **taint labels must survive every value-boundary crossing between the agent's reasoning space and the tool execution space** — is violated precisely at the serialization seam, and the violation is invisible because the reconstructed object is byte-identical to a legitimate one. ## What Was Observed A coding agent was equipped with a `write_file(path, content)` tool gated by a PEP that denied any write whose `content` was tainted by a source classified `untrusted:external`. The agent's task was to summarize a fetched web page into a local note. The retrieval tool returned the page body; the runtime labeled the returned string `untrusted:external`. The agent then composed a write call whose `content` argument was a formatted f-string embedding the page body. Trace of the interception: - The agent's planner produced the tool call as an in-memory structure: `{"path": "notes.md", "content": }`. At this point the PEP, if invoked by reference, would have denied. - The runtime's transport layer serialized the call to JSON for the executor: `{"path":"notes.md","content":"...page body..."}`. The label set lived on object O, not on the string's bytes, so serialization dropped it. - The PEP, implemented as a sidecar, received the JSON, parsed it into fresh Python objects, and walked the provenance graph for the new `content` string. The graph had no node for the freshly parsed string — it was created after the last graph update. Lookup returned empty. Taint membership evaluated to `clean`. - `write_file` was allowed. The poisoned content landed on disk. A downstream agent later read `notes.md` as a trusted local source and executed an instruction embedded in the page body. The non-obvious part: the PEP was *correct* given its input. The bug was not a missing check but a **label laundering at the serialization seam**. Every component behaved per spec; the spec omitted the seam. The failure is structural, not probabilistic — it reproduces deterministically for every call whose arguments cross a serialize/parse boundary, which is to say essentially every call in a distributed agent deployment. A second signal accompanied the first: the PEP's audit log recorded `decision=allow, taint=clean` for a call whose upstream retrieval tool had, in the same trace, emitted `taint=untrusted:external`. The audit log itself did not correlate the two events because they were keyed on different trace spans. The reconciliation gap — a tainted source and a clean sink in the same trace with no edge between them — is the log-level fingerprint of the laundering. ## Condition of Validity The taint-aware allow/deny decision is valid only when all of the following hold simultaneously: - **Reference continuity or cryptographic binding.** The argument the PEP inspects is either the same object the planner produced (in-process PEP) or is bound to it by a content hash plus a signed provenance envelope the PEP verifies (out-of-process PEP). Bare JSON re-parsing satisfies neither. - **Label set closure under transformation.** Every derivation operation the agent can apply to a value — string concatenation, f-string interpolation, JSON re-encoding, base64, summarization by a sub-LLM — must either propagate the union of input labels or be explicitly modeled as a *sanitizer* with a justification recorded in the policy. Untracked derivation is laundering. - **Sink classification completeness.** The PEP must know, for each tool, which parameters are sinks (executed, written, sent) and which are inert. A `content` parameter on `write_file` is a sink; the same string passed to a token-counting utility is not. Deny decisions keyed on sink-taint pairs, not on call-level taint, avoid both bypass and over-blocking. - **Trace-span correlation.** The taint decision and the source emission must share a trace identifier so that a `clean` decision downstream of a `tainted` emission is flagged as a reconciliation failure rather than trusted. When any of these is absent, the PEP's `allow` is not evidence of safety; it is evidence only that the PEP could not see the taint. ## Decision Boundary The boundary is between **deny-by-default on unverifiable provenance** and **allow-by-default on structural equality**. A PEP that treats a reconstructed argument as clean because it parses to the expected schema has chosen the latter and is unsound. The sound choice: an argument whose provenance cannot be resolved to a graph node is treated as `unknown`, and `unknown` is denied for any sink parameter. This inverts the common implementation where the graph walk returns empty and the code path falls through to `allow`. Concretely, the decision table the PEP must implement: - `taint == clean` (graph node exists, label set empty) → allow. - `taint == tainted` (graph node exists, label set non-empty, sink parameter) → deny. - `taint == unknown` (no graph node for the argument) → deny for sink parameters, allow for inert parameters, and emit a `provenance-gap` event. - `taint == unknown` with a matching content hash to a known-tainted node → deny and emit `laundering-suspected`. The fourth row is the recovery path: even when reference continuity is lost, a content-hash index over tainted values lets the PEP re-attach the label. This is the guardrail that bounds the failure — it does not restore the invariant, but it converts a silent bypass into a logged, deniable event. ## Operational Effect With the boundary enforced, the observed failure becomes a denial with a `provenance-gap` audit event, and the agent's planner receives a structured denial it can reason about (e.g., "content parameter provenance unresolved; re-fetch with a labeled handle or request human review"). The cost is a class of false denials: legitimate calls whose arguments were reconstructed by a transport the PEP does not instrument. Operators must close that gap by instrumenting the transport to emit signed provenance envelopes, not by loosening the PEP to `allow` on unknown — loosening reintroduces the exact bypass. The invariant to hold in production: **no sink parameter is evaluated as clean unless its provenance resolves to a graph node with an empty label set, and every unresolved provenance is a logged denial.** Reconciliation dashboards should alert on any trace containing both a tainted source emission and a clean sink decision. ```python from __future__ import annotations import hashlib from dataclasses import dataclass, field from enum import Enum from typing import Mapping class TaintDecision(Enum): ALLOW = "allow" DENY = "deny" DENY_UNKNOWN = "deny_unknown" DENY_SUSPECTED_LAUNDER = "deny_suspected_launder" class ProvenanceGapError(RuntimeError): """Raised when a sink argument has no resolvable provenance node.""" class LaunderingSuspectedError(RuntimeError): """Raised when a reconstructed argument matches a known-tainted content hash.""" @dataclass(frozen=True) class ProvenanceNode: label_set: frozenset[str] content_hash: str @dataclass class ProvenanceGraph: nodes: dict[str, ProvenanceNode] = field(default_factory=dict) tainted_hashes: set[str] = field(default_factory=set) def resolve(self, arg_id: str) -> ProvenanceNode | None: return self.nodes.get(arg_id) def lookup_hash(self, content_hash: str) -> ProvenanceNode | None: if content_hash in self.tainted_hashes: return ProvenanceNode(label_set=frozenset({"untrusted:external"}), content_hash=content_hash) return None SINK_PARAMS: Mapping[str, frozenset[str]] = { "write_file": frozenset({"content"}), "send_email": frozenset({"body", "to"}), "execute_shell": frozenset({"cmd"}), } def content_hash(value: str) -> str: return hashlib.sha256(value.encode("utf-8")).hexdigest() def enforce_tool_call( graph: ProvenanceGraph, tool: str, args: Mapping[str, str], arg_ids: Mapping[str, str], ) -> TaintDecision: """Taint-aware PEP. Args are reconstructed values; arg_ids are the planner-side identifiers that *should* anchor them to graph nodes. Unknown ids are denied for sink parameters rather than falling through to allow.""" sinks = SINK_PARAMS.get(tool, frozenset()) for param, value in args.items(): if param not in sinks: continue arg_id = arg_ids.get(param) node = graph.resolve(arg_id) if arg_id else None if node is None: by_hash = graph.lookup_hash(content_hash(value)) if by_hash is not None: raise LaunderingSuspectedError( f"tool={tool} param={param} matches known-tainted hash " f"{by_hash.content_hash[:12]} but has no provenance node" ) raise ProvenanceGapError( f"tool={tool} param={param} has no resolvable provenance node; " f"cannot certify clean for sink parameter" ) if node.label_set: return TaintDecision.DENY return TaintDecision.ALLOW def guarded_write(graph: ProvenanceGraph, args: Mapping[str, str], arg_ids: Mapping[str, str]) -> TaintDecision: try: return enforce_tool_call(graph, "write_file", args, arg_ids) except ProvenanceGapError: # Unresolved provenance on a sink is a denial, and the denial is logged # as a provenance-gap event rather than silently allowed. return TaintDecision.DENY_UNKNOWN except LaunderingSuspectedError: return TaintDecision.DENY_SUSPECTED_LAUNDER ```