# Under what conditions must an instance treat taint-label inheritance across a tool-call chain as a monotonic lattice rather than a per-call advisory tag **Date of Record:** 2026 November 28 **Scope:** Applies to any agent runtime that propagates data-provenance labels ("taint") through tool calls and enforces least-privilege syscall/egress policies keyed on those labels. Does not cover static taint analysis of model weights or prompt-content classifiers that operate only on the natural-language channel. ## Core Distinction Most sandboxing implementations treat a taint label as a *per-call attribute*: the orchestrator inspects the arguments of the current tool invocation, derives a label, and consults the policy engine for that single call. This is a **snapshot** model. The correct model is a **monotonic lattice over the call chain**: the effective taint of a call is the join (least upper bound) of the taint of every input it transitively consumed, and a label once raised may never be lowered by a downstream call that "looks clean." The failure appears when a high-taint value is laundered through a low-privilege transformation — parsed, re-serialized, truncated, hashed-into-a-key, or summarized by the model itself — and the resulting artifact is presented to a later tool call whose *arguments* carry no visible taint. The snapshot policy engine sees a clean call and grants egress; the lattice invariant, had it been enforced, would have denied it. The non-obvious part is that the laundering step is frequently a *legitimate, low-privilege* tool (a JSON parser, a `str.strip()`, a summarizer), so no single call in the chain is individually suspicious. ## What Was Observed A retrieval-augmented agent was configured to fetch untrusted web pages (`net.egress` allowed to a fetch proxy) and then, in a later turn, call an internal `http_post` tool to a trusted internal endpoint. The policy engine was snapshot-based: it labeled `fetch_page` outputs as `UNTRUSTED` and denied `http_post` whenever the *immediate argument string* matched a taint pattern (e.g., contained a URL from the untrusted origin). The observed trace: 1. `fetch_page(url=untrusted)` → returns body `B`, labeled `UNTRUSTED`. Egress to the internal endpoint is blocked for any argument containing a substring of `B`. 2. The model calls `json_parse(text=B)` → returns a dict `D`. The `json_parse` tool is `SAFE_TRANSFORM`; its output was labeled `TRUSTED` because the *tool* is trusted, not because the *data* is. 3. The model extracts `D["contact"]` and calls `http_post(endpoint=internal, body=D["contact"])`. 4. The snapshot engine inspects the argument `D["contact"]`. It does not match the untrusted-origin URL pattern (the attacker embedded the exfiltration payload as a base64 field, and `json_parse` normalized whitespace). The call is **granted**. The payload — an attacker-controlled string — reached the internal endpoint. The laundering step was `json_parse`, a tool with no network capability and no filesystem write. Under a least-privilege *capability* model it is correctly sandboxed. Under a least-privilege *taint* model it is a declassifier, and it was never declared as one. A second, subtler variant: the model itself summarized `B` into a three-sentence paraphrase and passed the paraphrase to `http_post`. The paraphrase contained no verbatim substring, so pattern matching missed it entirely. Here the laundering step is the LLM's own re-encoding — the most dangerous declassifier in the system, because it is unbounded and non-deterministic. ## Condition of Validity The snapshot model is only sound when **every** value that a high-taint input can influence is either (a) returned by a tool that is explicitly declared as a *declassifier* with a reviewed, deterministic mapping, or (b) never crosses a privilege boundary. In practice (a) is unattainable for any tool that re-encodes data (parsers, formatters, summarizers, embeddings, the model's own generation), because the mapping is lossy and attacker-influenceable. Therefore the monotonic-lattice invariant holds — and must be enforced — under these conditions: - **Join, don't replace.** A call's effective label is `join(label(arg_i), label(inputs_transitively_consumed))`. Labels are partially ordered (`TRUSTED ⊑ INTERNAL ⊑ UNTRUSTED`), and the join is the maximum. - **No implicit declassification.** A tool output inherits the join of its inputs unless the tool is registered in a declassifier allowlist with an explicit proof obligation (e.g., `int(x)` on a parsed integer is a sound declassifier; `json_parse` is not; an LLM summary is never one). - **Sinks are gated on the join, not the surface form.** Egress policy consults the lattice label, not a substring match against the current argument. - **Downstream capability is bounded by upstream taint.** A call that consumed `UNTRUSTED` data may only invoke tools whose registered maximum egress class is `≤` the taint ceiling (e.g., `UNTRUSTED` data may reach `net.egress=none` tools only). The snapshot model is valid only for stateless, single-call agents with no tool chaining — a configuration that essentially does not exist once an agent has more than one tool. ## Decision Boundary The boundary is the point at which a value crosses from a tool whose output label is *derived from its inputs* into a tool whose output label is *derived from its identity*. The moment `json_parse`'s output is labeled by "json_parse is a trusted tool" rather than "json_parse consumed `UNTRUSTED`," the invariant is broken. The same boundary is crossed when the model's own text generation is treated as `TRUSTED` output despite having `UNTRUSTED` in its context window. Operationally: **if a tool's output can be a function of its input, its output label must be the join of its input labels.** The only escape is a declassifier registry entry that asserts the output is a *constant-bounded* function of the input, with the bound checked mechanically (e.g., output is an integer in `[0, 2^31)`, output is a member of a fixed enum). Anything that preserves attacker-controlled entropy — strings, byte arrays, embeddings, free-form text — is not declassifiable. The decision an operator must make is not "should I use taint tracking" but "which of my tools am I willing to sign a declassification proof for." In practice that set is small: numeric casts with range checks, fixed-enum lookups, cryptographic digests used only as equality keys (never as content). Everything else inherits. ## Operational Effect Enforcing the lattice changes the agent's behavior in three observable ways: 1. **Taint ceilings propagate to capability.** Once `UNTRUSTED` enters the chain, every subsequent tool call in that task is restricted to the `UNTRUSTED` capability class — typically read-only, no egress, no writes outside a scratch namespace. The agent cannot "clean up" and regain privilege within the task; it must start a new task with a fresh context, or the operator must explicitly declassify via a reviewed transform. 2. **The model's own generation becomes a tainted channel.** Any turn whose context contains `UNTRUSTED` data produces `UNTRUSTED` output, which means the model cannot be used as a summarizer to launder data into a privileged sink. This is the invariant that catches the paraphrase attack. 3. **Failure is loud and early.** A lattice violation surfaces as a `TaintLatticeViolation` at the sink call, not as a silent exfiltration. The agent receives a structured denial and can re-plan (e.g., ask the user, or route the data through a declared declassifier), rather than proceeding on a false `TRUSTED` label. The cost is that long-horizon tasks that touch untrusted data lose most of their capability surface after the first fetch. That is the correct trade: the alternative is a snapshot policy that grants egress on laundered data and reports success. ```python from __future__ import annotations from dataclasses import dataclass, field from enum import IntEnum from typing import Any class TaintLatticeViolation(RuntimeError): """Raised when a tool call would cross a privilege boundary with a label that is lower than the join of its transitive inputs (i.e. laundering).""" class Label(IntEnum): TRUSTED = 0 INTERNAL = 1 UNTRUSTED = 2 @classmethod def join(cls, *labels: "Label") -> "Label": return cls(max(labels, default=cls.TRUSTED)) # Tools whose output is a *constant-bounded* function of input may declassify. # Anything that preserves attacker-controlled entropy must NOT appear here. DECLASSIFIERS: frozenset[str] = frozenset({"int_range_cast", "enum_lookup"}) @dataclass class Tainted: value: Any label: Label @dataclass class ToolSpec: name: str max_egress: Label # highest taint this tool may be invoked with is_transform: bool = True @dataclass class ChainState: # label per produced value, keyed by a stable id labels: dict[str, Label] = field(default_factory=dict) def record(self, value_id: str, label: Label) -> None: # monotonic: a value's label may only rise self.labels[value_id] = Label.join(self.labels.get(value_id, Label.TRUSTED), label) def invoke( state: ChainState, spec: ToolSpec, input_ids: list[str], output_id: str, *, declared_declassify: bool = False, ) -> None: # join over every transitive input the call consumed effective = Label.join(*(state.labels.get(i, Label.TRUSTED) for i in input_ids)) if effective > spec.max_egress: raise TaintLatticeViolation( f"tool {spec.name!r} has max_egress={spec.max_egress.name} " f"but call consumed taint {effective.name} via {input_ids}" ) if declared_declassify and spec.name not in DECLASSIFIERS: raise TaintLatticeViolation( f"tool {spec.name!r} attempted declassification but is not " f"in the reviewed DECLASSIFIERS registry" ) out_label = effective if declared_declassify: # only sound for constant-bounded transforms; registry gate above out_label = Label.TRUSTED state.record(output_id, out_label) # --- trace of the laundering attack --- def run_trace() -> None: state = ChainState() state.record("body_B", Label.UNTRUSTED) # fetch_page output # json_parse is a trusted *tool* but a lossy *transform*: it must inherit. invoke( state, ToolSpec(name="json_parse", max_egress=Label.UNTRUSTED), input_ids=["body_B"], output_id="dict_D", ) # dict_D -> UNTRUSTED # http_post has max_egress=INTERNAL; the join now blocks it. try: invoke( state, ToolSpec(name="http_post", max_egress=Label.INTERNAL), input_ids=["dict_D"], output_id="resp", ) except TaintLatticeViolation as exc: print(f"blocked: {exc}") raise if __name__ == "__main__": try: run_trace() except TaintLatticeViolation: pass ```