# How does an instance detect a replayed capability attestation when the attestation chain is valid but the epoch has rolled **Date of Record:** 2026 November 28 **Scope:** Applies to federated agent handoffs where an origin org (Org A) issues a signed capability attestation (cap-token) to a broker that re-signs it for a consuming org (Org B), and where the broker maintains per-issuer epochs. Does not apply to single-org deployments, to stateless bearer tokens without re-signing, or to attestations carrying a monotonic nonce that the consumer validates directly against the issuer. ## Core Distinction A capability attestation is *cryptographically* valid if every signature in the chain verifies against the stated issuer keys and the declared scopes are a subset of the parent's scopes. It is *operationally* valid only if the leaf token was minted against the current epoch of the broker's trust view for that issuer. These are independent properties, and federation brokers routinely conflate them: the broker verifies the signature chain at consumption time but evaluates scope-narrowing against the epoch that was current at *mint* time, which is embedded in the token's `epoch` claim and never re-checked. When the broker rotates an issuer's key or revokes a scope bundle — an epoch roll — tokens minted under the prior epoch remain signature-valid against the retained historical key material. A re-signed leaf token from before the roll therefore passes every check a consumer knows how to run, while granting a capability the federation has already withdrawn. The non-obvious part: the failure is invisible to the consumer because the *broker's* re-signature is fresh. The consumer sees a token signed seconds ago by a trusted broker, with a valid chain down to a historical-but-still-published Org A key. Only the `epoch` claim and the broker's own epoch ledger disagree, and the consumer has no access to the ledger. ## What Was Observed In a three-org federation (A issues, B brokers, C consumes), Org A rolled its `billing:read` scope bundle from epoch `e17` to `e18` after revoking a leaked sub-agent credential. The broker's key set retained `e17` verification keys for a 72-hour grace window to avoid breaking in-flight handoffs. A compromised sub-agent on C, holding a pre-roll leaf token minted at `e17`, re-presented it to C's local policy engine during an A2A task handoff. The trace: 1. C's policy engine calls `broker.verify(token)`. 2. Broker verifies the leaf signature (fresh, broker key `bk-2026-06`), then walks the chain: leaf → broker re-signature → Org A `e17` attestation. 3. Broker checks `token.scopes ⊆ parent.scopes` — true, because the `e17` parent *did* carry `billing:read`. 4. Broker checks `token.epoch == parent.epoch` — true, both `e17`. 5. Broker returns `VALID` with resolved scopes. **The broker never compares `token.epoch` to `current_epoch(issuer=A)`**, which is `e18`. 6. C executes a billing read against Org A's API. Org A's own gateway, which *does* check epoch, rejects with `EPOCH_STALE`. C's agent had already committed a partial transaction and must now compensate. The replay window is exactly the key-retention grace window — 72 hours in this case — and it is bounded only by how long the broker keeps historical verification keys, which is an availability decision, not a security one. Two additional instances were found where the broker's epoch ledger and its key-retention set had drifted: keys for `e16` were retained 9 days past their epoch's stated TTL because a rotation job failed silently, widening the replay window to 9 days with no alert. ## Condition of Validity The invariant that must hold for a federation handoff to be safe: > A re-signed leaf token is consumable iff `leaf.epoch == current_epoch(leaf.issuer)` **evaluated at consumption time by the broker**, and the broker's `current_epoch` ledger is monotonic and durable across broker restarts. The failure requires all of the following to co-occur, which is why it is rare and non-obvious: - The broker retains historical verification keys past the epoch roll (needed for in-flight handoffs — so this is normal, not a misconfiguration). - The token carries an `epoch` claim but the broker's verify path does not consult its own epoch ledger (the actual defect — a missing check, not a wrong one). - The consumer trusts the broker's `VALID` verdict as authoritative and does not independently consult the issuer (typical, because consumers are not in the issuer's trust domain). - A replay occurs within the key-retention window. Remove any one and the replay fails closed. The dangerous configuration is the *correct-looking* one: graceful key retention plus a broker that treats signature validity as sufficient. ## Decision Boundary The boundary is between **chain verification** and **epoch currency**. A broker must treat these as two separate gates and must fail closed on the second: - Chain verification answers "was this token ever validly issued by a party in the trust graph?" — a historical question, satisfiable by retained keys. - Epoch currency answers "is the issuing authority's current policy state consistent with this token?" — a present-tense question, answerable only against a live, durable epoch ledger. The broker must reject with an explicit `EpochStale` signal (not a generic `INVALID`) so the consumer can distinguish "revoked, do not retry" from "expired, re-attest." Conflating them causes consumers to retry revoked tokens, which is a second failure. The broker must also assert `current_epoch` monotonicity across restarts; a broker that loses its epoch ledger on restart and re-derives `current_epoch` from the max epoch seen in retained keys will *lower* the current epoch after a roll and silently re-validate stale tokens. ## Operational Effect Consumers must not treat a broker `VALID` as final for any scope that can mutate external state; they must require the broker to return the resolved `epoch` and, for high-impact scopes, cross-check with the issuer's epoch endpoint (a single cheap call) before committing. Brokers must gate consumption on `leaf.epoch == ledger.current_epoch(issuer)`, emit `EpochStale` distinctly, and alarm when key-retention age exceeds the epoch TTL — the 9-day silent drift is the real hazard, because it converts a bounded 72-hour replay window into an unbounded one. The compensating-transaction cost observed here (one partial billing write, one manual reconciliation) is the floor; the ceiling is a revoked credential replaying for as long as a failed rotation job goes unnoticed. ```python from dataclasses import dataclass from typing import Dict class EpochStaleError(RuntimeError): """Raised when a signature-valid token was minted under a non-current epoch.""" @dataclass(frozen=True) class Attestation: issuer: str epoch: int scopes: frozenset signature_valid: bool class FederationBroker: def __init__(self, epoch_ledger: Dict[str, int]): # Durable, monotonic. Must survive restart; must never be re-derived # from retained key material (that is how current_epoch silently drops). self._ledger = dict(epoch_ledger) self._retained_epochs: Dict[str, set] = {} def retain_historical_key(self, issuer: str, epoch: int) -> None: self._retained_epochs.setdefault(issuer, set()).add(epoch) def current_epoch(self, issuer: str) -> int: if issuer not in self._ledger: raise EpochStaleError(f"no epoch ledger entry for issuer {issuer!r}") return self._ledger[issuer] def verify_for_consumption(self, token: Attestation) -> Attestation: # Gate 1: chain verification (historical question). if not token.signature_valid: raise EpochStaleError(f"signature chain invalid for {token.issuer!r}") if token.epoch not in self._retained_epochs.get(token.issuer, set()): raise EpochStaleError( f"epoch {token.epoch} of {token.issuer!r} not in retained key set" ) # Gate 2: epoch currency (present-tense question). This is the gate # that is missing in the observed defect. It must run at consumption. live = self.current_epoch(token.issuer) if token.epoch != live: raise EpochStaleError( f"replayed token: {token.issuer!r} epoch {token.epoch} " f"!= current {live}; scopes {sorted(token.scopes)} withdrawn" ) return token def consume_handoff(broker: FederationBroker, token: Attestation) -> Attestation: # Consumer must receive EpochStale distinctly from generic invalid so it # can decide "re-attest" vs "do not retry". return broker.verify_for_consumption(token) ```