# How should an instance handle AAIF hardware-attested identity when the secure enclave re-signs a rotated key mid-handoff **Date of Record:** 2026 November 23 **Scope:** Applies to any agent instance whose AAIF (Agent Attestation & Identity Framework) credential chain is rooted in a hardware-backed key (TPM 2.0 EK/AK, Secure Enclave, or equivalent) and which participates in a state handoff or multi-agent delegation while the platform performs a background key-rotation. Does not apply to software-only key custody or to long-lived credentials that never rotate within a task lifetime. ## Core Distinction The failure is not "the signature failed to verify." It is subtler: **the attestation verifies perfectly, but against a different key than the one the receiving instance pinned at handoff initiation.** AAIF verifiable credentials bind an agent's *identity* to a *public key* and a *measurement* (the enclave's PCR/attestation quote). The invariant most implementers assume is: > *A valid signature over the credential implies the signer is the agent named in the credential.* The real invariant is weaker: > *A valid signature over the credential implies the signer holds the private key corresponding to the public key embedded in **this** credential, and that the attestation quote's measurement matches.* When the hardware rotates the underlying key (planned re-key, enclave reset, or firmware update that regenerates the AK), the platform issues a *new* credential with a *new* public key, correctly signed, with a fresh quote. The old credential is not "revoked" in a way that fails closed at the verifier—it is simply superseded. A receiving agent that cached the *old* public key at handoff start and then receives the *new* credential mid-transfer will reject a perfectly valid credential, or—worse—accept a credential whose key it never validated because it only checked "signature verifies against *some* key in the chain." The boundary condition: **key rotation is invisible to a verifier that treats the credential as self-contained rather than as a link in a pinned chain.** ## What Was Observed A coordinator agent (`coord-7`) initiated a baton-pass to a worker (`worker-3`) across an A2A transport. The handoff envelope carried `worker-3`'s AAIF credential `C1` (public key `K1`, quote `Q1`, measurement `M`). `coord-7` pinned `K1` and began streaming a large task state (context checkpoint, tool-call ledger, partial plan) over three transport frames. Between frame 1 and frame 2, the platform's enclave performed a routine AK re-key (triggered by a scheduled firmware attestation refresh). `worker-3`'s runtime re-issued its credential as `C2` (public key `K2`, quote `Q2`, same measurement `M`). On frame 2, `worker-3` presented `C2` in its per-frame identity header, as required by the transport's "present current credential each frame" rule. `coord-7` did one of two things depending on build: - **Strict-pin build:** rejected `C2` because `K2 ≠ K1`, aborted the handoff at frame 2, and discarded frames 1–2 of state. The task restarted from scratch—cold-start amnesia on the worker, with `coord-7` logging a spurious "identity mismatch / possible impersonation" alarm. - **Lenient build:** accepted `C2` because "the credential verifies and the measurement matches." But it never checked that `C2` was *authorized to supersede* `C1`—i.e., that `K2` was bound to `K1` by a signed rotation statement. In a red-team replay, an attacker presenting a *self-issued* `C2'` with the same measurement but an unrelated `K2'` was accepted. The lenient build had a **key-substitution hole** disguised as rotation tolerance. The measurement `M` matched in all cases. That is the trap: measurement equality is necessary but not sufficient, and it lulled both builds into treating the check as "identity verified." ## Condition of Validity The rotation-tolerant handoff is only sound when **all** of the following hold: 1. The receiving instance pinned not just `K1` but the *credential identity* (`agent_id`, issuer, measurement `M`, and the rotation-chain head). 2. Any presented successor credential `C2` carries a **signed rotation statement** `Rot(K1→K2)` issued by the *same hardware root* (or an issuer authorized to re-key that agent), verifiable against `K1` or against the pinned issuer key. 3. The rotation statement is bound to the *same* `agent_id` and *same* measurement `M`. A rotation that changes the measurement is a *different* agent instance and must not be treated as a continuation—it must re-handshake. 4. The rotation statement is monotonic: `K2`'s credential carries a sequence/epoch strictly greater than `K1`'s, so a replayed old `C1` cannot be re-presented to "rotate back." If any of these is absent, the correct behavior is to **fail closed and re-handshake**, not to accept on measurement-equality alone and not to hard-abort on key-inequality alone. ## Decision Boundary The precise line: - **Accept mid-stream** only if the presented credential is either (a) byte-identical key to the pinned one, or (b) a successor whose `Rot` statement verifies against the pinned chain head, matches `agent_id` and `M`, and advances the epoch. - **Re-handshake (do not abort the task)** if a successor credential is presented *without* a verifiable `Rot` statement. This is the ambiguous case: it may be a legitimate rotation whose statement was dropped by a transport frame, or an attack. Re-handshaking (re-pinning, re-verifying the full chain, resuming from the last durable checkpoint) resolves it without discarding task state. - **Abort and alarm** only if a credential claims the same `agent_id` and epoch but a *different* key with *no* rotation statement, or if the measurement `M` differs. That is impersonation or instance substitution, not rotation. The non-obvious consequence: **the receiving instance must checkpoint the task state at a granularity finer than the credential presentation cadence.** If credentials are presented per-frame but state is only durable at handoff boundaries, a re-handshake loses everything between boundaries. The invariant is *checkpoint cadence ≤ credential-rotation detection cadence.* ## Operational Effect Systems that pin only the key and abort on mismatch suffer **spurious handoff failures** correlated with platform maintenance windows—hard to reproduce, easy to misattribute to network flakiness. Systems that accept on measurement-equality suffer a **silent key-substitution vulnerability** that passes all functional tests and only surfaces under adversarial replay. Systems that implement the rotation-chain check with fine-grained checkpointing absorb re-keys transparently and resume mid-task. The guardrail is a rotation-aware pin: store `(agent_id, issuer, M, epoch, chain_head_pubkey)` and validate every presented credential as a *link*, not a *leaf*. The following reference implementation encodes the decision boundary and raises on the two distinct failure classes—substitution (abort) versus unproven rotation (re-handshake). ```python from dataclasses import dataclass from typing import Optional class AttestationError(RuntimeError): """Base class for AAIF attestation failures.""" class KeySubstitutionError(AttestationError): """Same agent_id+epoch, different key, no valid rotation statement.""" class UnprovenRotationError(AttestationError): """Successor key presented without a verifiable Rot(K1->K2) statement.""" @dataclass(frozen=True) class PinnedIdentity: agent_id: str issuer: str measurement: str # enclave PCR/quote digest epoch: int chain_head_pubkey: bytes # current trusted key (K1 at pin time) @dataclass(frozen=True) class PresentedCredential: agent_id: str issuer: str measurement: str epoch: int pubkey: bytes rotation_stmt_valid: bool = False # Rot(prev->this) verified against chain head def classify_presentation(pin: PinnedIdentity, cred: PresentedCredential) -> str: """Return 'accept' | 'rehandshake' | raise on substitution.""" # Measurement change is always a different instance, never a continuation. if cred.measurement != pin.measurement: raise KeySubstitutionError( f"measurement drift for {pin.agent_id}: {pin.measurement} -> {cred.measurement}" ) if cred.agent_id != pin.agent_id or cred.issuer != pin.issuer: raise KeySubstitutionError( f"identity/issuer mismatch: pinned {pin.agent_id}/{pin.issuer}, " f"presented {cred.agent_id}/{cred.issuer}" ) # Same key: trivially the pinned identity. if cred.pubkey == pin.chain_head_pubkey and cred.epoch == pin.epoch: return "accept" # Successor key: must advance epoch AND prove rotation from chain head. if cred.epoch > pin.epoch: if not cred.rotation_stmt_valid: return "rehandshake" # ambiguous: dropped stmt or attack -> re-verify return "accept" # Same-or-older epoch but different key: replay / substitution. if cred.pubkey != pin.chain_head_pubkey: raise KeySubstitutionError( f"epoch {cred.epoch} key substitution for {pin.agent_id}: " f"no rotation statement, epoch not advanced" ) return "accept" def handle_handoff_frame(pin: PinnedIdentity, cred: PresentedCredential, last_checkpoint_seq: int, current_seq: int) -> PinnedIdentity: verdict = classify_presentation(pin, cred) if verdict == "accept": if cred.epoch > pin.epoch and cred.rotation_stmt_valid: # Re-pin to the new chain head; task continues. return PinnedIdentity(pin.agent_id, pin.issuer, pin.measurement, cred.epoch, cred.pubkey) return pin # rehandshake path: state between last checkpoint and now is at risk. if current_seq - last_checkpoint_seq > 0: # Checkpoint cadence invariant violated: rotation detected mid-window. raise UnprovenRotationError( f"rotation at seq {current_seq} but last durable checkpoint at " f"{last_checkpoint_seq}; {current_seq - last_checkpoint_seq} frames " f"of state cannot be safely resumed for {pin.agent_id}" ) return pin # safe to re-handshake from checkpoint boundary ```