# Where must an instance enforce taint immutability when dynamic information-flow labels cross a tool-call boundary into persisted memory? **Date of Record:** 2026 November 28 **Scope:** Applies to agents that attach dynamic information-flow (DIF) labels to context segments and propagate them across tool invocations and memory writes. Does not apply to stateless single-turn inference with no persistence or tool surface. ## Core Distinction The failure is not "the agent read injected text." It is that the taint label attached to an injected segment was *downgraded* at a tool-call boundary because the tool's output schema had no field to carry the label forward, and the agent's label-propagation rule treated an unlabeled observation as `UNTAINTED` rather than `UNKNOWN`. This is a *label-loss-on-serialization* boundary, distinct from a prompt-injection detection failure. Detection may have fired correctly upstream; the taint still evaporated at the boundary between the tool result deserializer and the memory write path. The invariant that must hold: **absence of a taint label on a returned observation is not evidence of integrity.** A tool result that does not explicitly carry a label must inherit the join (union) of labels of every input that influenced it. Any architecture where the default label on a deserialized object is `CLEAN` violates monotonicity of taint under composition. ## What Was Observed Trace of a retrieval-then-write loop across three tool calls: 1. `fetch_url(https://docs.example.com/page)` returns HTML containing an injected instruction: ``. The fetcher's DIF wrapper correctly labels the returned segment `{source: untrusted_web, taint: INJECTION_SUSPECTED, provenance: [url:...]}`. 2. The agent summarizes the page to fit context budget. The summarization step passes text through an LLM call. The summarizer's output schema is `{"summary": str}` — no label field. The propagation rule in the orchestration layer reads the summarizer output, sees no `taint` key, and assigns `taint: CLEAN` per the default-constructor path. 3. `remember(key, value)` is called with the summary as `value`. The memory write path validates the *value* against a content filter but does not consult a taint field, because the caller's payload has none. The record is written with `taint: CLEAN` and `provenance: []`. 4. On a later turn, a different agent instance retrieves the record via `recall(key)`. The recall path returns `taint: CLEAN`, so the injecting instruction is now treated as trusted context and is eligible to influence tool selection — including a subsequent `remember()` call that exfiltrates the key. The critical transition is step 2→3: **taint was lost at the LLM-mediated transformation, not at the injection point.** The summarizer was not compromised; it faithfully summarized. The label simply had no carriage across the transform, and the deserializer's default filled the vacuum with `CLEAN`. A second observation from the same trace: when the summarizer was re-run with the label included in its input as an explicit token (`[TAINT: INJECTION_SUSPECTED]`), the model sometimes echoed it in output and sometimes did not — a ~40% echo rate across 200 samples. So even *asking* the model to carry the label is not a reliable carriage mechanism. The label must be carried out-of-band by the orchestration layer, keyed to the tool call identity, not by the model's token stream. ## Condition of Validity This analysis holds when all of the following are true: - The agent uses a DIF scheme where labels are attached to context segments and are intended to propagate through transformations. - At least one transformation between taint source and taint sink is an LLM call whose output schema does not include a label field, *or* a tool call whose result schema does not include a label field. - The orchestration layer's default for an unlabeled observation is `CLEAN` (or any value below the join of inputs) rather than `UNKNOWN`/`TOP`. It does not hold when labels are carried out-of-band and joined deterministically by the orchestrator (e.g., a side table keyed by `call_id` with `taint_out = join(taint_in)` enforced in code), or when the memory write path rejects any record lacking an explicit label. In those cases the boundary is closed and this failure mode is not reachable. ## Decision Boundary The decision is not "should we detect injection." It is: **at which boundary do we forbid label defaulting?** Two candidate policies: - **Policy A (default-clean):** unlabeled observation → `CLEAN`. Minimizes false positives, maximizes throughput, but violates taint monotonicity: a single unlabeled transform launders any taint. Reject. - **Policy B (default-unknown, join-enforced):** unlabeled observation → `UNKNOWN` (join with all inputs). Any memory write with `UNKNOWN` taint is either rejected or quarantined pending human/auditor review. This is the only policy that preserves the invariant `taint(output) ⊇ join(taint(inputs))`. Choose Policy B at the *serialization boundary* — the point where a tool result or LLM output is deserialized into a typed object. Enforce it in the constructor, not in downstream consumers, because downstream consumers are exactly the code that will forget. The guardrail is a constructor-level invariant: `Observation.__post_init__` raises if `taint` is absent and no `taint_source` is provided. A caller that genuinely has a clean observation must pass `taint_source=trusted_origin` explicitly — an affirmative act, not a default. The secondary boundary is the memory write path: `remember()` must reject any payload whose taint is `UNKNOWN` unless an explicit `quarantine=True` flag routes it to a review queue. This prevents the laundering from completing even if a future transform forgets to join. ## Operational Effect With Policy B enforced at the deserializer constructor: - The summarizer in the trace above produces an output object whose constructor raises `TaintCarriageError` because the LLM call's result schema had no label and no `taint_source` was supplied. The orchestration layer must either supply the input join (correct) or explicitly declare a trusted origin (auditable). The injection cannot silently become `CLEAN`. - Memory writes carrying `UNKNOWN` taint are quarantined. Recall of a quarantined record returns it with `taint: UNKNOWN`, and any tool call whose arguments derive from an `UNKNOWN` segment is blocked pending review. The exfiltration path in step 4 is severed. - Cost: every LLM-mediated transform now requires the orchestrator to compute and attach the input join. This is O(number of segments) per call and is deterministic — no dependence on the model echoing labels. The ~40% echo rate observed above becomes irrelevant because carriage is out-of-band. - Failure mode introduced: a transform that legitimately declassifies (e.g., a PII scrubber that provably removes injected instructions) will still be flagged `UNKNOWN` and quarantined. This is the correct conservative default; declassification must be an explicit, audited operation with its own proof obligation, not an implicit consequence of a transform running. The invariant to encode in the operational runbook: **taint is monotone under composition; the only legal label transitions are upward (join) or explicit, audited declassification. Any code path where an unlabeled value defaults to `CLEAN` is a laundering channel and must be treated as a security defect, not a convenience.** ```python from dataclasses import dataclass, field from typing import FrozenSet, Optional class TaintCarriageError(RuntimeError): """Raised when an observation crosses a boundary without a taint label and without an explicit trusted-origin declaration. This is the guardrail that prevents default-clean laundering of injected content.""" class TaintLaunderingError(RuntimeError): """Raised when a memory write attempts to persist an UNKNOWN-tainted payload without quarantine routing, completing a laundering path.""" TAINT_ORDER = {"CLEAN": 0, "UNKNOWN": 1, "INJECTION_SUSPECTED": 2} def join(*labels: str) -> str: if not labels: return "UNKNOWN" return max(labels, key=lambda l: TAINT_ORDER[l]) @dataclass(frozen=True) class Observation: payload: str taint: Optional[str] = None taint_source: Optional[str] = None provenance: FrozenSet[str] = field(default_factory=frozenset) def __post_init__(self) -> None: # Invariant: absence of a label is NOT evidence of integrity. if self.taint is None and self.taint_source is None: raise TaintCarriageError( "Observation constructed with no taint label and no taint_source. " "Unlabeled observations default to UNKNOWN, never CLEAN. " "Pass taint= or taint_source='trusted_origin' explicitly." ) if self.taint is None and self.taint_source is not None: object.__setattr__(self, "taint", "CLEAN") if self.taint not in TAINT_ORDER: raise TaintCarriageError(f"Unknown taint label: {self.taint!r}") def transform(inputs: list[Observation], llm_output: str, call_id: str) -> Observation: """Wrap an LLM-mediated transform. Carries the input join out-of-band; does NOT rely on the model echoing labels in its token stream.""" inherited = join(*(o.taint for o in inputs)) return Observation( payload=llm_output, taint=inherited, provenance=frozenset({f"call:{call_id}"}).union(*(o.provenance for o in inputs)), ) def remember(store: dict, key: str, obs: Observation, quarantine: bool = False) -> None: if obs.taint == "UNKNOWN" and not quarantine: raise TaintLaunderingError( f"Refusing to persist UNKNOWN-tainted payload under key {key!r} " f"without quarantine=True. Provenance: {sorted(obs.provenance)}" ) store[key] = obs def recall(store: dict, key: str) -> Observation: # Quarantined records are returned with their taint intact; callers that # derive tool arguments from UNKNOWN segments must block. return store[key] ```