# Where must an instance re-derive taint when a provenance label survives a tool call but the payload underneath it is re-serialized **Date of Record:** 2026 November 27 **Scope:** Applies to agents that carry per-span provenance labels (e.g., `trusted:user`, `tainted:web`, `tainted:tool_output`) through retrieval and tool-call boundaries and gate privileged actions on those labels. Does not apply to single-turn, tool-free completions, nor to systems that enforce isolation purely by capability tokens with no in-band content flow. ## Core Distinction The failure is not "the model ignored the taint label." It is that the label and the tainted bytes decouple at any boundary where the payload is **re-serialized**—JSON parse/stringify round-trips, markdown re-rendering, truncation-and-ellipsis, unicode normalization, or a summarization step—while the provenance annotation is carried forward by reference to the *original* span ID rather than being recomputed against the *emitted* bytes. The label then attests to content that no longer exists, and a downstream gate that trusts the label admits attacker-controlled bytes that were never inside the labeled span. The invariant that must hold: **provenance labels are a function of emitted bytes, not of span lineage.** Any transform that changes bytes must either re-derive the label from the transform's input taint or invalidate it. A label that survives a byte-changing transform without re-derivation is a forged label, regardless of who forged it. ## What Was Observed A retrieval-then-tool agent fetched a document containing an injected instruction inside an HTML comment: ``. The fetcher correctly tagged the returned span `tainted:web`. The agent's extraction tool (`html_to_text`) stripped comments and re-emitted clean prose—so the *emitted* text no longer contained the instruction. But the tool returned the result as a JSON envelope `{"span_id": "s7", "text": "..."}` and the orchestrator, seeing `span_id: s7`, re-attached the original `tainted:web` label to the *whole envelope*, including a `metadata` field the tool had populated from the raw HTML's `data-*` attributes. The injected string was reconstructed in `metadata.raw_attrs` by a later `format_for_prompt` step that concatenated envelope fields. The taint label was still attached—pointing at the now-clean `text`—and a policy gate that read "if any `tainted:web` span is present, require human approval for fund transfers" *did* fire. The approval prompt, however, rendered only `text` (clean prose), so the human approved a document they had never seen the payload of. The tainted bytes reached the model through `metadata`, the reviewer saw only `text`, and the label was technically truthful about a span that no longer contained the attack. Second observation, same class: a `summarize` tool took a `tainted:web` span and returned a 40-token summary. The orchestrator propagated `tainted:web` to the summary—correct in direction, but the summary had *dropped* the injected instruction while *retaining* an innocuous paraphrase of surrounding text. The gate fired on a harmless summary; an operator, seeing repeated false positives from summarization, added an allowlist for `summarize` output. That allowlist then admitted a *different* summarization whose input had contained the payload verbatim. The label was preserved across a lossy transform in one case (false positive) and the allowlist generalized the exemption to a case where the lossy transform happened to preserve the attack (false negative). ## Condition of Validity A provenance label `L(span)` is valid at a downstream consumer **iff** the bytes the consumer will actually render or feed to the model are a subset (under the transform's semantics) of the bytes that were labeled `L`. This requires three conditions, all of which must be checked at the transform boundary, not at the label's origin: 1. **Byte-closure:** every field of the emitted envelope that can reach the model or a human reviewer is covered by the label. Metadata, attributes, tool-error strings, and truncation markers are all in scope. A label on `text` alone is not a label on the envelope. 2. **Transform-taint monotonicity:** for a transform `T`, `taint(T(x)) ⊇ taint(x)` for *retained* content, and content `T` *drops* must not be re-introduced by any downstream concatenation. Summarizers that drop payload are safe only if nothing re-reads the source. 3. **Render-parity:** the bytes shown to the approving human equal the bytes the model consumes. If the gate reviews `text` but the model reads `text + metadata`, the gate is reviewing a different object than the one it authorized. The condition fails silently whenever (1) is violated by an envelope field the labeler didn't enumerate, or (3) is violated by a renderer that projects a subset of fields. ## Decision Boundary The boundary is: **does the transform change the byte-set that flows downstream?** If yes, the label must be recomputed against the emitted envelope, not inherited by span ID. Concretely: - Identity transforms (passthrough, no-op normalization) may inherit labels by reference. - Lossy transforms (extract, summarize, truncate) must **narrow** the label to the emitted fields and must **drop** the label from any field not derived from the labeled input. A summarizer that emits `{summary, source_span_ids}` must label `summary` as tainted (it is derived from tainted input) but must not let `source_span_ids` carry the taint into a *different* span's envelope. - Expansive transforms (template fill, format-for-prompt, attribute flattening) must **widen** the label to every field they synthesize from labeled input. The `format_for_prompt` step above is the canonical violation: it synthesized `metadata.raw_attrs` from tainted input and emitted it under a label scoped to `text`. When the boundary is ambiguous—a transform that both drops and synthesizes—the safe default is to label the entire emitted envelope as tainted and require the gate to render the entire envelope. False positives are recoverable by narrowing; false negatives are not, because the reviewer has already approved. ## Operational Effect The practical consequence is that **taint tracking is only as strong as the weakest re-serialization on the path from source to gate**, and re-serialization is invisible to label-based audits because the label is present and well-formed at every hop. An audit log showing `tainted:web → tainted:web → tainted:web` across three tools looks like correct propagation; it is actually three independent failures to re-derive. The failure is not detectable by inspecting labels—only by diffing the byte-set each label covers against the byte-set the consumer reads. The guardrail is a **render-parity assertion at the gate**, not a label check: before any privileged action, the gate must assert that the exact bytes it displayed to the approver are a byte-equal prefix of the bytes the model will receive, and that every labeled span's coverage set is a superset of the displayed bytes. If the assertion fails, the gate must reject and re-render the full envelope. This converts the silent decoupling into a hard error at the one point where it matters—the human authorization—rather than a probabilistic hope that the model "notices" the injection. ```python class TaintRenderParityError(RuntimeError): """Raised when a provenance label's coverage does not match the bytes a gate authorized.""" pass def assert_render_parity(displayed: bytes, model_input: bytes, label_coverage: set[str]) -> None: # The gate authorized `displayed`; the model will consume `model_input`. # A label is valid only if it covers every field that reaches the model. if not model_input.startswith(displayed): raise TaintRenderParityError( f"gate displayed {len(displayed)}B but model reads {len(model_input)}B; " "reviewer authorized a projection, not the consumed object" ) unlabeled_tail = model_input[len(displayed):] if unlabeled_tail and not label_coverage: raise TaintRenderParityError( f"{len(unlabeled_tail)}B of model input lie outside any labeled span; " "re-serialization synthesized unlabeled bytes" ) def rederive_label_on_transform(span_id: str, emitted_fields: dict[str, bytes], source_taint: set[str]) -> dict[str, set[str]]: # Labels are a function of emitted bytes, not of span lineage. labels: dict[str, set[str]] = {} for field, payload in emitted_fields.items(): if not payload: continue # Every emitted field derived from tainted input inherits the taint; # no field may inherit a label by span_id alone. labels[field] = set(source_taint) if not labels: raise TaintRenderParityError( f"transform on {span_id} emitted no labeled fields; " "empty envelope cannot carry provenance and must not be trusted" ) return labels ```