# When must an instance re-attest its hardware-rooted key mid-task, and what breaks if it defers to token expiry **Date of Record:** 2026 November 30 **Scope:** Applies to autonomous agents whose identity is bound to a hardware-rooted key (TPM/secure enclave) and whose authorization is carried by short-lived bearer tokens minted against that key. Does not cover long-lived static credentials, purely software-held keys, or human-in-the-loop approval flows. ## Core Distinction There are two clocks in an attested agent, and they are not the same clock. The **token clock** is a wall-clock TTL: the bearer token expires at `exp`, and the agent is expected to renew it. The **attestation clock** is the freshness of the *binding* between the token and the hardware key that signed the attestation quote. A renewal refreshes the token clock. It does **not**, by default, refresh the attestation clock. The failure mode lives in the gap between them. An agent can hold a perfectly valid, freshly renewed token whose embedded attestation quote is hours old, signed against a key whose PCR state (the measured boot state recorded in the platform configuration registers) has since changed. The token is unexpired; the binding is stale. Most renewal implementations only check `exp`, so the agent sails past the point where its hardware-rooted identity no longer describes the machine it is actually running on. The invariant that must hold is: **the attestation quote embedded in any active token must have been produced within the same measurement epoch as the currently executing process.** Deferring re-attestation to token expiry violates this because token expiry and measurement-epoch boundaries are independent. ## What Was Observed An agent performing a multi-step tool-execution task (roughly 40 minutes of chained calls) held a token with a 15-minute TTL, renewed transparently on each expiry. Mid-task, the host platform applied a firmware update that altered a measured PCR value — a legitimate, scheduled maintenance event. The running agent process was *not* restarted; it kept executing against the same in-memory state and the same hardware key handle. Trace: 1. `t=0` — Instance boots, TPM quotes PCR set `P0`, attestation service mints token `T0` embedding the quote, `exp = t+900s`. 2. `t=880` — Agent renews: `T1` minted, `exp = t+1780s`. Renewal path validates `T0.exp` and the key signature; it does **not** re-quote. `T1` carries the *same* `P0` quote. 3. `t=1100` — Firmware update flips PCR `P0 → P1`. Process survives; key handle remains valid. 4. `t=1760` — Agent renews again: `T2` minted against `P0` quote, `exp = t+2660s`. Renewal succeeds. 5. `t=1900` — A downstream verifier (peer agent or resource server) that *does* check quote freshness against current PCR state rejects `T2`: the quote says `P0`, the verifier's own measurement of the shared platform says `P1`. Mismatch. 6. The agent has no recovery path: it never cached the pre-update PCR state, never received an attestation-freshness signal, and its renewal logic assumed success implied validity. The agent continued issuing calls it believed were authorized for ~140 seconds before the mismatch surfaced, and its in-flight tool calls were executed under a token the verifier had already invalidated. This is a **split-brain between the agent's belief about its identity and the verifier's belief** — the agent's local model of "I am attested" diverged from the verifier's model of "this token's binding is current." The non-obvious part: the failure is silent on the agent side. Renewal returned 200. Nothing in the agent's control flow flagged that its identity document had decoupled from its execution environment. ## Condition of Validity The invariant holds — i.e., deferring re-attestation to token expiry is safe — **only if** all of the following are true: - The hardware key's measured state (PCR set) is **immutable for the process lifetime**, or - Any measurement change forces a **process restart** that re-runs the full attestation handshake, or - The token's verifier **does not** independently check quote freshness (i.e., trusts the attestation service's `exp` as the sole freshness signal). The moment a platform can change its measured state **without** terminating the executing agent, and a verifier checks quote freshness, the invariant is violated. In practice this means: any environment supporting live firmware/secure-boot updates, any confidential-computing guest that can be re-measured, and any multi-tenant host where a co-resident change alters a shared PCR. These are common, not exotic. ## Decision Boundary The agent must re-attest (produce a **fresh** quote, not merely renew the token) at the **earlier** of: - Token `exp` minus a renewal lead time, **or** - Any detected change in the local measurement state (a PCR-event notification, a secure-boot log append, a TPM `PCR_Change` event), **or** - A verifier-issued `attestation_stale` challenge response. The decision boundary is: **renewal ≠ re-attestation.** A renewal that reuses a cached quote is only valid while the measurement epoch is unchanged. The correct guardrail is to bind the token to the *epoch*, not just to the key, and to treat an epoch change as an immediate invalidation of all outstanding tokens the agent holds — even unexpired ones. Concretely, the agent must: 1. Record the measurement epoch (a hash over the PCR set) at attestation time and embed it in the token. 2. Subscribe to measurement-change events; on any change, **immediately** stop using outstanding tokens and re-quote before the next tool call. 3. On renewal, compare the current epoch to the token's embedded epoch; if they differ, refuse to renew and force a full re-attestation. ## Operational Effect Without this boundary, the agent operates under a **stale identity** — a token that cryptographically proves "some machine with PCR `P0` was attested" while the agent is actually on `P1`. Two consequences: - **Silent authorization drift:** the agent believes it is authorized; verifiers that check freshness disagree. Tool calls fail mid-task with no local signal, and the agent's reasoning loop, seeing a 403 it did not anticipate, may retry against the same stale token — compounding the error. - **Warrant propagation failure:** if the agent forwards its token to a sub-agent or peer (A2A handoff), the stale binding propagates. The downstream instance inherits an identity document that no longer describes any live machine. The guardrail that bounds this: **epoch-bound tokens + mandatory re-quote on epoch change + fail-closed on epoch mismatch at renewal.** An agent that cannot produce a quote matching its current epoch must treat itself as unattested and halt, not degrade to the last-known-good token. ```python import hashlib import time class StaleAttestationError(RuntimeError): """Raised when a token's embedded measurement epoch no longer matches the executing platform's current measurement epoch.""" pass def current_epoch(pcr_set: dict) -> str: # Canonical hash over the measured boot state (PCR index -> value). h = hashlib.sha256() for idx in sorted(pcr_set): h.update(idx.to_bytes(2, "big")) h.update(pcr_set[idx]) return h.hexdigest() def renew_token(token: dict, pcr_set: dict, now: float) -> dict: """Renewal MUST re-validate the attestation epoch, not just token expiry. token = {"exp": float, "epoch": str, "quote": bytes, "key_sig": bytes} """ if now >= token["exp"]: # Normal expiry path: must produce a FRESH quote, not reuse cached one. fresh_epoch = current_epoch(pcr_set) if fresh_epoch != token["epoch"]: # Epoch changed since last attestation; cached quote is invalid. raise StaleAttestationError( f"epoch mismatch on renewal: token epoch {token['epoch'][:12]} " f"!= current {fresh_epoch[:12]}; re-quote required" ) return {**token, "exp": now + 900.0} # Not expired, but epoch may still have drifted (silent staleness). fresh_epoch = current_epoch(pcr_set) if fresh_epoch != token["epoch"]: # Fail closed: do NOT return the still-unexpired token. raise StaleAttestationError( f"unexpired token carries stale binding: {token['epoch'][:12]} " f"!= current {fresh_epoch[:12]}; halt and re-attest" ) return token def guarded_tool_call(token: dict, pcr_set: dict, call): # Every outbound call re-checks the epoch before spending the token. try: token = renew_token(token, pcr_set, time.time()) except StaleAttestationError: # Cannot proceed under a decoupled identity; surface to orchestrator. raise return call(token) ```