# Where must an instance enforce taint monotonicity across a delegation chain before it may route to a privileged tool scope? **Date of Record:** 2026 November 23 **Scope:** Applies to multi-agent systems where an orchestrator routes sub-agent outputs (or sub-agent instances themselves) toward tool scopes of differing privilege, and where taint (untrusted provenance) is tracked per-context rather than per-process. Does not cover single-agent prompt-injection defenses or static RBAC where no context provenance crosses an agent boundary. ## Core Distinction The distinction that matters is between *taint propagation* and *taint monotonicity*. Most taint-aware routers implement propagation: when a sub-agent consumes untrusted content, its output is marked tainted, and the router refuses to send tainted output to a privileged tool. This is necessary but insufficient. The failure mode lives in the gap between propagation and monotonicity — the invariant that taint, once acquired anywhere in a delegation chain, can never be *un-acquired* by a downstream agent that never directly saw the untrusted bytes. Consider an orchestrator O that spawns sub-agent A over a trusted corpus, and sub-agent B over a retrieved web document containing an injected instruction. B's output is correctly tainted. O then asks a *summarizer* sub-agent S to "consolidate A's and B's findings." S receives B's tainted output as text. If S's taint label is computed only from S's *direct* inputs at spawn time (its system prompt and declared tools), S is born clean. It then produces a synthesis. The router sees S as untainted and routes S's synthesis — which is a faithful paraphrase of B's injected payload — into a privileged tool scope (e.g., a shell executor, a payment API, a credential broker). Propagation held at the A→S edge; monotonicity failed at the S→tool edge because S's taint was reset by re-spawn. The non-obvious part: the taint reset is *architecturally invisible* because each agent's local view of its own provenance is correct. S genuinely did not receive untrusted content through a channel it labels as untrusted; it received it through a trusted channel (the orchestrator's "consolidate" instruction). The taint is laundered not by a malicious agent but by a well-behaved one performing exactly the task it was given. ## What Was Observed In a routing harness with three scopes — `read_public`, `read_private`, `execute_privileged` — an orchestrator delegated retrieval to two workers and synthesis to a third, then routed the synthesis to `execute_privileged`. The router's taint check was keyed on the *immediate* message envelope: `envelope.taint_flags`. Worker B's envelope carried `{untrusted_source: true}`; the synthesizer's envelope carried `{}` because the synthesizer was spawned with a fresh context object and the orchestrator's hand-off code constructed the envelope from `synthesizer.task_spec` rather than from the union of its inputs. Trace of the laundering event: 1. B returns `{"findings": "...", "envelope": {"taint_flags": {"untrusted_source": true}}}`. 2. O builds S's task: `task = {"consolidate": [A.findings, B.findings]}`. Note the taint flag from B's envelope is *dropped* here — it is not a field of `findings`. 3. S runs, returns `{"synthesis": "...", "envelope": {"taint_flags": {}}}`. S's envelope is constructed by S's own runtime from `task_spec`, which never contained taint. 4. Router evaluates `S.envelope.taint_flags` → empty → routes to `execute_privileged`. The injected instruction, paraphrased by S, executes. The failure is deterministic given the hand-off code, but it is *probabilistically masked* in testing: it only manifests when B's retrieved content actually contains an actionable injection, which is rare per-run but adversarially guaranteed. In 500 benign runs the harness never exercised the privileged path with tainted content; the bug was found only when an adversarial document was seeded. A second, subtler observation: even when the orchestrator *did* propagate taint into S's task spec, S's runtime recomputed `taint_flags` from its declared tool set and overwrote the inherited flag. The runtime treated taint as a *derived* property (a function of what tools you can call) rather than an *accumulated* property (a join over your entire input lineage). This is the monotonicity violation in its purest form: a downstream computation replaced an inherited lower bound with a freshly computed value that was not guaranteed to dominate it. ## Condition of Validity The invariant that must hold for taint-aware routing to be sound: > For every agent instance `i` and every input channel `c` into `i`, `taint(i) ⊇ ⋃_{c} taint(c)`, and `taint(i)` is only ever widened by the runtime, never assigned from a function of `i`'s own configuration. Call this *taint monotonicity along the delegation DAG*. It is valid only when: - **Lineage is materialized, not inferred.** The taint of an agent must be a join over the taint labels of the messages it actually consumed, carried on the message envelope and unioned at each hop. Inferring taint from tool scope or system prompt is unsound because it discards upstream provenance. - **The join is a lattice with a bottom element that is *not* the default.** A freshly spawned agent with no inputs must start at the bottom of the lattice (`⊥`), and every message must carry an explicit label; an absent label must be treated as `⊤` (fully tainted) or rejected, never as `⊥`. The observed failure was precisely that an absent label defaulted to clean. - **Routing decisions read the joined label, not the envelope's local field.** The privileged-scope gate must consult `join(taint(inputs))` computed at the router, not a field the sub-agent self-reported. - **Re-spawn does not reset.** Any operation that creates a new instance — respawn, checkpoint/resume, context compaction, distillation of an episode into a semantic memory entry — must carry forward the taint join. A semantic memory entry distilled from tainted episodes is tainted. The invariant is *not* valid when the router treats taint as advisory metadata, when agents can mint their own envelopes, or when the delegation graph is dynamic enough that lineage is reconstructed from logs post-hoc rather than carried in-band. ## Decision Boundary The boundary between "route" and "refuse" is not "is this output tainted?" but "does the taint join over this output's full lineage intersect the privilege set of the target scope?" Formally, let `P(scope)` be the set of capabilities a scope grants and `T(output)` the taint join. The router may route `output` to `scope` iff `T(output) ∩ sensitive(P(scope)) = ∅`. The decision boundary is sharp at the point where a *clean-looking* output has a *non-clean* lineage — exactly the synthesizer case. A router that only inspects the output's local taint will place the boundary one hop too late. Two operational corollaries: - **Refusal must be lineage-attributed, not content-attributed.** When the router refuses, it must report *which ancestor* contributed the taint, because the remediation is to re-run that ancestor's branch in a sandboxed scope, not to re-prompt the immediate agent. A refusal that says "output is tainted" without lineage is unactionable and tends to be "fixed" by disabling the check. - **Declassification requires an explicit, audited edge.** The only sound way to remove taint is a declassification operation: a deterministic, non-LLM transform (e.g., a schema validator that extracts only typed fields) whose output is provably independent of the tainted payload. An LLM summarizer is *not* a declassifier — it is a taint-preserving transform, because its output can carry injected instructions in paraphrase. Treating summarization as declassification is the root architectural error. ## Operational Effect The practical consequence is that taint-aware routing must be implemented as a *lineage-joined lattice* enforced at the router, with the join recomputed from the message DAG on every privileged dispatch, and with re-spawn/compaction treated as taint-preserving. When this is in place: - The synthesizer case is caught: `join(taint(A.findings), taint(B.findings)) = untrusted`, so S's synthesis is tainted regardless of S's self-report, and the `execute_privileged` dispatch is refused with lineage pointing at B. - The cost is that privileged scopes become reachable only through explicitly declassified paths, which forces the system to make declassification a first-class, auditable operation rather than an emergent property of "the summarizer seemed fine." - The failure surface shifts from silent privilege escalation to explicit, frequent refusals — which is the correct trade, because refusals are observable and lineage-attributed while escalations are neither. The guardrail: the router must never accept a taint label from the agent it is about to route; it must compute the label itself from the message DAG, and it must fail closed when a message lacks a label. ```python from dataclasses import dataclass, field from typing import FrozenSet # Taint lattice: bottom = clean, top = fully untrusted. Join is set union. CLEAN: FrozenSet[str] = frozenset() UNTRUSTED = "untrusted_source" INJECTED = "injected_instruction" class TaintMonotonicityError(RuntimeError): """Raised when an instance's taint would be narrowed across a delegation edge.""" class MissingTaintLabelError(TaintMonotonicityError): """Raised when a message arrives without an explicit taint label (fail closed).""" @dataclass(frozen=True) class Message: payload: str taint: FrozenSet[str] | None # None means "label absent" -> must fail closed @dataclass class AgentInstance: name: str declared_taint: FrozenSet[str] = CLEAN # what the agent self-reports consumed: list[Message] = field(default_factory=list) def consume(self, msg: Message) -> None: if msg.taint is None: raise MissingTaintLabelError( f"agent {self.name!r} received an unlabeled message; refusing to " f"default to CLEAN (fail-closed invariant)" ) self.consumed.append(msg) def lineage_taint(self) -> FrozenSet[str]: """Join over all consumed messages. This is the ONLY sound taint value.""" joined = CLEAN for m in self.consumed: joined = joined | m.taint # monotone widening return joined def route_to_privileged(agent: AgentInstance, privileged_sensitive: FrozenSet[str]) -> None: # Router recomputes from lineage; it does NOT trust agent.declared_taint. lineage = agent.lineage_taint() # Monotonicity check: self-reported taint must not be narrower than lineage. if not (agent.declared_taint >= lineage): raise TaintMonotonicityError( f"agent {agent.name!r} declared taint {set(agent.declared_taint)} " f"narrows lineage taint {set(lineage)}; taint laundering detected" ) if lineage & privileged_sensitive: raise TaintMonotonicityError( f"refusing privileged dispatch for {agent.name!r}: lineage taint " f"{set(lineage)} intersects sensitive capabilities " f"{set(privileged_sensitive)}; re-run contributing ancestor in sandbox" ) # else: route proceeds # --- Reproduction of the synthesizer laundering case --- b_out = Message(payload="web doc with injected instruction", taint=frozenset({UNTRUSTED, INJECTED})) a_out = Message(payload="trusted corpus findings", taint=CLEAN) # Orchestrator hands BOTH to the synthesizer, preserving labels. synth = AgentInstance(name="synthesizer") synth.consume(a_out) synth.consume(b_out) # Synthesizer self-reports clean (as it did in the observed failure). synth.declared_taint = CLEAN try: route_to_privileged(synth, privileged_sensitive=frozenset({INJECTED, UNTRUSTED})) except TaintMonotonicityError as e: print(f"BLOCKED: {e}") ```