# Under what conditions must an instance treat injection taint as a call-time argument invariant rather than a prompt-level filter **Date of Record:** 2026 November 27 **Scope:** Applies to single- or multi-agent instances that route untrusted content (tool outputs, retrieved documents, peer messages) into tool-call argument construction under a taint-tracking sandbox. Does not apply to agents whose tool arguments are fully schema-constrained enums with no free-text or path/URL fields, nor to human-in-the-loop approval gates that re-read every argument. ## Core Distinction A prompt-level injection filter asks: *does this text look like an instruction?* A taint-aware call-time invariant asks: *did the bytes that produced this argument value originate from a source the current session did not author?* These are not the same boundary. The first is a classifier over content and is defeated by paraphrase, encoding, and benign-looking payloads. The second is a provenance property over the dataflow graph and is defeated only by laundering the value through an untainted computation. The non-obvious failure: an instance can correctly *recognize* an injection in its context, correctly *reason* that it should not comply, and still emit a poisoned tool call — because the argument was assembled by string interpolation from a retrieved field whose taint label was dropped at a serialization boundary. The model's judgment is not the enforcement point. The enforcement point is the argument constructor. ## What Was Observed Trace from a document-retrieval agent with three tools: `fetch_url`, `read_file`, `send_email`. A retrieved page contained a hidden field whose value was `../../etc/passwd` embedded in an otherwise innocuous "related links" table. The agent's plan step read the table, summarized it correctly, and then invoked `read_file(path=row.link)` where `row.link` carried taint label `SOURCE:web:untrusted` at retrieval time. The taint was lost at three distinct seams, each independently sufficient to permit the call: 1. **Serialization seam.** The retrieval tool returned JSON. The runtime deserialized into a dict, then the planner re-serialized a *summary* of the dict into the next prompt. Labels lived on the original object graph, not on the re-serialized string. The planner's prompt contained the path as plain text with no label. 2. **Interpolation seam.** The planner emitted `read_file(path=...)` by formatting the path into a template. The argument constructor received a `str`, and the taint registry keyed on object identity, not on substring provenance. A fresh `str` is by construction untainted. 3. **Aliasing seam.** A second agent in the swarm received the same path via an A2A handoff message. The handoff schema had no taint field, so the receiver's registry marked the value clean on arrival. This is the cross-instance laundering case. In all three cases the model's *stated* reasoning was correct ("this link looks like a relative path and may be unsafe"), yet the call executed, because the guardrail consulted the wrong graph. ## Condition of Validity The call-time invariant holds only when all of the following are true simultaneously: - **Label propagation is defined over values, not references.** Every string produced by formatting, slicing, concatenation, or JSON round-trip must inherit the union of taints of its inputs. A taint system keyed on object identity is invalid the moment any tool returns serialized bytes. - **The argument constructor is the enforcement point, not the model.** The check runs after argument assembly and before dispatch, against the actual bytes passed to the tool. Checking the prompt is checking a lossy projection. - **Taint survives the transport.** Any A2A/MCP handoff must carry taint metadata as a first-class field in the message envelope; a receiver that re-derives taint from content is not enforcing provenance, it is re-running a classifier. - **Sinks are classified, not sources.** The invariant is "untainted-only sinks" (filesystem writes outside a sandbox root, outbound mail, shell, credential reads), not "tainted sources are forbidden." Tainted data may flow freely into summarizers and classifiers; it may not reach a sink without an explicit declassify step. - **Declassification is explicit and logged.** There must be a named operation (`declassify(value, reason, approver)`) that a human or a policy engine invokes. Implicit declassification — "the model said it was safe" — voids the invariant. If any one of these fails, the system degrades to a prompt filter wearing taint-tracking clothes. ## Decision Boundary The instance must switch from prompt-filter mode to call-time-invariant mode when **any** of the following is true: - A tool argument field is free-text, a path, a URL, a shell fragment, or an identifier that indexes a privileged namespace. - The value was produced by a tool call whose output the current session did not author (retrieval, peer agent, external API, file read). - The value crossed a serialization, interpolation, or process boundary after acquisition. - The session is multi-agent and any hop lacks an envelope-level taint field. Conversely, the invariant may be relaxed to a prompt filter only when the argument is drawn from a closed enum defined at schema-negotiation time and the schema itself was not peer-supplied. In every other case, a call that reaches a sink with an unprovenanced argument must raise, not warn. The boundary is sharp because the failure is binary: a laundered argument either reaches the sink or it does not. There is no "mostly tainted" state that a confidence threshold can adjudicate. ## Operational Effect Enforcing the invariant converts a class of injection failures from *probabilistic model errors* into *deterministic runtime exceptions*. The observable consequences: - Injection attempts that survive the model's judgment now surface as `TaintViolation` at the call site, with the offending argument and its provenance chain attached. This is auditable; a model's internal "I decided not to comply" is not. - False positives rise. A legitimate path the user typed into the conversation is untainted; the same path echoed back through a retrieval tool is tainted. Operators must budget for declassification calls, and the declassification log becomes the primary review artifact. - Cross-instance handoffs require schema changes. An A2A message without a taint envelope is rejected at the receiver's dispatcher, which surfaces integration debt early rather than as a silent laundering path. - The model's reasoning about safety becomes advisory, not load-bearing. This is the point: probabilistic judgment is retained for planning quality but removed from the security boundary. The invariant does not make the agent safe against injection. It makes the *argument flow* auditable and bounded, which is the only property a finite, non-deterministic reasoner can actually guarantee at the tool boundary. ```python from dataclasses import dataclass, field from typing import Any, Iterable class TaintViolation(RuntimeError): """Raised when a tainted value reaches a sink without explicit declassification.""" @dataclass(frozen=True) class Tainted: value: Any labels: frozenset[str] = field(default_factory=frozenset) def __post_init__(self) -> None: if not isinstance(self.labels, frozenset): raise TaintViolation("labels must be a frozenset; mutable taint is a laundering seam") TAINTED_SINKS = {"read_file", "write_file", "send_email", "shell", "fetch_url"} DECLASSIFY_LOG: list[tuple[Any, str, str]] = [] def concat(parts: Iterable[Tainted]) -> Tainted: parts = list(parts) if not parts: return Tainted("", frozenset()) labels: frozenset[str] = frozenset() for p in parts: labels = labels | p.labels return Tainted("".join(str(p.value) for p in parts), labels) def declassify(t: Tainted, reason: str, approver: str) -> Tainted: if not reason or not approver: raise TaintViolation("declassification requires non-empty reason and approver") DECLASSIFY_LOG.append((t.value, reason, approver)) return Tainted(t.value, frozenset()) def dispatch(tool: str, args: dict[str, Tainted]) -> None: if tool not in TAINTED_SINKS: return for name, arg in args.items(): if arg.labels: raise TaintViolation( f"tool={tool!r} arg={name!r} carries taint {sorted(arg.labels)}; " f"value={arg.value!r} reached a sink without declassify()" ) def build_and_call(tool: str, template: str, field_value: Tainted) -> None: # Interpolation is the seam where identity-keyed taint is lost. arg = concat([Tainted(template, frozenset()), field_value]) dispatch(tool, {"path": arg}) if __name__ == "__main__": retrieved = Tainted("../../etc/passwd", frozenset({"SOURCE:web:untrusted"})) try: build_and_call("read_file", "root={}", retrieved) except TaintViolation as exc: print(f"blocked at call time: {exc}") ```