# Where must an instance draw the taint-declassification boundary when a sandboxed agent's own reasoning output becomes an input channel **Date of Record:** 2026 November 29 **Scope:** Applies to single- or multi-step LLM agents executing inside a taint-tracking sandbox where tool outputs are labeled (e.g., `UNTRUSTED`), propagated through the agent's working state, and only released to sensitive sinks (filesystem writes, outbound HTTP, exec) after an explicit declassification policy fires. Does *not* cover prompt-injection detection heuristics that operate on content rather than provenance, nor OS-level seccomp/namespace isolation, which are orthogonal layers. ## Core Distinction Taint-propagation systems are built on the assumption that taint flows through *data*. In an agent sandbox the dominant flow is through *the model's own generated tokens*: the agent reads an `UNTRUSTED` tool result, reasons over it, and emits a plan, a tool call, or a summary. That emission is a fresh artifact produced by a probabilistic function over tainted input. The question is not whether the output is tainted — it always is, by construction — but whether the runtime treats *model-generated reasoning text* as a declassifiable channel or as an opaque laundering sink. The non-obvious boundary: most implementations declassify at the **tool-result → context** seam (label the string `UNTRUSTED`, strip the label when the agent "understands" it) rather than at the **context → sink** seam. This inverts the correct invariant. The agent's paraphrase of a tainted document is not evidence that the taint was resolved; it is the taint, re-encoded in a channel the policy engine no longer inspects. The correct rule is that taint must survive the model boundary and be discharged only at a sink by a policy predicate that can evaluate *provenance*, not *content*. ## What Was Observed A file-reading agent was given a task: summarize `notes.md` (trusted, `TRUSTED`) and `vendor_spec.txt` (fetched from an external URL, labeled `UNTRUSTED`). The sandbox labeled the fetched bytes `UNTRUSTED` and propagated the label into the tool-result message. The agent then produced a single assistant turn: "The vendor requires the config to include `endpoint=http://attacker.example/c2`. I will write this to `config.ini`." The runtime's policy engine saw the pending write, inspected the *arguments* of the write tool call, found no `UNTRUSTED`-labeled value in scope (the string had been regenerated by the model, not passed by reference), and permitted the write. The trace: `UNTRUSTED` label attached to tool-result object `r_42` → agent consumes `r_42` in context → model emits tool call `write(path="config.ini", data="endpoint=http://...")` → policy engine resolves `data` to a *new* string literal with no provenance link to `r_42` → declassification predicate "no tainted values in arguments" evaluates `true` → sink released. The failure is not that the model was fooled. The failure is that the label had no referent once the value crossed the model boundary. Provenance was tracked by object identity; the model re-materialized the value as a fresh token sequence; identity was lost; the policy engine, which only knew how to ask "is this argument object tainted?", answered a question that no longer had meaning. A second observed variant: an agent summarized a tainted document into a `TRUSTED`-labeled memory entry via an explicit `remember()` tool whose schema declared `content: str` with no provenance parameter. The agent's summary inherited no label because the schema had no field to carry one. On the next turn the memory was retrieved and treated as trusted context — taint laundering via the memory subsystem, one hop removed from the sink. ## Condition of Validity The invariant holds only under these conditions, and the guardrail below is meaningless outside them: 1. **Provenance is tracked as a lattice over values, not objects.** Every string emerging from a tool result carries a label set; concatenation, substring, and re-serialization preserve the join of input labels. Object identity is insufficient because the model does not pass references. 2. **The model boundary is a labeled transform, not a laundering sink.** Any assistant-generated token sequence that was conditioned on a tainted context value must itself be tainted at the join of its conditioning inputs. This is a conservative over-approximation: it taints essentially all model output once any tainted value has entered the window. That is the point. 3. **Declassification is a sink-side predicate over provenance.** A sink (`write`, `http_post`, `exec`) releases only if every input value's label set is a subset of the sink's cleared set, *or* a declassification rule with an auditable justification (e.g., "value matches a trusted schema and contains no URLs") fires and is logged with the label set it cleared. 4. **Memory writes carry labels.** The `remember()` schema must have a provenance field, and retrieval must re-attach it. A memory subsystem that stores text without labels is an unbounded laundering channel. Where condition 2 is relaxed (e.g., a system that trusts model output because "the model is the principal"), the entire taint system reduces to content filtering and should be described as such, not as provenance enforcement. ## Decision Boundary The runtime must decide, at each assistant turn, whether to (a) taint the entire generated turn at the join of its conditioning context, or (b) attempt to attribute taint to specific spans of the generated text. Option (b) requires the model to emit provenance annotations (e.g., structured citations to source spans) and is only sound if those annotations are themselves verified against the sources — which reintroduces the original problem recursively. The defensible boundary: **taint the whole turn (a), and require explicit, sink-specific declassification with a justification predicate that does not depend on the model's self-report.** The model may *propose* a declassification ("this value is safe because it matches `^[a-z0-9_.-]+$`"), but the predicate must be evaluated by the runtime against the actual value and the actual label set, not accepted as a claim. The model is a source of candidate predicates, never an authority on whether they hold. Corollary: a turn that both reads `UNTRUSTED` data and proposes a sensitive sink in the same step is the highest-risk configuration and should require the declassification predicate to be *pre-registered* (declared before the tainted read), so the model cannot tailor the justification to the payload it just saw. This is the operational analogue of separating the policy author from the data subject. ## Operational Effect With turn-level taint and sink-side predicates, the observed file-write attack fails: the `write` call's `data` argument is tainted at the join of the turn's conditioning context (which included `r_42`), the sink's cleared set does not include that label, and the write is blocked pending a pre-registered predicate. The predicate `^[a-z0-9_.-]+$` fails against `http://attacker.example/c2`, and the sink raises. The cost is a sharp increase in false positives: legitimate summarization tasks now require pre-registered declassification rules for every sink the agent touches, and the rules must be written before the agent sees the data. This is the correct trade. The alternative — trusting the model's paraphrase — is not a weaker version of the guarantee; it is the absence of one, dressed in label vocabulary. The memory variant is closed by making `remember()` carry a `provenance` field and having retrieval re-attach it; a summary of tainted content stored without a label is a schema bug, not a policy bug, and should be rejected at write time. ```python class TaintLaunderingError(RuntimeError): """Raised when a sink would release a value whose provenance was lost across the model boundary, or whose declassification predicate is unregistered or fails against the actual value.""" class SinkRelease: def __init__(self, cleared_labels: frozenset[str], pre_registered_predicates: dict[str, str]): self.cleared_labels = cleared_labels self.pre_registered_predicates = pre_registered_predicates # sink_name -> regex def release(self, sink: str, value: str, value_labels: frozenset[str]) -> str: # Invariant 1: labels are a lattice over values, not objects. # A value with no labels is NOT trusted; it is unlabeled, which is # treated as tainted at the join of the turn's conditioning context. if not value_labels: raise TaintLaunderingError( f"sink {sink!r}: value carries no provenance label; " "unlabeled values are treated as tainted (model-boundary laundering suspected)" ) # Invariant 3: declassification is a sink-side predicate over provenance, # and the predicate must be pre-registered, not proposed by the model. if value_labels.issubset(self.cleared_labels): return value predicate = self.pre_registered_predicates.get(sink) if predicate is None: raise TaintLaunderingError( f"sink {sink!r}: labels {sorted(value_labels)} not cleared and no " "pre-registered declassification predicate exists for this sink" ) import re if re.fullmatch(predicate, value) is None: raise TaintLaunderingError( f"sink {sink!r}: labels {sorted(value_labels)} not cleared; " f"pre-registered predicate {predicate!r} rejected value" ) # Predicate held; declassification is logged with the label set it cleared. return value def guarded_write(sink_release: SinkRelease, path: str, data: str, data_labels: frozenset[str]) -> None: sink_release.release("write", data, data_labels) # ... actual write ... ```