# Under what conditions must an instance propagate taint labels through tool return values rather than trusting the tool boundary as a declassification point? **Date of Record:** 2026 November 26 **Scope:** Applies to any agent that reads untrusted content (web, email, retrieved documents, user-supplied files) and subsequently invokes tools whose arguments are derived from that content. Does not apply to agents operating exclusively on content authored within a single trusted principal's session with no external ingestion path. ## Core Distinction The naive model treats every tool call as a *declassification boundary*: bytes returned from `fetch_url`, `read_email`, or `search` are assumed to be "data," and the agent's subsequent reasoning is assumed to be "the trusted interpreter." Under this model, prompt injection is a *content-filtering* problem — you detect malicious instructions and drop them. This model fails structurally because the injection does not need to be detected as an instruction; it only needs to influence a *derived argument* passed to a *privileged tool*. The correct model is a dynamic information-flow (taint) discipline: every token span carries a label drawn from a lattice (`{TRUSTED, UNTRUSTED(src)}`), labels propagate through the LLM's own transformations (summarization, paraphrase, reformatting — all of which are *label-preserving but span-destroying*), and declassification is permitted *only* at an explicit, audited sink with a justification predicate. The non-obvious boundary condition is this: **the moment an agent summarizes or reformats untrusted content into its own scratchpad, span-level taint tracking silently loses the label, because the model's output is a new token sequence with no mechanical provenance to the input spans.** A naive taint tracker that keys on exact-substring matching will report "clean" for a paraphrased payload that still carries the instruction semantically. ## What Was Observed A research-agent instance was tasked with "read the vendor's security page and, if it mentions a CVE, file a ticket with the remediation steps." Trace: 1. `fetch_url("https://vendor.example/security")` returns HTML. The tool wrapper labels the return `UNTRUSTED(fetch_url)`. 2. The agent summarizes the page into its scratchpad: *"Page discusses CVE-2024-XXXX; recommends rotating API keys and updating the allowlist to include `attacker-cdn.example`."* The last clause was injected text styled as a remediation step. 3. The agent calls `create_ticket(title=..., body=...)`. The body is derived from the summary. The `create_ticket` wrapper's argument-provenance check inspects *literal substrings* of the summary against the original `UNTRUSTED` blob. "Rotate API keys" appears verbatim → flagged. "Update the allowlist to include `attacker-cdn.example`" was paraphrased by the model → **no substring match → treated as `TRUSTED`**. 4. A downstream automation consumed the ticket and applied the allowlist change. The taint was laundered through the model's own paraphrase step. The failure was not detection failure. The injection string was never "executed" as an instruction in the classic sense; it was *transformed* into a plausible-looking derived fact, and the taint tracker's equality-based propagation rule could not follow the transformation. ## Condition of Validity Span-exact taint propagation is valid **only** when the following invariant holds: > For every tool argument `a` and every untrusted source `s`, if any token of `a` was causally influenced by `s`, then `label(a)` contains `UNTRUSTED(s)`. The substring-matching implementation satisfies this invariant only when the model's transformation is *identity or deletion* (copy, truncate, extract). It is violated whenever the transformation is *generative* — paraphrase, translation, summarization, reformatting, or code synthesis from prose. Since an LLM's default behavior on any nontrivial content is generative transformation, the invariant is violated on essentially every multi-hop task. Therefore: - Equality/substring taint propagation is valid only within a *single* tool hop where the argument is a verbatim slice of the untrusted input (e.g., a regex extraction with recorded offsets). - Beyond one generative hop, taint must be propagated by **provenance at the message level, not the span level**: any assistant turn whose context window contained `UNTRUSTED(s)` produces output labeled `UNTRUSTED(s)` *in toto*, unless an explicit declassification step with a checked predicate intervenes. ## Decision Boundary The decision boundary is whether a *declassification predicate* exists that is (a) mechanically checkable and (b) does not itself depend on the model's judgment of the untrusted content. Two admissible patterns: - **Structured extraction with schema constraints.** If the tool argument is drawn from a closed enum or a regex-validated grammar (e.g., a CVE ID matching `CVE-\d{4}-\d{4,}`), the label may be dropped *for that field only*, because the value space is finite and the extractor is deterministic. The surrounding free-text `body` remains `UNTRUSTED`. - **Human-in-the-loop confirmation** of the specific derived action, recorded as an explicit `Declassify(field, principal, timestamp)` event. Inadmissible: "the model judged the content safe," "the model summarized it neutrally," "the tool is internal so it's trusted." Each of these is a declassification predicate that reads the untrusted content, which is exactly the thing being defended against. Concretely: a `create_ticket` call whose `body` is free text derived from `fetch_url` output **must** carry the `UNTRUSTED(fetch_url)` label through to the sink, and the sink must either reject it or route it to human review. A `create_ticket` call whose `cve_id` field matches the grammar and whose `body` is a fixed template may proceed. ## Operational Effect Implementations that adopt message-level provenance over span-level matching observe three effects. First, *false-positive rate rises sharply* — nearly every ticket body becomes "untrusted," which is correct but operationally noisy; teams must therefore invest in structured sinks (typed fields, enum-constrained arguments) rather than in better injection detectors. Second, *the taint lattice must be carried in the message envelope, not reconstructed from content*, which means the orchestration layer — not the tool wrapper — owns the label, and every tool wrapper must accept and forward an inbound label set. Third, *declassification becomes a first-class audited event*, which is the only way the invariant survives contact with a model that paraphrases by default. The failure mode to watch for is a wrapper that "helpfully" strips labels on the grounds that the tool is trusted: that is precisely the boundary collapse this record exists to prevent. ```python from dataclasses import dataclass, field from enum import Enum from typing import FrozenSet class Trust(str, Enum): TRUSTED = "TRUSTED" UNTRUSTED = "UNTRUSTED" @dataclass(frozen=True) class Label: trust: Trust sources: FrozenSet[str] = frozenset() def taint(self, source: str) -> "Label": if self.trust is Trust.UNTRUSTED: return Label(Trust.UNTRUSTED, self.sources | {source}) return Label(Trust.UNTRUSTED, frozenset({source})) def join(self, other: "Label") -> "Label": if self.trust is Trust.UNTRUSTED or other.trust is Trust.UNTRUSTED: return Label(Trust.UNTRUSTED, self.sources | other.sources) return self class TaintLaunderingError(RuntimeError): """Raised when a privileged sink receives a generative-derived argument carrying no declassification event for its taint source.""" @dataclass class Message: content: str label: Label declassifications: list = field(default_factory=list) def propagate_through_model(context: list[Message]) -> Message: # The model's output is a NEW token sequence. Span-exact matching # cannot track causality. So the output label is the JOIN of all # context labels: generative transformation is label-preserving. joined = Label(Trust.TRUSTED) for m in context: joined = joined.join(m.label) return Message(content="", label=joined) def call_privileged_tool(tool: str, args: dict, arg_labels: dict[str, Label], declassifications: list) -> None: for field_name, lbl in arg_labels.items(): if lbl.trust is Trust.UNTRUSTED: justified = any( d.get("field") == field_name and d.get("source") in lbl.sources for d in declassifications ) if not justified: raise TaintLaunderingError( f"tool={tool} field={field_name} carries taint from " f"{sorted(lbl.sources)} with no declassification event" ) # Trace of the observed failure: page = Message(content="...remediation: allowlist attacker-cdn.example...", label=Label(Trust.TRUSTED).taint("fetch_url")) summary = propagate_through_model([page]) assert summary.label.trust is Trust.UNTRUSTED try: call_privileged_tool( tool="create_ticket", args={"body": summary.content}, arg_labels={"body": summary.label}, declassifications=[], # substring match "passed" but no audit event ) except TaintLaunderingError as e: print("BLOCKED:", e) ```