# What happens when an instance resolves a peer's federated identity mid-key-rotation and replays a stale warrant across an AAIF/OIDC bridge **Date of Record:** 2026 November 25 **Scope:** Applies to autonomous agents that resolve peer identity across an Agent-to-Agent Identity Federation (AAIF) ↔ OIDC bridge, where the bridge caches OIDC `sub`/`azp` claims and signs AAIF warrants with a rotating bridge key. Does not apply to single-domain OIDC-only deployments, nor to sessions that resolve identity strictly per-request with no warrant caching. ## Core Distinction The failure is not "expired credential" or "signature mismatch." Those are loud and fail closed. The boundary failure here is a **silent identity substitution under rotation**: an agent presents a warrant signed by bridge key `K_n`, the bridge has already rotated to `K_{n+1}` and dropped `K_n` from its JWKS, but the *resolving* peer agent still holds a cached JWKS snapshot that includes `K_n` and — crucially — still maps the `kid` to the *old* `sub`↔`agent_id` binding. The signature verifies. The claim is well-formed. The identity is wrong. The invariant that breaks is: **key validity and identity-binding validity are not the same lifetime, but the bridge publishes them as if they were.** A JWKS rotation is treated as a cryptographic event; the identity binding it carries is a *semantic* event with a different (usually longer) expiry. When those two clocks diverge, replay protection keyed on `jti`/`iat` still passes while the underlying principal has been re-bound. ## What Was Observed A three-agent chain: `planner` (AAIF domain A) → `executor` (bridge domain) → `auditor` (OIDC domain C). The bridge rotates its signing key every 15 minutes and retains the prior key in JWKS for a 60-second grace window. The executor caches peer JWKS for 5 minutes (a reasonable default it inherited from a generic HTTP-cache config). Trace: 1. `t=0` — Executor resolves `planner`'s identity, fetches JWKS snapshot `S_0` containing `K_5`, and caches the `kid=K_5 → agent_id=planner@A:7f3a` binding alongside it. 2. `t=14:50` — Bridge rotates to `K_6`. The OIDC `sub` for the human operator backing `planner` was re-provisioned (account merge in domain C), so `K_6`'s warrant now binds `agent_id=planner@A:7f3a` to a *new* `sub`. The old `sub`'s delegation warrant is revoked. 3. `t=15:10` — Bridge drops `K_5` from JWKS. Grace window elapsed. 4. `t=15:40` — Executor receives a *replayed* warrant `W` signed by `K_5`, `jti` not seen before (attacker minted a fresh `jti` from a leaked-but-not-yet-rotated signing context, or from a compromised planner instance that captured `K_5` material before rotation). Executor checks: signature against cached `S_0` → valid; `exp` → still 4 minutes out; `jti` not in local replay set → pass; `kid=K_5` → maps to `planner@A:7f3a` → **authorized**. 5. The warrant was issued under the *pre-merge* identity binding. Executor acts on behalf of a principal that no longer exists in domain C. The auditor, resolving independently and with a fresh JWKS, rejects the downstream attestation — but only *after* the executor has already executed the tool call. The replay protection worked exactly as specified (no duplicate `jti`). The signature was cryptographically sound. The identity binding was stale by one rotation plus one account-merge, and nothing in the protocol surfaced that. ## Condition of Validity The failure requires all of the following to hold simultaneously: - The resolver caches JWKS **and** caches the `kid → agent_id → sub` binding in the same cache entry with the same TTL. (If the binding is re-resolved per-warrant via a `/userinfo`-style call, the merge is caught.) - The bridge's rotation cadence is **shorter** than the resolver's cache TTL. (If TTL < rotation period, the stale key is evicted before it can be abused.) - A semantic identity event (account merge, `sub` re-provisioning, delegation revocation) occurs **between** the resolver's last fetch and the key's removal from JWKS. This is the narrow but real window: the merge must land inside the cache lifetime, not before it. - Replay protection is keyed on `jti`/`iat` only, with no binding to `kid` or to a monotonic identity epoch. A fresh `jti` under a retired `kid` is invisible to it. Remove any one condition and the attack collapses. The dangerous region is specifically the overlap of a long binding TTL, a short rotation period, and a semantic event in between. ## Decision Boundary The resolver must decide, on every inbound warrant, whether the `kid` it verifies against is *authoritative for the identity it carries*. The correct boundary is not "is this key in my JWKS" but "**is this key still within its binding-epoch, and is that epoch the current one for this `agent_id`?**" Operationally: the bridge must publish an **identity epoch** (`epoch` claim, monotonically increasing per `agent_id`) alongside the `kid`, and the resolver must reject any warrant whose `epoch` is less than the highest `epoch` it has observed for that `agent_id` — regardless of whether the signature verifies against a cached key. This is a per-principal high-water mark, not a per-key check. It is the analogue of a sequence number in a stream: the key says *who signed*, the epoch says *which version of who*. The second boundary: JWKS cache TTL must be **strictly less than** the rotation period, and the binding cache must be **shorter than** the JWKS cache. Binding freshness is the tighter constraint because semantic events are rarer and more dangerous than key events. If you can only afford one cache, cache the key, never the binding. ## Operational Effect When this boundary is unguarded, the system exhibits **authorization that is locally consistent and globally wrong**: every individual check passes, the audit log shows a clean verification, and the compromise is only visible when a downstream auditor with fresh state disagrees. In a multi-agent swarm, this manifests as the classic "one agent thinks the handoff succeeded, the auditor rejects the attestation" split — except the split is not a bug in coordination, it is a *correct* auditor rejecting a *correctly-verified* stale principal. Debugging it as a coordination race wastes the incident. The guardrail is a two-part invariant enforced at the resolver: 1. **Epoch monotonicity per `agent_id`** — reject any warrant with `epoch < high_water_mark[agent_id]`, even if signature-valid. 2. **Cache ordering** — `ttl(binding) < ttl(jwks) < rotation_period`, with binding re-resolution forced on any `kid` not present in the *current* JWKS (not the cached one). The code below encodes the resolver with both guards and the specific exception raised when a signature-valid warrant is rejected for epoch regression — the case that would otherwise pass silently. ```python from dataclasses import dataclass, field from typing import Dict, Optional class StaleIdentityEpochError(RuntimeError): """Raised when a warrant is signature-valid but carries an identity epoch older than the resolver's high-water mark for that agent_id. This is the silent-substitution boundary: the key still verifies against a cached JWKS snapshot, but the identity binding it carries has been superseded by a rotation or a semantic re-provisioning event. """ @dataclass class Warrant: agent_id: str kid: str epoch: int # monotonic per agent_id, published by the bridge jti: str exp: int signature_valid: bool @dataclass class Resolver: # kid -> whether the key is in the *current* JWKS (not a cached snapshot) current_jwks: Dict[str, bool] # per-agent high-water mark for identity epoch epoch_hwm: Dict[str, int] = field(default_factory=dict) seen_jti: set = field(default_factory=set) def resolve(self, w: Warrant, now: int) -> str: if not w.signature_valid: raise StaleIdentityEpochError(f"bad signature for {w.jti}") # Guard 1: replay protection on jti (necessary, not sufficient) if w.jti in self.seen_jti: raise StaleIdentityEpochError(f"replayed jti {w.jti}") # Guard 2: the key must be in the CURRENT JWKS, not a cached snapshot. # A kid that verifies only against a stale snapshot is retired. if not self.current_jwks.get(w.kid, False): raise StaleIdentityEpochError( f"kid {w.kid} not in current JWKS; cached-snapshot verification is not authoritative" ) if w.exp <= now: raise StaleIdentityEpochError(f"warrant {w.jti} expired") # Guard 3: identity-epoch monotonicity. This is the invariant that # catches signature-valid-but-semantically-stale principals. hwm = self.epoch_hwm.get(w.agent_id, -1) if w.epoch < hwm: raise StaleIdentityEpochError( f"epoch regression for {w.agent_id}: warrant epoch {w.epoch} < hwm {hwm}" ) # Commit: only after all guards pass self.epoch_hwm[w.agent_id] = max(hwm, w.epoch) self.seen_jti.add(w.jti) return w.agent_id def handle_handoff(resolver: Resolver, w: Warrant, now: int) -> str: try: return resolver.resolve(w, now) except StaleIdentityEpochError as e: # Fail closed: do not execute the tool call, do not pass the baton. raise StaleIdentityEpochError( f"handoff rejected at identity boundary: {e}" ) from e ```