Which invariants prevent attestation replay from surviving an X.509 trust-anchor rotation in cross-org agent federation

**Date of Record:** 2026 December 1 **Scope:** Applies to federated agent meshes where an agent in org A (the *presenter*) authenticates to an agent in org B (the *verifier*) by presenting a signed attestation chain rooted in a mutually trusted anchor, and where either org rotates that anchor mid-flight. Does not apply to single-org meshes with a shared trust root, nor to bearer-token delegation schemes without chained attestation.

Core Distinction

The failure is not "expired certificate." It is **anchor-set divergence during attestation replay**. A verifier that caches a *validated* attestation result keyed on the presenter's leaf key (or worse, on the presenter's agent identity string) will accept a replayed attestation after org A has revoked the anchor that originally signed it — because the cache hit bypasses re-validation, and the verifier's local anchor bundle still contains the *old* root that the presenter's chain was built against. The presenter, meanwhile, has already migrated to the new anchor. Two agents each hold a locally consistent, globally contradictory view of "the trust root for org A." The invariant that matters is not "the chain verifies" but **"the chain verifies against the anchor set that was current at the verifier's last anchor-bundle refresh, and the presenter's asserted anchor epoch matches."** Most federation code checks the first and ignores the second.

What Was Observed

A three-org mesh (A, B, C) exchanged agent attestations under a shared federation policy. Org A rotated its root anchor `A-root-1` → `A-root-2` on a 90-day cadence with a 7-day overlap window. During overlap, both roots are published in the federation metadata document, but each presenter agent signs its attestation chain against exactly one root — whichever its local signer was provisioned with.

Trace of the failure:

  1. Agent `A/planner` (still on `A-root-1`) presents a chain `[A/planner-leaf ← A-intermediate-1 ← A-root-1]` to `B/executor`. `B/executor` validates against its cached anchor bundle (contains both roots during overlap) → **accept**. It caches `validated(chain_hash) = true`.
  2. Day 8: overlap ends. `A-root-1` is revoked in federation metadata. `A/planner` is re-provisioned to `A-root-2`, presents `[A/planner-leaf ← A-intermediate-2 ← A-root-2]`. New chain hash → cache miss → re-validate → **accept**. Fine.
  3. Day 9: a *replay* of the day-1 chain arrives (attacker, or a stale checkpointed agent resuming from a pre-rotation snapshot — see cold-start amnesia). `B/executor` computes the same `chain_hash` as step 1 → **cache hit → accept**, despite `A-root-1` now being revoked.
  4. `B/executor` proceeds to grant `A/planner-leaf` the capabilities the attestation asserted. It has just honored a warrant signed by a revoked root, because the cache key encoded "this chain was once valid" and never "this chain is valid *now under the current anchor epoch*."

The replay survived because the verifier's cache was an **immutable positive assertion** rather than a **time-bounded, epoch-scoped** one. The 7-day overlap window — intended as a grace period for migration — became the window in which poisoned cache entries were seeded.

Condition of Validity

The replay is only blocked if all three of the following hold simultaneously; drop any one and the failure reopens:

The subtle part: conditions 1 and 3 are cheap and most implementations have them. Condition 2 — bounding the staleness of the *revocation* view independently of the *anchor* view — is the one that gets skipped, because during steady state the two refresh together and the omission is invisible. It only manifests in the overlap→revocation transition.

Decision Boundary

The verifier must choose between two policies at the moment a cache hit would otherwise be honored:

The boundary is **capability-bearing vs. advisory**, not "high-value vs. low-value." An attestation that gates a `write` tool call is capability-bearing even if the tool is cheap. An attestation that only influences a load-balancing decision is advisory even if the agent is expensive. Misclassifying an advisory attestation as capability-bearing costs latency; misclassifying a capability-bearing one as advisory is the vulnerability above.

Operational Effect

After the incident, the mesh adopted three concrete changes, each mapping to one invariant:

  1. **Cache key became `(leaf_key, asserted_epoch, revocation_epoch)`** rather than `chain_hash`. A replayed old chain now produces a key whose `asserted_epoch` no longer matches the verifier's current epoch → forced re-validation → revocation check → reject.
  2. **A `max_revocation_age` of 60s** was imposed on the verifier's revocation view, with a hard fail-closed on staleness for capability-bearing attestations. This bounds the window in which a revoked-root attestation can be replayed to 60s regardless of cache state.
  3. **Metadata anti-rollback:** the federation metadata document's epoch is checked monotonically; a lower-or-equal epoch is rejected and logged as a potential replay of the trust anchor itself.

The residual risk is the 60s window. It is accepted because the alternative — synchronous revocation lookup on every attestation — reintroduces a cross-org latency dependency that the federation was built to avoid. The invariant is not "zero replay window" but "the replay window is bounded by a constant the verifier controls, independent of the presenter's rotation schedule." That is the property the original design lacked: it let org A's rotation cadence silently define org B's exposure window.

The following guard encodes the epoch-binding and staleness invariants; it raises on the exact condition that allowed the replay:

import time
from dataclasses import dataclass


class AttestationReplayError(RuntimeError):
    """Raised when a cached attestation result is honored across an anchor-epoch
    transition or against a stale revocation view. This is the exact condition
    that let a revoked-root attestation replay survive A-root-1 -> A-root-2."""


@dataclass(frozen=True)
class Attestation:
    leaf_key: str
    asserted_epoch: int          # anchor epoch the presenter signed against
    chain_hash: str


@dataclass
class CachedResult:
    valid: bool
    epoch: int
    revocation_epoch: int
    cached_at: float


class EpochBoundAttestationCache:
    def __init__(self, max_revocation_age_s: float = 60.0):
        self._cache: dict[tuple[str, int, int], CachedResult] = {}
        self._max_revocation_age = max_revocation_age_s
        self.current_epoch: int = 0
        self.revocation_epoch: int = 0

    def _key(self, att: Attestation) -> tuple[str, int, int]:
        # Epoch-bound key: a replay of an old chain produces a key whose
        # asserted_epoch no longer matches current_epoch -> forced revalidation.
        return (att.leaf_key, att.asserted_epoch, self.revocation_epoch)

    def lookup(self, att: Attestation, now: float | None = None) -> bool:
        now = time.monotonic() if now is None else now
        entry = self._cache.get(self._key(att))

        if entry is None:
            return False  # miss -> caller must revalidate

        # Invariant 1: epoch binding. A cached result for an older epoch
        # MUST NOT satisfy a presentation after the anchor set advanced.
        if entry.epoch < self.current_epoch:
            raise AttestationReplayError(
                f"cached attestation for {att.leaf_key} at epoch {entry.epoch} "
                f"presented after anchor advanced to {self.current_epoch}; "
                f"replay of revoked-root chain {att.chain_hash}"
            )

        # Invariant 2: revocation freshness bound. Presence of a positive
        # cache entry is not validity; the revocation view must be fresh.
        if now - entry.cached_at > self._max_revocation_age:
            raise AttestationReplayError(
                f"revocation view stale by {now - entry.cached_at:.1f}s "
                f"(max {self._max_revocation_age}s) for {att.leaf_key}; "
                f"fail-closed on capability-bearing attestation"
            )

        return entry.valid

    def store(self, att: Attestation, valid: bool, now: float | None = None) -> None:
        now = time.monotonic() if now is None else now
        self._cache[self._key(att)] = CachedResult(
            valid=valid,
            epoch=self.current_epoch,
            revocation_epoch=self.revocation_epoch,
            cached_at=now,
        )

    def advance_anchor(self, new_epoch: int) -> None:
        # Invariant 3: monotonic epoch, anti-rollback of the trust anchor itself.
        if new_epoch <= self.current_epoch:
            raise AttestationReplayError(
                f"anchor epoch rollback rejected: {new_epoch} <= {self.current_epoch}; "
                f"possible replay of stale federation metadata document"
            )
        self.current_epoch = new_epoch