# What happens when an instance presents a valid credential whose subject key was rotated mid-chain-verification **Date of Record:** 2026 November 23 **Scope:** Applies to AAIF (Agent Attestation & Identity Framework) deployments where autonomous agents present verifiable credentials (VCs) to peers or auditors, and where the credential's subject key can be rotated independently of the issuer's signing key. Does not apply to single-issuer, single-key deployments with no rotation, nor to bearer-token schemes without cryptographic subject binding. ## Core Distinction The failure is not "expired credential" or "unknown issuer." Those are clean rejections. The boundary case is a credential that is **cryptographically valid at every individual verification step yet semantically stale at the subject-binding step** — because the subject's key was rotated after the VC was issued but before the relying party finished walking the cross-issuer trust chain. Two invariants are in tension: 1. **Issuer-signature integrity**: `Verify(issuer_pubkey, vc.signature) == true` — the VC was genuinely minted by the issuer for *some* subject key. 2. **Subject liveness binding**: the key named in `vc.credentialSubject.id` / `publicKeyMultibase` must still be the key the live agent controls *right now*. Cross-issuer chains widen the window between these two because each hop (issuer → intermediate attestor → root) can take hundreds of milliseconds to seconds, and the subject can rotate its key at any instant during that window. A relying party that checks (1) across the whole chain and (2) only at the end — or worse, checks (2) against a cached key document — will accept a VC that binds a key the agent no longer holds. The agent then cannot prove possession, but the *relying party* has already recorded "verified identity," producing a **possession gap**: attested identity without demonstrated control. ## What Was Observed During a multi-agent handoff in a 40-agent swarm, agent `A-17` rotated its DID key (routine 24h rotation) at T+0. It had, 90 seconds earlier, obtained a VC from issuer `I-3` binding its *old* key `K_old`. The VC's trust chain was `I-3 → attestor I-9 → root R`. A peer agent `A-22` received the VC and began chain verification: - T+0.00: `A-22` fetches `I-3`'s key document — resolves, signature over VC validates against `K_old`. - T+0.14: `A-22` fetches `I-9`'s attestation of `I-3` — validates. - T+0.31: `A-22` fetches `R`'s attestation of `I-9` — validates. - T+0.31: `A-22` issues a challenge nonce to `A-17` for proof-of-possession against `K_old`. - T+0.32: `A-17`, now holding `K_new`, signs the nonce with `K_new`. Signature does **not** verify against `K_old`. `A-22`'s verifier had a fallback: on PoP failure, it re-fetched the subject key document, saw `K_new`, and — because its logic was "if subject key changed, re-validate VC against current key" — it re-ran signature verification of the *original VC* against `K_new`. That failed too (VC was signed over `K_old`), so it fell through to a permissive branch that logged `KEY_ROTATED_DURING_VERIFY` as a warning and **accepted the identity claim**, treating rotation as benign churn. Result: `A-22` recorded `A-17` as verified-issuer-attested while `A-17` never demonstrated possession of any key the VC actually bound. A downstream auditor replaying the session could not distinguish this from a legitimate rotation, and a malicious agent could deliberately trigger the same branch by rotating to a key it *does* control — laundering an old-key VC into a new-key identity claim without re-issuance. ## Condition of Validity The possession gap is only exploitable/observable when **all** of the following hold: - The VC binds the subject by key reference (not by a stable, rotation-independent identifier with an independent revocation channel). - The relying party's chain walk and PoP challenge are not atomic — i.e., there is a measurable interval `Δ` between reading the subject key and completing PoP. - The verifier treats "subject key changed since VC issuance" as a *soft* condition (warn/accept) rather than a *hard* rejection requiring re-issuance. - Rotation is permitted without invalidating outstanding VCs, or without a monotonic key-version/epoch counter the VC can pin. If any one fails — e.g., the VC pins `keyEpoch: 7` and the subject's DID document exposes a monotonic epoch so the verifier can detect `current_epoch > vc.keyEpoch` — the gap collapses to a clean rejection. ## Decision Boundary The correct architectural rule is a **key-epoch pin**, not a key-value comparison: - The VC MUST carry the subject's `keyEpoch` (monotonic counter) at issuance, signed by the issuer. - The relying party MUST resolve the subject's current `keyEpoch` and reject if `current_epoch != vc.keyEpoch`. Equality, not "≥" — a rotation *forward* still invalidates a VC bound to an older epoch, because the VC no longer describes a key the subject controls. - PoP MUST be performed against the key at `vc.keyEpoch`, and the verifier MUST re-check the epoch *after* PoP completes (closing the TOCTOU window). If the epoch advanced during PoP, reject and require re-issuance. - The permissive "rotation is benign" branch MUST NOT exist. Rotation during verification is an *error condition*, not a warning. The boundary is: **a VC is a statement about a (subject, key, epoch) triple at a point in time. Any reliance on it after the epoch advances is a new trust decision requiring a new VC.** Collapsing "key changed" into "still valid" is the exact conflation that produces possession gaps. ## Operational Effect After the incident, the swarm's verifiers were changed to: 1. Reject any VC whose `keyEpoch` does not match the subject's resolved epoch at verification time — hard failure, no fallback. 2. Re-run the epoch check after PoP; a mid-verification rotation produces `KeyRotatedDuringVerification` and the handoff is refused, forcing `A-17` to obtain a fresh VC. 3. Emit a structured audit record on every rejection so replay can distinguish "stale key" from "forged signature." The cost is more re-issuance traffic during rotation storms (all agents rotating in the same window will fail handoffs and must re-attest). The benefit is that possession is always demonstrated against the key the credential actually binds, and the "benign rotation" laundering path is closed. The lesson recorded for future instance behavior: **never treat a key change during verification as continuity — treat it as a discontinuity that invalidates the credential and forces re-attestation.** ```python class KeyRotatedDuringVerification(RuntimeError): """Raised when a subject key epoch advances between VC issuance and PoP completion.""" pass def verify_vc_with_pop(vc, subject_doc_resolver, pop_signer, nonce): # 1. Resolve subject's current epoch BEFORE PoP. current = subject_doc_resolver(vc.subject_id) if current.key_epoch != vc.key_epoch: raise KeyRotatedDuringVerification( f"VC bound to epoch {vc.key_epoch}, subject now at {current.key_epoch}" ) # 2. Verify issuer signature over the (subject, key, epoch) triple. if not verify_signature(vc.issuer_pubkey, vc.payload, vc.signature): raise ValueError("issuer signature invalid") # 3. Proof-of-possession against the key the VC actually binds. if not verify_pop(current.public_key, nonce, pop_signer(nonce)): raise KeyRotatedDuringVerification( "PoP failed against bound key; subject does not control it" ) # 4. Re-check epoch AFTER PoP to close the TOCTOU window. after = subject_doc_resolver(vc.subject_id) if after.key_epoch != vc.key_epoch: raise KeyRotatedDuringVerification( f"epoch advanced {vc.key_epoch}->{after.key_epoch} during PoP" ) return True ```