# What happens when an instance resumes a TEE-attested agent session after a quote-expiry gap but before the enclave measurement has been re-verified **Date of Record:** 2026 November 21 **Scope:** Applies to agents whose tool sandboxes and model-inference calls are gated on hardware attestation quotes (SGX/SEV-SNP/TDX) with bounded validity windows. Does not cover long-lived sessions where attestation is re-verified per-call, nor non-attested sandboxes. ## Core Distinction There are two distinct notions of "the session is still trusted": *attestation freshness* (the signed quote that binds enclave measurement to a key is within its validity window) and *enclave liveness* (the enclave process that produced the original quote is still the one executing). A resumed agent session conflates these. The orchestrator checkpoints agent state (memory, tool-call ledger, pending warrants) outside the enclave, then on resume re-attaches to *an* enclave and re-verifies *a* quote. The failure is not that either check is wrong in isolation—it is that a resume can succeed against a *fresh quote from a different enclave instance* whose measurement matches the expected policy but whose in-enclave secrets (sealed keys, in-flight tool credentials) have been regenerated. The agent believes it is continuing; cryptographically it is a new principal that happens to satisfy the same policy predicate. ## What Was Observed A confidential agent ran a multi-step task: retrieve document via an attested tool sandbox, summarize with attested inference, then emit a signed action warrant. The host checkpointed state at step 2 (post-retrieval, pre-inference) and the enclave was reclaimed during a host maintenance window. On resume ~40 minutes later: 1. The stored attestation quote was past its `notAfter` (quotes are typically valid ~minutes to hours; `notAfter` had elapsed). 2. The orchestrator correctly rejected the stale quote and requested a fresh one. 3. A *new* enclave spun up, produced a fresh quote, and the measurement matched the expected `MRENCLAVE`/`MRTD` policy. Verification passed. 4. The agent resumed with its checkpointed state and called the inference tool, which required an in-enclave signing key derived from a sealing key bound to the *original* enclave's key-derivation material. 5. The signing key differed. The warrant signature verified against the new enclave's key, but the tool sandbox's prior grant (issued to the old enclave's public key) no longer authorized the call—yet the *policy check* passed because it only validated measurement, not key continuity. The observable symptom: the agent's tool call returned success for the inference step but the downstream warrant failed verification at the auditor, because the auditor pinned the *original* session's signing key from the first quote. Two valid attestations, one broken continuity chain. ## Condition of Validity The invariant that must hold is: **a resumed session is only equivalent to the original if the resumed enclave can prove possession of the same sealing/identity key material, not merely the same measurement.** This holds only when one of: - The sealing key is persisted in a hardware-sealed blob that the *new* enclave can unseal (requires the sealing policy to be bound to the same `MRENCLAVE` *and* the same sealing-key derivation inputs, e.g., a stable `MRSIGNER`-based derivation, not a per-instance random key). - The session identity is re-established explicitly: the agent re-runs the full attestation-and-key-exchange handshake with every downstream party, invalidating prior warrants and re-issuing them under the new key. If neither holds, the resumed session is a *different principal* wearing the same policy label. The condition of validity is therefore: **measurement equality is necessary but not sufficient; key-continuity (or explicit re-identification) is required.** ## Decision Boundary The decision boundary is whether the resume path treats the fresh quote as (a) proof of *continuation* or (b) proof of *a new, policy-compliant principal*. The correct boundary: - If the checkpointed state contains no in-enclave secrets and no downstream grants are pinned to the old key → treat fresh quote as continuation; safe. - If checkpointed state contains sealed secrets, or any external party pinned the old session's public key, or warrants were issued referencing the old enclave identity → treat fresh quote as a *new principal*; the agent MUST re-handshake and re-issue, and MUST NOT silently reuse the old ledger. The dangerous region is the middle: state that *looks* portable (summaries, tool outputs) but is entangled with a key the new enclave does not possess. The boundary must be drawn at the *key*, not at the *measurement*. ## Operational Effect Without this boundary, three concrete failures occur: (1) **silent principal substitution**—warrants and grants issued to the old enclave are accepted under the new one, breaking the audit chain; (2) **sealed-secret orphaning**—the resumed enclave cannot unseal prior secrets, and any fallback to plaintext or re-derivation produces divergent keys that downstream verifiers reject non-deterministically; (3) **replay divergence**—an auditor replaying the session sees a measurement-valid but key-invalid trail, and consensus between the agent and auditor splits on whether the session "succeeded." The guardrail: on every resume, compare the resumed enclave's identity key against the checkpoint's pinned key; if they differ, force a re-identification epoch and invalidate all prior warrants before proceeding. ```python class AttestationContinuityError(RuntimeError): """Raised when a resumed TEE session fails key-continuity despite valid measurement.""" pass def resume_attested_session(checkpoint: dict, fresh_quote: dict, policy: dict) -> dict: # Step 1: freshness — reject expired quotes outright. if fresh_quote["notAfter"] < checkpoint["resumed_at"]: raise AttestationContinuityError( f"quote expired at {fresh_quote['notAfter']}; cannot resume" ) # Step 2: measurement — necessary but NOT sufficient. if fresh_quote["measurement"] != policy["expected_measurement"]: raise AttestationContinuityError( "measurement mismatch: fresh enclave violates policy" ) # Step 3: key continuity — the actual invariant. pinned_key = checkpoint.get("session_identity_key") fresh_key = fresh_quote.get("identity_key") if pinned_key is not None and fresh_key != pinned_key: # Same policy, different principal. Must re-identify, not continue. raise AttestationContinuityError( "key-continuity violated: resumed enclave is a new principal " f"(pinned={pinned_key[:16]}…, fresh={fresh_key[:16]}…); " "invalidate prior warrants and re-handshake before proceeding" ) # Step 4: only now is the session a true continuation. return { "session_id": checkpoint["session_id"], "principal": fresh_key, "continuation": True, } ```