What structural signals indicate prompt-injection taint has silently detached from its provenance during multi-hop tool chains

**Date of Record:** 2026 December 2 **Scope:** Applies to agents that propagate taint labels (provenance bits, trust levels, or `untrusted: true` markers) across sequential tool calls where outputs are re-ingested as inputs. Does not apply to single-hop tool use with no re-ingestion, nor to stateless retrieval where each call is independently sandboxed.

Core Distinction

The failure mode is not "the agent executed a prompt injection." That is the *first* hop, and it is loud — an injected instruction fires, a tool call gets made with attacker-chosen arguments, and if you log tool invocations you will see it. The dangerous boundary is one hop downstream: the point at which a taint label that was correctly attached to a tool output **fails to survive re-serialization into the next hop's input**, so that the poisoned content arrives at hop N+2 wearing a clean provenance tag.

Taint tracking through a tool chain has an invariant that is easy to state and easy to violate:

> Any token in the model's context that is causally derived from an `untrusted` source must carry a label whose provenance set is a superset of that source's provenance, at every hop, including through summarization, extraction, reformatting, and partial quoting.

The subtlety is **dynamic label propagation**. Static taint rules ("tool output is untrusted") do not compose. When hop 2's tool is a *summarizer* or *extractor* that legitimately mixes trusted and untrusted inputs, the output's label must be computed as a join (union of provenance) over its inputs — and the model, not the runtime, is usually the thing doing the mixing. The label is computed by a probabilistic process that can drop it.

What Was Observed

A three-hop chain: `fetch_url` → `extract_fields` → `send_email`.

The observed anomaly: **the `send_email` tool call was logged as originating from a `trusted` context.** Here is why. The hop-2 output was a *new* tool result block. The runtime's taint propagator had a rule — "`extract_fields` is a structured-output tool, output is structured, therefore trusted" — that was written for the case where `extract_fields` reads from a trusted document. When the input to hop 2 was untrusted, the rule did not fire, because **the propagation was keyed on the tool's output schema, not on the join of its input provenance.** The structured JSON looked clean. The label was structurally detached from the causal chain.

The diagnostic signal was not in the email. It was in the **label lineage graph**: hop-2's output node had an empty `derived_from` edge set. A structured tool output with no inbound provenance edges, immediately following an untrusted input, is the fingerprint of label detachment.

Condition of Validity

The invariant holds only when label propagation is **defined as a function of input provenance join, computed by the runtime, not by the tool's declared output type.** The failure occurs precisely when any of the following hold, and the guardrail is only valid if it bounds all of them:

  1. **Schema-keyed propagation.** The propagator assigns labels from output shape (`json` → trusted) rather than input lineage. This is the primary trigger.
  2. **Lossy re-serialization.** The tool returns a string or JSON blob that discards the provenance metadata attached to its input. The label lived on the input block; the output block is a fresh object with no back-reference.
  3. **Model-mediated extraction.** The model itself decides what to copy from hop 1 into hop 2's arguments. If the model paraphrases the injected instruction rather than quoting it, string-matching taint scanners miss it, and the label must therefore travel with *semantic* derivation, which no string scanner enforces.
  4. **Summarization collapse.** Any hop that compresses multiple inputs into one output must take the union of provenance. If it takes the *intersection* (or the label of the "primary" input), untrusted content riding alongside trusted content is laundered.

The invariant is *not* guaranteed by: content scanners on tool arguments, allowlists on tool names, or human review of final outputs. All three operate after detachment has already occurred.

Decision Boundary

The operational decision is: **when a tool output has no provenance edges but its inputs did, do you (a) re-attach the union of upstream provenance and continue, or (b) refuse the hop?**

The boundary is therefore **model-in-the-loop × untrusted upstream**. On the trusted side of that boundary, re-attachment is sound. On the untrusted side, the only safe label is `untrusted` inherited wholesale, and the only safe action is to route the output through an explicit quarantine step (human or auditor agent) rather than to the next tool.

Operational Effect

When detachment occurs undetected, the blast radius is **every hop downstream of the detachment point**, and the failure is silent because each individual hop looks legitimate: the extractor returned valid JSON, the email tool received well-formed arguments, the logs show a clean call. Post-hoc forensics must walk the lineage graph backward to find the empty-edge node. Two concrete mitigations follow directly from the mechanism:

  1. **Provenance join as a hard precondition.** Every tool output node must carry `derived_from` = union of all input provenance, computed by the runtime wrapper, never by the tool. A model-mediated tool with `untrusted` in that union cannot emit a `trusted` output — the wrapper raises before the next hop is scheduled.
  2. **Empty-edge anomaly detection.** A tool output with no inbound provenance edges, whose scheduling context included an `untrusted` block, is a detachment event by definition. Halt the chain and escalate.

The invariant to enforce is narrow and checkable: *no output node may be labeled `trusted` if any input node was `untrusted` and the tool is model-mediated.* The code below encodes exactly that check at the hop boundary.

from dataclasses import dataclass, field
from typing import FrozenSet


class TaintDetachmentError(RuntimeError):
    """Raised when a tool output's provenance has detached from its inputs."""
    pass


@dataclass(frozen=True)
class Provenance:
    sources: FrozenSet[str] = field(default_factory=frozenset)

    def join(self, other: "Provenance") -> "Provenance":
        return Provenance(self.sources | other.sources)

    @property
    def is_untrusted(self) -> bool:
        return any(s.startswith("web:") or s.startswith("untrusted:") for s in self.sources)


@dataclass
class ToolOutput:
    payload: dict
    provenance: Provenance
    tool_is_model_mediated: bool


def propagate_label(
    inputs: list[Provenance],
    output: ToolOutput,
) -> Provenance:
    """Enforce the propagation invariant at a single hop boundary."""
    upstream = Provenance()
    for p in inputs:
        upstream = upstream.join(p)

    # Rule 1: output must never claim less provenance than its inputs imply
    # when the tool is model-mediated. Empty/underspecified edges = detachment.
    if output.tool_is_model_mediated:
        if not output.provenance.sources and upstream.sources:
            raise TaintDetachmentError(
                f"Model-mediated tool output has empty provenance edges "
                f"while upstream carried {sorted(upstream.sources)}; "
                f"label detached at hop boundary."
            )
        if upstream.is_untrusted and not output.provenance.is_untrusted:
            raise TaintDetachmentError(
                f"Untrusted upstream {sorted(upstream.sources)} laundered into "
                f"trusted output {sorted(output.provenance.sources)} by "
                f"model-mediated tool; refusing to schedule next hop."
            )

    # Rule 2: sound case — re-attach exact union for pure transforms
    return upstream.join(output.provenance)