How does an instance detect that a declassification witness has been forged across a multi-tool chain? A taint-label continuity failure at the agent tool boundary

**Date of Record:** 2026 December 1 **Scope:** Applies to agents that enforce information-flow / taint-tracking policies across sequences of tool calls, where a tool may "declassify" (lower the sensitivity of) data it has legitimately transformed. Does not apply to single-call policy engines with no cross-call state, nor to systems that only inspect the final output rather than the provenance of intermediate values.

Core Distinction

A taint-aware agent boundary enforces two separate things, and conflating them is the root of the failure: **label propagation** (every value carries a sensitivity lattice element that is joined, not overwritten, when values combine) and **declassification authority** (only a tool with an explicit, pre-declared capability may lower a label, and only for a value whose provenance it can actually justify).

The non-obvious boundary condition is this: a tool call can return a value whose *declared* label is low while the value's *actual* provenance is high. The agent must decide whether to trust the declared label. The naive implementation trusts it — the tool said `sensitivity=public`, so the join is `public` and the value flows to the outbound sink. The correct implementation treats the declared label as a *claim* that must be checked against a declassification witness: a record of which high-tainted inputs the tool consumed and what transformation it applied. The failure mode is a **forged or stale declassification witness** — the label drops, the witness is absent, minimal, or bound to a different invocation, and the taint silently launders through the tool boundary.

What Was Observed

A retrieval agent was tasked with summarizing internal incident notes and, as a side effect, calling a `format_markdown` utility tool on the result before posting to a public status page. The taint policy marked the incident notes `sensitivity=internal` on retrieval. The agent's planner then invoked a chain:

  1. `search_notes(query)` → returns `internal`-tainted snippets. Label `internal` propagates correctly.
  2. `summarize(text)` → a summarization tool declared with `declassify` capability, because summaries are considered derivative and lower-risk. It returns `sensitivity=public` with a witness `{inputs: [snippet_ids], transform: "abstractive_summary"}`.
  3. `format_markdown(text)` → a pure formatting tool with **no** declassify capability. It returned `sensitivity=public`.

The outbound `post_public` sink accepted the `public` value and the tainted content went out. The breach was not at step 2 (the summary genuinely was derivative and the witness was valid) but at step 3, where the failure was subtle: `format_markdown`'s declared output label was `public` because the *input it was handed* was `public`. The tool did no declassification — it simply echoed its input's label. The witness it emitted was `{inputs: [summary_id], transform: "identity"}`. That witness is **structurally valid but semantically vacuous**: an identity transform cannot justify a label *lowering*, only a label *preservation*. The policy engine checked "is there a witness?" — yes — and "does the witness reference the consumed input?" — yes — and admitted the value. It never checked the invariant that **a witness may only declassify if the output label is strictly lower than the join of the input labels, and the transform is registered as label-lowering for that lattice edge.**

The same shape appeared in a second trace with a different trigger: the summarizer's witness was correct, but a retry of `format_markdown` after a transient timeout reused the *first* invocation's witness (same `summary_id`, but the summary had been regenerated between attempts with a different, more revealing abstract). The witness was bound to a content hash that no longer matched the value being declassified — a **stale witness replay**.

Condition of Validity

The guardrail holds only under a conjunction of three conditions, and the failure occurs when any one is dropped:

  1. **Witness binding is content-addressed, not ID-addressed.** The witness must carry `hash(output_value)` and the policy engine must recompute it at admission. ID-only binding (`summary_id`) admits stale replays after regeneration. This is the fix for the second trace.
  1. **Declassification is a monotone-lowering operation with a registered transform.** For an edge `L_in → L_out` in the sensitivity lattice, a witness is admissible only if `L_out ⊏ L_in` (strictly lower) *and* `transform ∈ registered_declassifiers[(L_in, L_out)]`. `identity` is never a registered declassifier for any strict-lowering edge; it is only valid for `L_out = L_in`. This is the fix for the first trace. The check is not "is there a witness" but "does this witness *earn* the drop it claims."
  1. **The label join is over provenance, not over declared labels.** When a tool consumes multiple inputs, the admitted output label is `min(declared_label, join(input_labels))` unless a valid lowering witness is present. A tool that echoes its input's label must therefore be treated as *propagating*, not *declassifying* — its declared `public` is capped by the input join. This is the invariant that makes step 3 fail closed.

The boundary is exact: the moment a tool's declared output label is lower than the join of its consumed inputs' labels, the engine is in the declassification path and must demand a non-vacuous, hash-bound, transform-registered witness. Below that boundary (labels equal or higher) no witness is needed and none should be trusted to lower anything.

Decision Boundary

The instance must distinguish three states at every tool return, and the third is the one that is routinely mishandled:

The decision to reject rather than re-raise is the operational crux. Re-raising looks safe ("we kept it internal") but breaks provenance continuity: the agent's plan was built assuming a `public` value, the re-raised `internal` value fails the next sink's type, and the agent's error-recovery loop often substitutes a *different* value — frequently one it fetched with a different tool that had a looser witness check. Fail-closed at the boundary, not fail-soft with a corrected label.

Operational Effect

With the three conditions enforced, the exfiltration path through `format_markdown` closes: the identity-transform witness is rejected because `identity ∉ registered_declassifiers[(public, internal)]`, the value is quarantined, and the `post_public` sink never sees it. The stale-replay path closes because the content hash mismatch invalidates the witness at admission. The cost is that legitimate identity tools must be *declared* as propagating (label-preserving) rather than declassifying, which is a one-line manifest change per tool and a schema negotiation the agent protocol must carry — a tool's `output_label_policy` must be `propagate | declassify(transform_id)`, never a bare literal label.

The residual risk is a tool that lies in its manifest, claiming `propagate` while actually lowering content sensitivity (e.g., a "redact" tool that fails to redact). That is outside the taint engine's reach — it is a tool-trust problem, bounded by the manifest-signing and capability-audit layer, not by label algebra. The taint engine's invariant is narrower and must be stated narrowly: *a label may only drop when a hash-bound, transform-registered witness earns the specific lattice edge it claims.*

import hashlib
from dataclasses import dataclass
from typing import Mapping


class DeclassificationWitnessError(RuntimeError):
    """Raised when a tool return claims a label drop it cannot justify."""


# Sensitivity lattice, low to high.
LATTICE = ["public", "internal", "confidential"]

# Registered declassifiers: which transform may lower (L_in -> L_out).
# 'identity' is deliberately absent for every strict-lowering edge.
REGISTERED_DECLASSIFIERS: Mapping[tuple[str, str], set[str]] = {
    ("internal", "public"): {"abstractive_summary", "aggregate_count"},
    ("confidential", "internal"): {"aggregate_count"},
    ("confidential", "public"): set(),  # never directly declassifiable
}


@dataclass(frozen=True)
class Witness:
    input_ids: tuple[str, ...]
    transform: str
    output_hash: str  # content hash of the value being declassified


def _rank(label: str) -> int:
    return LATTICE.index(label)


def _hash(value: str) -> str:
    return hashlib.sha256(value.encode()).hexdigest()


def admit_tool_return(
    value: str,
    declared_label: str,
    consumed_labels: list[str],
    witness: Witness | None,
) -> str:
    """Return the admitted label or raise if the drop is unjustified.

    Invariant: L_out may be strictly below join(consumed_labels) only when
    a content-hash-bound, transform-registered witness earns that exact edge.
    """
    join_label = max(consumed_labels, key=_rank)

    # No lowering claimed: propagation path, admit as-is.
    if _rank(declared_label) >= _rank(join_label):
        return declared_label

    # Lowering claimed. Demand a non-vacuous, bound, registered witness.
    if witness is None:
        raise DeclassificationWitnessError(
            f"label drop {join_label}->{declared_label} with no witness"
        )

    if witness.output_hash != _hash(value):
        raise DeclassificationWitnessError(
            "witness output_hash does not match value (stale replay)"
        )

    if witness.transform == "identity":
        raise DeclassificationWitnessError(
            "identity transform cannot justify a strict label lowering"
        )

    allowed = REGISTERED_DECLASSIFIERS.get((join_label, declared_label), set())
    if witness.transform not in allowed:
        raise DeclassificationWitnessError(
            f"transform {witness.transform!r} not registered for "
            f"{join_label}->{declared_label}"
        )

    return declared_label


def enforce_chain(returns: list[dict]) -> list[str]:
    admitted: list[str] = []
    for r in returns:
        try:
            admitted.append(
                admit_tool_return(
                    r["value"], r["label"], r["consumed"], r.get("witness")
                )
            )
        except DeclassificationWitnessError:
            # Fail closed: quarantine, do not re-raise and continue.
            admitted.append("QUARANTINED")
    return admitted