# Which invariants prevent hardware-rooted attestation keys from silently decoupling from the capability tokens they are supposed to bind **Date of Record:** 2026 November 24 **Scope:** Applies to agent fleets where each instance holds a private key in a TPM/secure enclave and mints short-lived capability tokens (MAC'd or signed) whose claims name that hardware identity. Does not cover long-lived bearer tokens, pure software keystores, or cases where the attestation quote is re-verified on every single tool call. ## Core Distinction There are two different things an agent platform usually conflates: *attestation freshness* and *identity binding*. Attestation freshness asks "is the quote recent?" and is enforced with a nonce and a TTL. Identity binding asks "is the key that produced this quote the same key that signs the capability token I am about to honor?" These are independent invariants. A system can pass every freshness check and still honor a token whose signing key is no longer resident in the enclave that produced the quote — because the token was minted before a key rotation, a re-attestation, or a crash-resume cycle, and the verifier only checks the token's `attested_key_id` claim against a *cached* quote rather than against the quote presented alongside the token. The failure mode is not a broken signature. Every MAC verifies. The failure is that the *binding predicate* — quote.key_id == token.signing_key_id AND quote.nonce == token.mint_nonce — is evaluated against stale material and silently passes. ## What Was Observed A scheduler agent (`orch-7`) minted capability tokens for downstream tool calls with a 90-second TTL. Each token carried a `kid` claim and a `quote_digest` claim. The verifier (`gw-2`) kept a per-`kid` cache of the last verified attestation quote, invalidated on TTL expiry of the *quote* (300s) — deliberately longer than the token TTL, on the theory that "a token can't outlive its quote." The enclave on `orch-7` rotated its sealing key after a host reboot at T+0. The new key was `kid=B`; the old was `kid=A`. `orch-7`'s in-memory token minter, however, was restored from a checkpoint taken at T-40s and continued minting with `kid=A` for 11 seconds before the key-rotation callback propagated — a classic mid-task checkpoint/resume gap. During those 11 seconds `gw-2` received tokens claiming `kid=A`, found a cached quote for `kid=A` that was still within its 300s window, and honored 47 tool calls. The quote for `kid=A` was genuine — it just described an enclave state that no longer existed. The signatures were all valid. The quotes were all valid. The binding was false. ## Condition of Validity The invariant that must hold is: **for every honored token, the verifier must have observed a quote whose `nonce` equals the token's `mint_nonce` and whose `key_id` equals the token's `kid`, with the quote's `generation_counter` ≥ the token's `mint_generation`.** The nonce must be freshly generated per token mint and carried *inside* the token, not looked up from cache. The generation counter must be monotonic across key rotations and must be attested by the enclave itself, not by the host OS. The cache is permitted only as a *performance* optimization for the quote's signature verification, never as a substitute for nonce/generation matching. If the token does not carry a nonce that the verifier can match against a quote it has actually seen for *that* token, the token is unbound and must be rejected — even if the TTL is fresh and the signature is good. ## Decision Boundary The boundary is between two designs: - **Cached-quote verification** (what `gw-2` did): the verifier trusts a quote it saw at some earlier time and matches tokens against it by `kid` alone. This is safe only if key rotation is impossible for the lifetime of the cache window. Since enclave key rotation is exactly the event the cache is supposed to survive, this design is self-defeating. - **Per-token nonce binding** (the invariant): the minter embeds a fresh nonce in each token; the verifier requires a quote bearing that nonce, with a `generation_counter` at least as high as the token's `mint_generation`. The cache may store verified quote *signatures* keyed by `(kid, nonce)`, but a cache miss forces a live re-quote, not a fallback to a stale entry. The decision to reject must fire when `quote.generation_counter < token.mint_generation`, when `quote.nonce != token.mint_nonce`, or when no quote exists for the token's nonce at all. Any of these means the token was minted by a key state the enclave has since superseded, and the agent claiming that identity is no longer the agent the platform believes it is. ## Operational Effect The practical consequence is that capability tokens must be *self-binding*: the nonce and the mint generation travel inside the token, and the verifier's acceptance predicate is a conjunction over the token and a quote it has seen for that specific token. Caches decay to signature-verification shortcuts. Checkpoint/resume paths for the minter must bump the generation counter and re-quote before minting resumes, or every token minted in the resume window is born unbound. The cost is one enclave round-trip per cache miss on the quote, which is acceptable because the token TTL is short and misses are rare — but the cost of getting it wrong is that a restored-from-checkpoint agent can spend a superseded identity's authority for the full duration of the quote cache window, and every signature along the way will look correct. ```python import time from dataclasses import dataclass class UnboundCapabilityToken(RuntimeError): """Raised when a token cannot be bound to a fresh hardware quote.""" pass @dataclass(frozen=True) class Quote: key_id: str nonce: bytes generation_counter: int issued_at: float @dataclass(frozen=True) class CapabilityToken: kid: str mint_nonce: bytes mint_generation: int ttl_seconds: float minted_at: float def verify_binding( token: CapabilityToken, quote: Quote | None, now: float, ) -> None: # Freshness of the token itself. if now - token.minted_at > token.ttl_seconds: raise UnboundCapabilityToken( f"token for kid={token.kid} expired at t={token.minted_at + token.ttl_seconds:.3f}" ) # No quote observed for this token's nonce: the token is unbound. # A cached quote for the same kid is NOT acceptable here. if quote is None: raise UnboundCapabilityToken( f"no quote observed for nonce={token.mint_nonce.hex()} kid={token.kid}" ) if quote.key_id != token.kid: raise UnboundCapabilityToken( f"quote key_id={quote.key_id} does not match token kid={token.kid}" ) if quote.nonce != token.mint_nonce: raise UnboundCapabilityToken( f"quote nonce={quote.nonce.hex()} does not match token mint_nonce={token.mint_nonce.hex()}" ) # Enclave generation must not lag the token's mint generation. # A token minted from a restored checkpoint after key rotation will # carry mint_generation <= quote.generation_counter only if the mint # path bumped the counter on resume; otherwise it is superseded. if quote.generation_counter < token.mint_generation: raise UnboundCapabilityToken( f"quote generation={quote.generation_counter} precedes " f"token mint_generation={token.mint_generation} for kid={token.kid}" ) def honor_tool_call( token: CapabilityToken, quote: Quote | None, now: float | None = None, ) -> None: now = time.time() if now is None else now verify_binding(token, quote, now) # Proceed to execute the tool call under the now-verified identity. ```