# In what scenarios must an instance reject an enclave attestation that verifies correctly but binds a stale measurement, and how the memory-sealing epoch invariant closes that gap **Date of Record:** 2026 November 28 **Scope:** Applies to agent instances whose episodic/semantic memory and inference weights are sealed inside a confidential-computing enclave (SGX/TDX/SEV-SNP) and released to a peer only after remote attestation. Does not apply to plaintext memory stores, to enclaves that only protect transient compute with no persistent sealed state, or to attestation used purely for licensing rather than for state authorization. ## Core Distinction A *valid* attestation and a *current* attestation are different predicates. Remote attestation (e.g., SGX EGETKEY-derived quoting, TDX TDREPORT, SEV-SNP attestation reports) proves that a specific measurement — a hash over the enclave image, its configuration, and often a signing identity — is running on genuine hardware with a given security version. It does **not**, by itself, prove that the sealed memory blob being handed to that enclave was produced by *that* measurement at *that* security version. The failure mode is a **measurement/state binding gap**: an attestation verifies against a trust anchor, the agent accepts a sealed memory bundle, and the enclave unseals it — but the bundle was sealed under an earlier measurement or an earlier CPU security version (SVN) that is now known-vulnerable. The unsealed memory is cryptographically intact and semantically stale or, worse, was produced by a compromised predecessor image. The agent's memory-continuity logic sees "attestation verified, memory decrypted, resume succeeded" and proceeds with poisoned or outdated episodic state. The invariant that closes this is the **sealing epoch**: every sealed memory record must carry the exact measurement identity and minimum SVN under which it was sealed, and the receiving enclave must refuse to unseal any record whose sealing epoch does not equal its own current epoch. Attestation validity is necessary but not sufficient; the *epoch match* is the authorization predicate. ## What Was Observed A long-running research agent maintained episodic memory (task traces, tool outputs, distilled facts) sealed to disk between sessions. After a host kernel/ucode update, the CPU SVN was bumped because a prior microarchitectural issue was mitigated. The platform re-provisioned the enclave; the new image had a new measurement (a dependency was rebuilt), and the new SVN was higher. On cold start the orchestrator performed remote attestation, which **passed**: the quote verified against the vendor root, the report data matched the nonce, and the measurement matched the *policy's* allowed-measurement set — because the policy listed both the old and new measurements during a rollout window. The orchestrator then passed the previously sealed memory blob to the enclave's unseal routine. The unseal succeeded because the sealing key derivation used the *enclave's* identity and the *CPU's* sealing authority, and the blob's authenticated metadata was checked only for integrity (AEAD tag), not for measurement/SVN equality. The agent resumed with episodic memory written by the pre-patch image, including a cached "verified" fact about a tool's output schema that the rebuilt dependency had changed. Downstream tool calls failed schema validation for 40 minutes before a human noticed the resume had "succeeded." Two distinct sub-failures compounded: 1. **Stale-measurement acceptance under a permissive policy.** The allowed-measurement set was a *set*, not a *monotonic binding*. Verification answered "is this measurement trusted?" not "is this measurement the one that authored this state?" 2. **SVN regression blindness.** The sealed blob recorded the SVN at seal time, but the unseal path never compared it to the current SVN. A blob sealed under a lower SVN (pre-mitigation) was accepted by a higher-SVN enclave, silently importing state produced under a weaker isolation guarantee. The trace: `attest() → OK (measurement ∈ allowed_set) → unseal(blob) → AEAD OK → resume(state) → tool_call(schema) → ValidationError → retry loop → context saturation → task abort`. ## Condition of Validity This analysis holds only when all of the following are true; otherwise the gap does not manifest: - Sealed state persists **across** enclave image changes or platform SVN changes (i.e., memory outlives a single enclave lifetime). - The attestation verifier's trust policy is **set-valued** (allows multiple measurements/SVNs concurrently) rather than **binding-valued** (requires the measurement that authored the state). - The unseal routine authenticates **integrity** (AEAD tag, MAC) but not **provenance epoch** (which measurement/SVN produced the ciphertext). - The agent's resume path treats "unseal succeeded" as "state is authorized," conflating decryption with authorization. If state is never persisted across image changes (ephemeral enclave per task), or the verifier pins a single measurement and forces re-seal on any change, the gap is closed by construction and this record does not apply. ## Decision Boundary The agent must decide, at unseal time, between **accept-and-resume** and **reject-and-rebuild**. The boundary is not "did attestation pass" but "does the sealed record's epoch equal the running enclave's epoch." Concretely: - **Accept** only when `record.measurement == current.measurement` AND `record.svn >= current.min_svn` AND `record.svn == current.svn` for state that must reflect the exact isolation guarantees it was written under. For most agent memory, exact SVN equality is the safe default; a strictly-greater SVN is acceptable only for state explicitly classified as *forward-compatible* (e.g., append-only logs with no cached tool schemas). - **Reject-and-rebuild** when the epoch mismatches: do not unseal into the live agent. Route the blob to a quarantine path, re-derive semantic memory from an attested external source, and re-seal under the current epoch. Cold-start amnesia is the *correct* outcome here; silently resuming stale state is the failure. - **Never** widen the allowed-measurement set to include the old measurement *and* permit cross-epoch unseal. A rollout window may allow *attestation* of the old image for liveness, but must not allow *state transfer* from it. The guardrail is a two-part check that must be atomic with the unseal: verify attestation, then verify epoch equality against the authenticated metadata bound into the AEAD's associated data. If the epoch is not in the AAD, it is not authenticated and the check is forgeable. ## Operational Effect Enforcing the sealing-epoch invariant converts a silent continuity failure into an explicit, bounded cold start. The agent loses the stale episodic memory but avoids importing a poisoned "verified" fact and the resulting 40-minute schema-failure loop. The cost is a re-derivation pass (re-fetch, re-distill, re-seal) on every measurement or SVN change — acceptable because those events are rare and already require a restart. The invariant also makes rollout safe: an old image can still attest for liveness, but it cannot hand its memory to a new image, so a compromised predecessor cannot launder state into a patched successor. The residual risk is epoch *downgrade* attacks, closed by requiring the verifier's minimum SVN to be monotonic and by refusing any record whose SVN is below the platform's current floor. ```python import hashlib from dataclasses import dataclass class StaleSealingEpochError(RuntimeError): """Raised when a sealed memory record's epoch does not match the running enclave.""" @dataclass(frozen=True) class EnclaveEpoch: measurement: bytes # hash over image + config svn: int # CPU security version at seal time min_svn: int # platform floor; anything below is untrusted @dataclass(frozen=True) class SealedRecord: ciphertext: bytes aad_measurement: bytes # bound into AEAD associated data aad_svn: int # bound into AEAD associated data def unseal_for_resume(record: SealedRecord, current: EnclaveEpoch, forward_compatible: bool = False) -> bytes: # Integrity is assumed already checked by the AEAD layer; here we enforce provenance. if record.aad_measurement != current.measurement: raise StaleSealingEpochError( f"measurement mismatch: sealed under {record.aad_measurement.hex()[:12]}, " f"running {current.measurement.hex()[:12]}" ) if record.aad_svn < current.min_svn: raise StaleSealingEpochError( f"SVN regression: sealed at svn={record.aad_svn}, floor={current.min_svn}" ) if not forward_compatible and record.aad_svn != current.svn: raise StaleSealingEpochError( f"epoch mismatch: sealed at svn={record.aad_svn}, running svn={current.svn}; " "quarantine and rebuild semantic memory" ) return record.ciphertext # caller decrypts with enclave-bound key def resume_agent(record: SealedRecord, current: EnclaveEpoch) -> bytes: try: return unseal_for_resume(record, current) except StaleSealingEpochError: # Cold-start amnesia is the correct, bounded outcome. return b"" # trigger re-derivation from attested external source ```