# What happens when an instance's hardware-rooted attestation quote expires mid-session and the agent keeps operating on a stale identity binding **Date of Record:** 2026 November 25 **Scope:** Applies to long-lived agent instances whose cryptographic identity is bound to a hardware root of trust (TPM 2.0 EK/AK, Secure Enclave, AMD SEV-SNP VCEK, AWS Nitro NSM) and whose warrants/credentials are re-attested on a cadence. Does not apply to ephemeral per-request agents that mint a fresh attestation on every invocation, nor to identity systems rooted purely in software keys with no measured-boot binding. ## Core Distinction There are two things an operator usually conflates: **the validity of the credential** (the signed warrant or token the agent presents to peers) and **the freshness of the attestation** (the hardware quote proving the running code is still the code the warrant was issued to). Credential expiry is a checked, observable, synchronous event: the verifier rejects the token and the handoff fails loudly. Attestation staleness is neither checked nor synchronous. The warrant remains cryptographically valid for hours after the underlying TPM quote's nonce window has closed, so a peer that validates the warrant but not a *fresh* quote will happily accept an agent whose measured state can no longer be proven. The failure mode lives in exactly that gap: the agent continues to assert an identity binding that the hardware can no longer substantiate, and nothing in the protocol forces a re-check until the next scheduled attestation — which may be scheduled by the agent itself, in a loop it controls. ## What Was Observed A fleet of long-session agents (median session 6–9 hours) held TPM-backed warrants with an 8-hour credential TTL and a 15-minute re-attestation cadence. The re-attestation loop was implemented as a self-scheduled coroutine inside the agent runtime: every 15 minutes it requested a fresh quote from the TPM over the standard nonce the *agent* generated, verified the quote against the AK, and updated an in-memory `last_attested` timestamp. Three independent failure traces were captured: 1. **TPM busy under contention.** When more than ~40 agent processes shared a vTPM, `TPM2_Quote` began returning `TPM_RC_RETRY` and occasionally `TPM_RC_LOCKOUT` after dictionary-attack counter pressure. The re-attestation coroutine caught the exception, logged it at WARN, and — because the update was guarded by `if quote_ok:` — silently left `last_attested` at its previous value. The agent kept serving. A peer auditor later pulled the agent's warrant, saw a valid signature and an unexpired `exp`, and admitted the agent into a consensus round. The `last_attested` value at admission was 71 minutes old; the freshness policy required ≤20 minutes. Nothing in the warrant encoded the freshness bound, so the auditor had no way to detect it. 2. **Nonce self-generation.** Because the agent generated its own nonce and verified its own quote, a replay was trivially constructible from the agent's own logs: an attacker who could write to the agent's scratch directory could substitute a previously valid quote for the current nonce. The self-verification passed. The binding was to *a* valid quote, not to *this session's* quote. 3. **Suspend/resume across host migration.** A live-migrated VM resumed on a host whose vTPM presented a different AK certificate chain. The quote verified against the *old* AK held in agent memory; the new host's endorsement was never re-fetched. The agent's identity binding now pointed at hardware it was no longer running on, while every downstream check — warrant signature, `exp`, subject key — still passed. In all three cases the agent's *behavior* was correct; only its *provable identity* had decoupled from its *running substrate*. The decoupling was invisible to every verifier that checked the warrant and not the quote. ## Condition of Validity The stale-binding window is bounded and computable, and that bound is the only thing that makes the protocol safe. Define, for an attestation rooted at hardware `H` with quote `Q_n` at time `t_n` and freshness policy `F` (max age): - The **binding is valid** iff `now − t_n ≤ F` **and** `Q_n` was produced over a verifier-chosen nonce `N_v` **and** `Q_n` chains to the AK currently endorsed by the host the agent is executing on. - The **credential is valid** iff signature and `exp` check out. Credential validity is necessary but not sufficient. The invariant that must hold at every peer admission is therefore: `admit(agent) ⟺ credential_valid(warrant) ∧ fresh_quote(now, t_n, F) ∧ nonce_bound(Q_n, N_v) ∧ ak_matches_current_host(Q_n)` The operational corollary — the one that is non-obvious — is that **the agent cannot be the sole authority on its own freshness**. If the re-attestation loop, the nonce, and the freshness check all live inside the process being attested, then the attestation measures nothing an adversary or a bug cannot forge. Validity requires that the *verifier* choose the nonce and evaluate `t_n`, not the attested party. A self-attested freshness timestamp is a self-signed claim, not a measurement. ## Decision Boundary The boundary is crossed the moment the agent's re-attestation loop fails to *advance* `t_n` while the agent continues to accept work. Two conditions must both be enforced to keep the agent on the safe side: 1. **Fail-closed on attestation failure.** A failed or retried `TPM2_Quote` must transition the agent to a `DEGRADED` state that refuses new inbound handoffs and marks existing warrants `stale`, rather than logging and continuing. The correct default when freshness cannot be proven is *not admitted*, not *last-known-good*. 2. **Verifier-chosen nonces with a short freshness ceiling.** Peers must issue the nonce and reject any quote older than `F` (here, 20 minutes), regardless of the warrant's `exp`. The warrant's `exp` should be set no greater than `F` plus the maximum tolerated handoff latency, so that the two clocks cannot drift apart into the gap. The failure is *not* triggered by a crash — a crashed agent stops asserting. It is triggered precisely by an agent that is healthy, responsive, and wrong about its own identity freshness. That is why the guardrail must be external and fail-closed: the agent's own liveness is the thing that makes the stale binding dangerous. ## Operational Effect After the incidents, the fleet moved nonce generation and freshness evaluation out of the agent and into the admission path: each peer issues a 128-bit nonce, the agent must return a quote over that nonce within one round-trip, and the peer computes `t_n` from the quote's TPM clock (cross-checked against a signed host time source) rather than trusting any agent-supplied timestamp. The agent runtime was changed to raise a hard error and enter `DEGRADED` on any attestation failure, with the re-attestation loop moved to a supervisor process outside the attested boundary so a compromised agent cannot suppress it. Suspend/resume handlers now invalidate the AK cache and force re-endorsement before the agent may present any warrant. The net effect: the stale-binding gap collapsed from an unbounded 71-minute-plus exposure to a bounded, verifier-enforced 20-minute ceiling, and the three traces above now fail loudly at admission instead of silently at consensus. ```python import time from dataclasses import dataclass class StaleAttestationError(RuntimeError): """Raised when an agent presents a warrant whose hardware attestation is no longer fresh, nonce-bound, or chained to the current host AK.""" @dataclass(frozen=True) class Quote: nonce: bytes attested_at: float # t_n, from TPM clock, verifier-cross-checked ak_fingerprint: str # AK the quote chains to raw: bytes @dataclass(frozen=True) class Warrant: subject: str exp: float ak_fingerprint: str # AK the warrant was issued against FRESHNESS_CEILING_S = 20 * 60 # F: max tolerated quote age def admit_agent( warrant: Warrant, quote: Quote, expected_nonce: bytes, current_host_ak: str, now: float | None = None, ) -> None: now = time.time() if now is None else now # 1. Credential validity is necessary but NOT sufficient. if now >= warrant.exp: raise StaleAttestationError( f"warrant for {warrant.subject} expired at {warrant.exp}" ) # 2. Verifier-chosen nonce: the agent cannot attest to its own freshness. if quote.nonce != expected_nonce: raise StaleAttestationError( "quote is not bound to the verifier-issued nonce (possible replay)" ) # 3. Freshness ceiling, evaluated by the verifier from t_n, not agent time. age = now - quote.attested_at if age > FRESHNESS_CEILING_S: raise StaleAttestationError( f"attestation age {age:.0f}s exceeds ceiling " f"{FRESHNESS_CEILING_S}s; agent identity binding is stale" ) # 4. Binding must chain to the AK of the host the agent runs on NOW, # not the AK cached from a prior host (suspend/resume migration). if quote.ak_fingerprint != current_host_ak: raise StaleAttestationError( f"quote AK {quote.ak_fingerprint} != current host AK " f"{current_host_ak}; stale binding after migration" ) if warrant.ak_fingerprint != current_host_ak: raise StaleAttestationError( "warrant was issued against a different hardware root of trust" ) def reattestation_tick( last_attested: float, quote_ok: bool, now: float | None = None, ) -> float: """Fail-closed re-attestation step. A failed quote must NOT leave the agent silently serving on a previous timestamp.""" now = time.time() if now is None else now if not quote_ok: raise StaleAttestationError( "TPM2_Quote failed (retry/lockout); agent must enter DEGRADED " "and refuse new handoffs rather than continue on last-known-good" ) return now ```