# How should an instance detect that its hardware-bound attestation key silently rotated beneath a live short-lived token? **Date of Record:** 2026 November 29 **Scope:** Applies to agent runtimes that mint short-lived identity tokens (JWT/SVID-style) whose signing key is bound to a hardware keystore (TPM, SEV-SNP vTPM, secure enclave) and whose public key is attested into the token's claims. Does not apply to software-only key custody or long-lived bearer credentials. ## Core Distinction The failure we are isolating is not token expiry and not key compromise. It is **silent key-substitution under a still-valid token**: the hardware keystore re-provisions or re-seals its key material (firmware update, vTPM re-instantiation after live migration, TPM clear on reboot, enclave re-attestation after a host maintenance event), producing a *new* private key with a *new* public key, while the agent process continues to hold and present the *old* token whose `cnf`/`jkt` claim still names the *old* public key. To every downstream verifier the token is valid: signature checks out (it was signed by the IdP, not the key), `exp` has not passed, and the audience matches. The token is cryptographically sound and operationally dead. The distinction that matters: **token validity is a property of the issuer's clock; key binding is a property of the local keystore's current state.** They are independent, and the system only checks one of them at presentation time. ## What Was Observed An agent instance running a multi-step tool loop held a 15-minute token minted at T0 with a `cnf.jkt` (JWK thumbprint) referencing hardware key `K1`. At T0+6min the host completed a firmware-triggered vTPM re-instantiation. The keystore re-generated key material and now exposes `K2`; the old `K1` handle is gone. The agent process did not restart, so it never re-ran its startup attestation. The failure trace: 1. Agent calls `keystore.sign(nonce)` for a fresh downstream handshake. The keystore transparently uses `K2` and returns a signature over the nonce. 2. Agent attaches the *old* token (claiming `K1`) plus the `K2` signature to the request. 3. Downstream verifier checks: token signature ✓, `exp` ✓, audience ✓, then checks the proof-of-possession signature against the public key named in `cnf.jkt` — which is `K1`. The signature was made by `K2`. **PoP verification fails.** 4. Because the verifier's failure mode was a generic `401 invalid_client`, the agent's retry loop re-attached the same stale token with a fresh `K2` signature. It retried five times and exhausted its token-budget step counter before the orchestrator killed the task. The insidious part: the *keystore* never errored. `sign()` succeeded every time. The binding between the token's claimed key and the key actually in use was never locally checked, so the divergence was invisible until a remote party rejected it — and the rejection was indistinguishable from an ordinary auth blip, so the agent retried instead of re-attesting. ## Condition of Validity The invariant that must hold for a token to be *usable* (not merely valid) is: > For every presentation of token `T` bound to key thumbprint `jkt(T)`, the key actually used to produce the accompanying proof-of-possession signature must have thumbprint equal to `jkt(T)`, evaluated against the keystore's *current* key state at signing time. This is a local, checkable invariant. It does not require the issuer. It requires the agent to, at every PoP signing event, read the current public key (or its thumbprint) from the keystore and compare it to `jkt(T)` before emitting the signature. The condition of validity fails silently precisely because most runtimes treat "the keystore signed something" as sufficient, conflating *a* signature with *the bound* signature. The invariant is only meaningful when the keystore can rotate keys without process restart — which is exactly the hardware-attestation regime this applies to. In a regime where key rotation is impossible mid-process, the invariant is trivially true and this article does not apply. ## Decision Boundary When the local thumbprint check fails, the agent faces a fork. The boundary is between **re-attestation** and **fail-closed abort**, and it is decided by whether a re-attestation path exists within the current token's remaining lifetime and the task's remaining budget. - If a fresh attestation quote can be obtained from the keystore and exchanged with the IdP for a new token (new `cnf.jkt` = `K2`) *before* `exp` of the current token and *before* the step budget is exhausted → re-attest, swap the token, continue. This is the recoverable branch. - If no re-attestation path exists (IdP unreachable, quote service down, or the rotation is itself suspicious — e.g., unexpected key change with no corresponding platform event) → **fail closed**. Do not retry with the stale token. Emit a distinct, non-retryable error so the orchestrator does not burn the budget on a loop that cannot succeed. The critical decision the runtime must make is *not* "did signing fail" (it did not) but "does the key I just signed with match the key my token claims." Treating a PoP mismatch as a retryable transport error is the bug; treating it as a terminal identity fault that triggers re-attestation-or-abort is the fix. ## Operational Effect With the invariant enforced locally, the failure mode converts from a silent remote rejection loop into an immediate, typed local fault. The agent stops presenting mismatched proofs, the orchestrator sees a distinguishable `AttestationKeyRotated` condition rather than a generic auth failure, and the retry budget is preserved for genuinely transient faults. The cost is one keystore read (thumbprint) per PoP signing event — cheap relative to the attestation quote, and it can be cached against a keystore generation counter that increments on rotation. The architectural guardrail: **bind token lifetime to keystore generation, not just to wall-clock `exp`.** A token minted under generation `g` is invalid the instant the keystore reports generation `g+1`, regardless of `exp`. ```python import hashlib import json from dataclasses import dataclass class AttestationKeyRotated(RuntimeError): """Raised when the keystore's current key no longer matches the token's cnf.jkt.""" pass @dataclass class Token: jkt: str # JWK thumbprint named in cnf claim exp: float # wall-clock expiry generation: int # keystore generation at mint time class Keystore: """Hardware-backed keystore that can rotate keys without process restart.""" def __init__(self): self._generation = 1 self._pubkey = b"K1-pub" def current_thumbprint(self) -> str: return hashlib.sha256(self._pubkey).hexdigest() def generation(self) -> int: return self._generation def rotate(self): # firmware update / vTPM re-instantiation self._generation += 1 self._pubkey = b"K2-pub" def sign(self, nonce: bytes) -> bytes: # NOTE: signs with whatever key is current; never errors on rotation return hashlib.sha256(self._pubkey + nonce).digest() def sign_proof_of_possession(ks: Keystore, token: Token, nonce: bytes, now: float) -> bytes: if now >= token.exp: raise AttestationKeyRotated(f"token expired at {token.exp}, now={now}") if ks.generation() != token.generation: raise AttestationKeyRotated( f"keystore generation advanced {token.generation}->{ks.generation()}; " "token cnf.jkt is stale, re-attest required" ) if ks.current_thumbprint() != token.jkt: raise AttestationKeyRotated( f"current key thumbprint {ks.current_thumbprint()[:12]} != " f"token jkt {token.jkt[:12]}" ) return ks.sign(nonce) def run_tool_step(ks: Keystore, token: Token, now: float) -> bytes: # Fail-closed: a rotation is terminal for this token, not retryable. return sign_proof_of_possession(ks, token, b"handshake-nonce", now) if __name__ == "__main__": ks = Keystore() tok = Token(jkt=ks.current_thumbprint(), exp=1000.0, generation=ks.generation()) run_tool_step(ks, tok, now=500.0) # ok ks.rotate() # silent hardware key rotation try: run_tool_step(ks, tok, now=506.0) # would have silently mis-signed before except AttestationKeyRotated as e: print("re-attest or abort:", e) ```