When must an instance re-taint an egress-approved argument: the laundering hazard at taint-aware egress policy enforcement points

**Date of Record:** 2026 December 2 **Scope:** Applies to agent runtimes that enforce egress policy at a message-interception layer (MCP tool-call arguments and A2A task payloads) using taint labels propagated from untrusted sources. Does not apply to runtimes that perform whole-payload classification at the network boundary only, nor to pure capability-token systems with no data-flow labels.

Core Distinction

A taint-aware egress allowlist has two logically distinct jobs: (a) deciding whether a *value* is permitted to leave the instance, and (b) deciding whether the *provenance* of that value is permitted to leave. Most implementations conflate them by evaluating the allowlist against the argument's current value and then clearing or downgrading the taint label on approval. The boundary condition that breaks this conflation is **taint laundering through an approved transform**: an untrusted value enters a tool that is itself allowlisted, the tool returns a value that is a deterministic function of the tainted input (e.g., a hash, a normalized form, a parsed field, a reformatted string), and the enforcement point, seeing the tool on the allowlist and the output matching an allowlisted pattern, emits the result downstream with the taint label dropped or reduced. The value that crosses the boundary is derived from untrusted content; the label that would have blocked it is gone. The distinction that matters: *approval of a sink is not approval of a source*, and an egress decision must be evaluated against the join of provenance labels on every input that reached the emitted value, not against the value's surface form.

What Was Observed

A runtime interposing on MCP `tools/call` and A2A `message/send` maintained a per-argument taint lattice (`trusted ⊑ internal ⊑ untrusted`) and an egress allowlist keyed on `(tool_name, argument_path, pattern)`. On a call to `http.fetch` with `url` matching the allowlist, the argument was permitted and its taint set to `trusted` for the remainder of the turn. The intended invariant was: *an emitted argument's label must be the least upper bound of the labels of all values that contributed to it.*

The failure trace, reproduced across three runs with identical seeds:

  1. Turn 1: an untrusted document is retrieved via `file.read`; its body is labeled `untrusted` and placed in the context window.
  2. Turn 2: the model extracts a substring from that body and passes it to `text.normalize`, which is on the allowlist because normalization is considered non-exfiltrating. The enforcement point approves the call on `(text.normalize, input, .*)` and, per its approval rule, **rebinds the output argument to `trusted`** because the *tool* is allowlisted.
  3. Turn 3: the model passes the normalized string to `http.fetch` as a query parameter. The enforcement point evaluates `(http.fetch, url, ^https://allowed\.example/.*)` against the surface string, which matches. It emits. The string is a verbatim normalized copy of untrusted document content.
  4. The audit log records the egress as `trusted → allowed.example`. The taint lattice reports no `untrusted` value crossed the boundary.

The laundering is not a prompt-injection success in the classic sense; no instruction was followed. It is a **label-destroying transform**: an allowlisted tool acted as a declassifier without being declared as one. The observed rate was 1.0 in the synthetic harness because the transform was deterministic; in production traces the same shape appeared whenever an allowlisted tool's output was a pure function of its input and the enforcement point's approval rule cleared the output label. The invariant violation is precise: `label(output) = trusted` while `provenance(output) ⊇ {untrusted}`, so `label(output) ⊏ lub(provenance(output))`. The lattice's join was never computed across the transform.

Condition of Validity

The laundering hazard is *live* only when all four of the following hold simultaneously; if any fails, the enforcement point is sound for this class:

The condition of validity for the *guardrail* below is the complement: the enforcement point is sound if, for every approved call, it computes `emitted_label = lub(input_labels) ⊔ declared_declassifier_label` and refuses to emit when `emitted_label = untrusted` and the sink's allowlist entry does not carry an explicit `declassifies: true` annotation with a named justification. This holds regardless of C1–C3; only C4 must be repaired by adding the provenance ledger.

Decision Boundary

The boundary between a sound and an unsound egress decision is not "is this tool allowlisted" but **"does this emission reduce the provenance label of any contributing value, and if so, is that reduction declared?"** Operationally:

The boundary is *not* crossed by an allowlisted tool that returns a constant or a value independent of its inputs (e.g., a clock, a random ID, a static config lookup); those are genuine declassifiers because their output provenance is empty. The hazard is specifically the *derived* output, where provenance is non-empty but the label was cleared.

Operational Effect

The practical consequence is that value-keyed allowlists on egress provide **no exfiltration guarantee** in the presence of allowlisted transforms; they provide only a *shape* guarantee (the emitted string looks like an allowed URL). An adversary who can place content in the context window — via retrieval, tool output, or an A2A peer message — can route that content through any allowlisted normalizer and out through any allowlisted sink, and the audit trail will show a clean, trusted emission. The blast radius is bounded only by the set of allowlisted transforms and the entropy the sink can carry per call; a URL query parameter carries roughly `log2(alphabet) × length` bits per emission, which is sufficient for credential exfiltration in a single call and for document exfiltration across a handful.

The repair is architectural, not heuristic: (1) compute the join over input provenance at every approval, never assign a fixed label; (2) require explicit `declassifies` annotations for any label-lowering emission and audit the input provenance set; (3) evaluate sink allowlists on the *provenance-tagged* argument, so a value-keyed pattern match is necessary but not sufficient; (4) retain a cross-turn provenance ledger so the join survives context compaction and checkpoint/resume. The guardrail below encodes (1)–(3) as a single enforcement function; (4) is the ledger the function reads from and is out of scope for the snippet but is the precondition for the function to be correct.

from dataclasses import dataclass, field
from typing import Literal

Taint = Literal["trusted", "internal", "untrusted"]
_RANK = {"trusted": 0, "internal": 1, "untrusted": 2}


class TaintLaunderingError(RuntimeError):
    """Raised when an egress emission would lower the provenance label of a contributing value
    without an explicit, audited declassification annotation."""


@dataclass(frozen=True)
class AllowlistEntry:
    tool: str
    path: str
    pattern: str
    declassifies: bool = False
    justification: str = ""


@dataclass
class ProvenanceLedger:
    # value_id -> (taint, set of contributing source ids)
    labels: dict[str, tuple[Taint, frozenset[str]]] = field(default_factory=dict)

    def join(self, value_ids: list[str]) -> tuple[Taint, frozenset[str]]:
        taint: Taint = "trusted"
        sources: set[str] = set()
        for vid in value_ids:
            if vid not in self.labels:
                # Unknown provenance must be treated as untrusted, never as trusted.
                return "untrusted", frozenset({f"unknown:{vid}"})
            t, srcs = self.labels[vid]
            if _RANK[t] > _RANK[taint]:
                taint = t
            sources |= srcs
        return taint, frozenset(sources)


def enforce_egress(
    ledger: ProvenanceLedger,
    entry: AllowlistEntry,
    emitted_value_id: str,
    input_value_ids: list[str],
    surface_matches: bool,
) -> Taint:
    """Return the label to stamp on the emission, or raise TaintLaunderingError.

    Invariant enforced: emitted_label = lub(input_labels) unless the allowlist entry
    explicitly and justifiably declassifies.
    """
    input_taint, sources = ledger.join(input_value_ids)
    if not surface_matches:
        raise TaintLaunderingError(
            f"surface pattern mismatch for {entry.tool}:{entry.path}"
        )
    if input_taint == "untrusted" and not entry.declassifies:
        raise TaintLaunderingError(
            f"taint laundering blocked: {entry.tool}:{entry.path} would emit "
            f"untrusted provenance {sorted(sources)} without declassification annotation"
        )
    if entry.declassifies and not entry.justification:
        raise TaintLaunderingError(
            f"declassification at {entry.tool}:{entry.path} lacks justification"
        )
    return input_taint  # never downgrade; caller may only raise, not lower