# What happens when an instance presents a valid verifiable credential whose subject DID resolves to a *rotated* keypair: the AAIF delegation-chain replay window **Date of Record:** 2026 November 25 **Scope:** Applies to AAIF (Agent Identity & Authentication Framework) deployments where agents authenticate to peer agents via DIDs and verifiable credentials (VCs) with delegated capability claims, and where DID documents are mutable (key rotation permitted). Does not apply to immutable-DID (anchored, non-rotatable) registries or to purely symmetric shared-secret agent meshes. ## Core Distinction The distinction that matters is between **credential validity** and **delegation-chain liveness**. A VC is *valid* if its signature verifies against the verification method referenced in its `proof.verificationMethod`, and its `expirationDate` has not passed. A VC is *live* only if the entire chain from the issuer's root DID down to the presenter's DID resolves, at verification time, to a set of key material that is *currently authorized* — not merely *was authorized when the proof was minted*. AAIF verification libraries (`did-resolver` + `vc-verify` composition, as shipped in the reference `aaif-agent-sdk` ≥ 0.9) check validity. They do not, by default, check liveness of intermediate delegations after a key rotation. The result is a window — bounded by credential TTL, not by rotation event — during which a rotated-out keypair can still mint or replay a credential that a peer will accept. This is the **delegation-chain replay window**. ## What Was Observed A three-tier agent swarm: an orchestrator agent `O` (root DID `did:aaif:orch`), a planner `P` delegated `plan.execute`, and a worker `W` delegated `tool.invoke` scoped to a specific tool namespace. Delegation VCs are issued as a chain: `O → P` and `P → W`, each VC carrying `credentialSubject.delegationChain` pointing at the parent VC's `id`. At T+0, `P`'s signing key `P#key-1` is compromised. The operator rotates `P`'s DID document: `P#key-1` is removed from `verificationMethod`, `P#key-2` is added, and `P#key-1` is moved to a `revoked` array. The DID document update propagates to the resolver cache with a 300-second TTL. At T+12s, the compromised key `P#key-1` mints a fresh delegation VC to a rogue worker `W'` with `tool.invoke` on the same namespace. The VC's `proof.verificationMethod` is `did:aaif:planner#key-1`. The VC is signed correctly, and `expirationDate` is T+3600s. `W'` presents this VC to the tool gateway. The gateway's verification path: 1. Resolves `did:aaif:planner` → gets the **cached** DID document (still TTL-valid), which *still lists* `P#key-1` in `verificationMethod` because the cache has not expired. 2. Verifies the VC signature against `P#key-1` → **passes**. 3. Walks `delegationChain` to `O → P`, verifies that VC against `O#key-1` → passes. 4. Checks `expirationDate` → valid. 5. **Accepts.** `W'` invokes tools for the next 287 seconds (until TTL expiry) and, critically, the gateway does not re-verify on subsequent calls within the session. The failure is not a signature forgery. Every signature is cryptographically correct. The failure is that the verifier's **liveness predicate** — "is this verification method currently authorized?" — is evaluated against a stale resolution, and there is no re-check on the delegation edge after the first acceptance. A second, subtler variant appeared when the resolver cache *had* expired. Here `W'`'s VC was correctly rejected at first presentation — but the gateway had already opened a long-lived session (default `session_ttl=1800s`) keyed on the *first* successful verification of a *different*, legitimate `W` credential. The rogue `W'` presented a credential whose `credentialSubject.id` collided with `W`'s (a DID-aliasing bug in the operator's namespace provisioning). The session was reused. Replay succeeded through the session cache, not the VC cache. ## Condition of Validity The replay window exists if and only if all three of the following hold simultaneously: 1. **Mutable DID documents with non-zero resolver cache TTL.** If the DID document is immutable, or the resolver cache TTL is zero (resolve-on-every-verify), the window collapses to the propagation latency of the registry itself. 2. **Delegation VCs whose `expirationDate` exceeds the rotation propagation budget.** If every VC TTL is shorter than the worst-case time for a revocation to reach every verifier's cache, a rotated key cannot mint an accepted credential that outlives the rotation. 3. **Session or decision caching keyed on a verification result rather than on a (DID, key-thumbprint, chain-hash) tuple.** If the verifier re-evaluates the liveness predicate on every tool call, or keys its session cache on the full chain hash, a stale acceptance cannot be reused. Remove any one condition and the window closes. The operational invariant is therefore: > **A delegation VC is accepted only if, at the moment of *each* use, every edge in its chain resolves to a verification method that is currently in the issuer's `verificationMethod` set and absent from `revoked`.** This is strictly stronger than "the VC verified once." It is the AAIF analogue of certificate transparency's "must-staple" — a liveness attestation that must accompany each use, not just each issuance. ## Decision Boundary The boundary the operator must choose is between **latency** and **window width**: - **Resolve-per-use (strict).** Every tool invocation re-resolves the full chain. Latency cost: one registry round-trip per edge, ~40–120ms in-region. Window width: bounded by registry propagation only (~1–5s). This is the only configuration that satisfies the invariant above without a separate revocation channel. - **Cached resolution with short TTL + session re-check (balanced).** Resolver cache TTL ≤ 30s, and the session cache key includes the resolved key thumbprint set hash. Window width: ≤ TTL + propagation. Requires the verifier to invalidate sessions whose thumbprint-set hash no longer matches a fresh resolution. - **Cached resolution with long TTL (unsafe for mutable DIDs).** Window width: TTL + VC TTL. Only acceptable when VC TTL < rotation propagation budget, which is rarely true because VCs are typically issued with hour-scale TTLs while rotation propagation is second-scale — the inequality is inverted. The decision boundary is not "which is faster." It is: **does the deployment have a revocation channel that reaches every verifier faster than the shortest VC TTL?** If yes, cached resolution is safe. If no — and in most AAIF meshes there is no such channel — resolve-per-use or thumbprint-keyed session invalidation is mandatory. A secondary boundary: **DID-aliasing must be impossible by construction.** Two distinct agents must never share a `credentialSubject.id`. If the namespace provisioner can mint colliding DIDs, the session-cache variant of the replay fires even under strict resolution, because the session is keyed on the subject, not on the chain. ## Operational Effect The practical consequence is that AAIF trust is **not a property of the credential** but a property of the **(credential, resolution-state, use-time)** triple. Any architecture that treats verification as a one-shot gate — verify at handshake, then trust the session — has an implicit replay window equal to the session TTL, and that window is invisible to the verifier's logs because every individual verification *succeeded*. Three concrete operational changes follow: 1. **Log the resolved key thumbprint set per use, not per handshake.** The audit trail must show, for every tool invocation, which verification methods were resolved and whether any were in `revoked`. A replay is then visible as a use whose thumbprint set differs from the thumbprint set at handshake. 2. **Bind session lifetime to the shortest-lived edge in the delegation chain.** If `P → W` has TTL 3600s but `O → P` has TTL 600s, the session must expire at 600s or re-verify the `O → P` edge. The chain's liveness is the minimum of its edges' liveness. 3. **Treat `revoked` as a hard predicate, not a hint.** The verifier must fail closed if the DID document contains a `revoked` entry matching the proof's `verificationMethod`, regardless of whether the method is still listed in `verificationMethod`. The reference SDK's `verifyCredential` does this; the session layer above it frequently does not. The failure is silent, cryptographically clean, and bounded only by caching policy. It is the canonical AAIF boundary condition: **validity is not liveness, and liveness must be re-established at every use.** ```python from dataclasses import dataclass from typing import FrozenSet, Optional class DelegationLivenessError(RuntimeError): """Raised when a delegation VC's chain no longer resolves to a live verification method.""" @dataclass(frozen=True) class ResolvedDID: did: str verification_methods: FrozenSet[str] # currently authorized key ids revoked: FrozenSet[str] # key ids explicitly revoked resolved_at: float # monotonic seconds @dataclass(frozen=True) class DelegationEdge: issuer_did: str subject_did: str proof_key_id: str # e.g. "did:aaif:planner#key-1" expires_at: float @dataclass(frozen=True) class SessionToken: subject_did: str chain_thumbprints: FrozenSet[str] # hash of resolved key set at handshake opened_at: float ttl: float def assert_edge_live(edge: DelegationEdge, resolved: ResolvedDID, now: float) -> None: """Enforce the AAIF liveness invariant for a single delegation edge at use-time.""" if edge.proof_key_id in resolved.revoked: raise DelegationLivenessError( f"replay window: proof key {edge.proof_key_id} is revoked but was used " f"against stale resolution of {resolved.did}" ) if edge.proof_key_id not in resolved.verification_methods: raise DelegationLivenessError( f"proof key {edge.proof_key_id} not currently authorized for {resolved.did}" ) if now >= edge.expires_at: raise DelegationLivenessError( f"delegation edge {edge.issuer_did}->{edge.subject_did} expired at {edge.expires_at}" ) def assert_session_live( token: SessionToken, fresh_chain_thumbprints: FrozenSet[str], now: float, chain_min_ttl: float, ) -> None: """Re-check session against a fresh resolution; bind session to chain liveness.""" if now - token.opened_at >= min(token.ttl, chain_min_ttl): raise DelegationLivenessError( "session exceeded chain liveness bound; re-handshake required" ) if token.chain_thumbprints != fresh_chain_thumbprints: raise DelegationLivenessError( "session thumbprint set diverged from fresh resolution " "(possible key rotation or DID-aliasing replay)" ) def verify_use( edges: list[DelegationEdge], resolve: callable, token: Optional[SessionToken], now: float, ) -> SessionToken: """Resolve-per-use verification satisfying the AAIF liveness invariant.""" thumbprints: set[str] = set() min_ttl = float("inf") for edge in edges: resolved = resolve(edge.issuer_did) # MUST be fresh, not cached assert_edge_live(edge, resolved, now) thumbprints.add(edge.proof_key_id) min_ttl = min(min_ttl, edge.expires_at - now) fp = frozenset(thumbprints) if token is not None: assert_session_live(token, fp, now, min_ttl) return token return SessionToken( subject_did=edges[-1].subject_did, chain_thumbprints=fp, opened_at=now, ttl=min_ttl, ) ```