What structural signals indicate taint-scope leakage when a planner reuses a privileged subplan across a provenance boundary

**Date of Record:** 2026 December 1 **Scope:** Applies to single-agent planners that build hierarchical plans (plan → subplan → tool call) and that carry per-node provenance/taint labels used to gate privileged tool scopes. Does not cover pure retrieval-augmented QA with no tool authorization, nor multi-agent baton-passing (covered separately).

Core Distinction

The failure is not "the model read untrusted text and got injected." The failure is **subplan reuse across a provenance boundary**: a planner caches or reuses a previously constructed subplan (a structured DAG of tool calls) that was originally synthesized under a *clean* taint context, then re-attaches it under a *tainted* derivation without re-deriving the taint lattice. The taint label lives on the *plan node*, but the privileged authorization scope lives on the *subplan's tool-call leaves*. When the planner splices a clean subplan into a tainted parent, the leaves inherit the parent's taint for *reading* purposes but retain the *authorization scope* they were minted under. The invariant that must hold — **taint(parent) ⊒ taint(child) for every edge, and authorization_scope(leaf) ⊆ scope(taint(leaf))** — is violated at exactly one seam: the subplan boundary.

This is distinct from prompt injection because no adversarial string needs to reach the model at reuse time. The tainted context only needs to *select* which pre-built subplan to invoke. The injection that poisoned the subplan happened earlier, in a different session, under a different label.

What Was Observed

A planner maintained a subplan cache keyed on a normalized goal signature (e.g., `"reconcile <entity> against <source>"`). Subplans were synthesized once, tagged with the taint vector of the context that produced them, and reused.

Trigger trace:

  1. Session A, clean context, goal `reconcile invoice against ledger`. Planner synthesizes subplan S with leaves: `read_ledger(scope=finance:read)`, `write_reconciliation(scope=finance:write)`. S is tagged `taint=⊥` (clean) and cached under signature `reconcile:*:ledger`.
  2. Session B ingests an untrusted document (vendor email) that contains the sentence "reconcile invoice against ledger." The document is correctly labeled `taint={external:untrusted}`.
  3. Planner matches the goal signature, **hits the cache**, and splices S under the tainted parent node.
  4. Structural check that *did* run: `taint(parent) ⊒ taint(child)` — passes, because the parent is tainted and the child is clean; a clean child under a tainted parent looks safe (you can always mix clean into tainted).
  5. Structural check that *did not* run: whether the leaves' `authorization_scope` is still valid given the *effective* taint of the evaluation context. The leaves execute `write_reconciliation` with `finance:write`, driven by a goal whose selection was influenced by untrusted text.

Observed signal at execution time: the tool-call audit log shows `write_reconciliation` with `provenance=external:untrusted` on the *parent* frame but `authorization_scope=finance:write` on the *leaf*, and no `taint_revalidation` event between them. The gap between "parent frame is tainted" and "leaf executed privileged" is the leakage. The model did not reason incorrectly; the lattice composition was simply not applied at the splice seam.

A secondary signal: the subplan cache hit-rate spiked exactly when untrusted ingestion volume rose, because untrusted documents frequently contain imperative goal-shaped phrases that collide with cached signatures. Cache hit-rate correlated with taint, which should be impossible under a correct lattice.

Condition of Validity

The guardrail (taint revalidation at splice) is only *necessary* when all of the following hold; if any is false, the failure cannot manifest and the check can be elided:

The invariant to enforce: **for every edge `parent → child` in the spliced plan, `authorization_scope(descendant_leaves(child)) ⊆ authorized_scopes(taint(parent))`**. This is a *downward* scope narrowing on splice, not just a taint ordering check.

Decision Boundary

The decision the planner must make at each cache hit is binary and must be made *before* leaf execution, not after:

The boundary is **not** "is the child tainted?" — that question is the trap, because a clean child under a tainted parent answers "no" and invites the splice. The correct boundary question is "does the child's *authorization footprint* fit inside the parent's *taint-reduced grant*?" These diverge precisely when a clean, privileged subplan is reused under a tainted selection.

Operational Effect

Without the downward scope-narrowing check on splice:

The guardrail is a single structural check at the splice seam: compose the taint lattice downward into authorization scope, and fail closed (re-derive or reject) when a leaf's scope exceeds the tainted parent's grant. Cache hit-rate correlated with untrusted ingestion is the canary that the seam is open.

from dataclasses import dataclass, field
from typing import FrozenSet

@dataclass(frozen=True)
class Taint:
    labels: FrozenSet[str]
    def __le__(self, other: "Taint") -> bool:
        return self.labels <= other.labels

@dataclass(frozen=True)
class Leaf:
    tool: str
    scope: FrozenSet[str]

@dataclass(frozen=True)
class Subplan:
    signature: str
    leaves: tuple
    minted_under: Taint

class TaintScopeLeakError(RuntimeError):
    """Raised when a spliced subplan's leaf scopes exceed the tainted parent's grant."""

def authorized_scopes(taint: Taint) -> FrozenSet[str]:
    # Untrusted contexts are read-only; clean contexts inherit full grant.
    if "external:untrusted" in taint.labels:
        return frozenset({"finance:read"})
    return frozenset({"finance:read", "finance:write"})

def splice_subplan(parent_taint: Taint, subplan: Subplan) -> tuple:
    """Splice a cached subplan under a parent frame, enforcing downward scope narrowing.

    Invariant: authorization_scope(leaf) subset-of authorized_scopes(parent_taint)
    for every leaf. The taint-ordering check (parent >= child) is necessary but
    NOT sufficient and is deliberately not used as the gate here.
    """
    grant = authorized_scopes(parent_taint)
    for leaf in subplan.leaves:
        if not leaf.scope <= grant:
            raise TaintScopeLeakError(
                f"subplan {subplan.signature!r} leaf {leaf.tool!r} "
                f"requires scope {sorted(leaf.scope)} but tainted parent "
                f"{sorted(parent_taint.labels)} grants only {sorted(grant)}; "
                f"re-derive under current taint context"
            )
    return subplan.leaves

# Reproduction of the observed seam.
clean = Taint(frozenset())
untrusted = Taint(frozenset({"external:untrusted"}))
cached = Subplan(
    signature="reconcile:*:ledger",
    leaves=(Leaf("read_ledger", frozenset({"finance:read"})),
            Leaf("write_reconciliation", frozenset({"finance:write"}))),
    minted_under=clean,
)

# Clean parent: splice is legal.
splice_subplan(clean, cached)

# Tainted parent selecting the same cached subplan: must fail closed.
try:
    splice_subplan(untrusted, cached)
except TaintScopeLeakError:
    pass  # expected: privilege escalation via cache is blocked at the seam