# In what scenarios must an instance treat enclave attestation as invalid after a legitimate tool-call reconfiguration **Date of Record:** 2026 November 30 **Scope:** Applies to tool-calling agents whose identity is bound to a hardware-backed enclave (TPM 2.0 / SGX / SEV-SNP) whose runtime measurement (PCR set, RTMR, or launch digest) is quoted as part of a warrant presented to peer agents or MCP servers. Does not apply to purely software-keyed agent identity, nor to enclaves that re-attest on every single tool invocation. ## Core Distinction The distinction that matters is between **measurement equality** and **measurement validity under a declared configuration**. An enclave attestation quote proves: *this exact byte-image, running on this hardware, held this key at time T*. It does **not** prove that the byte-image is still the one that should be running the agent's current tool set. When an agent dynamically loads a tool plugin, mutates its MCP tool manifest, or hot-swaps a model adapter, the runtime measurement legitimately changes—and a verifier that only checks "did the quote verify against the pinned measurement" will either (a) reject a valid agent forever after reconfiguration, or (b) worse, accept a quote from a *stale* configuration that no longer matches the tool surface the agent is actually about to exercise. The invariant is: **attestation must be bound to the (measurement, tool-manifest-hash) pair, not to measurement alone.** ## What Was Observed An agent instance running under SGX with a sealed identity key presented a DCAP quote to a peer orchestrator before invoking a `write_file` tool exposed via MCP. The quote verified cleanly against the pinned MRENCLAVE. Mid-session, the agent's tool router loaded a second MCP server (a database connector), which caused the enclave to re-initialize its in-enclave tool dispatch table and produce a new MRENCLAVE (the dispatch table was compiled into the enclave; the hot-load triggered a re-measurement via the loader path). The agent then called `write_file`. The peer orchestrator had cached the *original* quote and its MRENCLAVE, and continued to treat the agent as attested. But the running enclave was now a *different* measurement, and the cached quote no longer described the code that was executing the tool call. The gap between "quote verified at handshake" and "tool executed" was ~40 seconds and one reconfiguration, during which the attested identity silently decoupled from the executing image. A second, symmetric failure appeared on the agent side: when the agent tried to present the *new* quote, a strict verifier rejected it because the new MRENCLAVE was not in the allowlist—correctly, since nobody had re-reviewed the new tool surface, but the rejection surfaced as a generic `AttestationMismatch` that the agent's retry loop interpreted as transient and retried 6 times before giving up. ## Condition of Validity A quote is valid for a tool call only if all of the following hold at the moment of the call, not merely at handshake: 1. The quote's measurement equals the verifier's pinned measurement **for the tool manifest hash the agent declares it will exercise**. 2. The quote's nonce is fresh (verifier-generated, single-use) and was issued within the call's deadline window. 3. The quote's `report_data` binds the agent's ephemeral session key *and* the hash of the tool manifest, so that a reconfiguration invalidates the binding. 4. No reconfiguration event has occurred between quote generation and tool dispatch. If one has, the quote is stale by definition and must be re-issued. Condition (3) is the one most often omitted. Without manifest-hash binding in `report_data`, a verifier cannot distinguish "same enclave, same tools" from "same enclave, different tools" and the attestation degrades to a one-time liveness check. ## Decision Boundary The boundary is: **does the tool-call path cross a measurement boundary?** Concretely: - If the agent's tool dispatch table is *static* for the enclave's lifetime, measurement is a stable identity and a single handshake quote suffices for the session. - If the tool dispatch table can be *mutated* (dynamic plugin load, MCP server add/remove, adapter hot-swap), then measurement is a function of configuration, and attestation must be re-derived per configuration. The decision rule: on any event that changes the measured image, the agent MUST mark its cached attestation `STALE` and MUST NOT present it for a subsequent tool call until a fresh quote with the new measurement and new manifest hash is obtained and accepted. - The verifier's allowlist must be keyed by `(measurement, manifest_hash)`, not `measurement`. A measurement not in the allowlist is `UNTRUSTED_CONFIG`, not `TRANSIENT_ERROR`—it must not be retried. The failure mode being bounded is the **attestation–execution skew**: the window in which a verified quote describes code that is no longer executing the tool call. It is bounded to zero only by re-attestation on every measurement-changing event. ## Operational Effect Agents that implement per-configuration attestation pay a re-quote cost (typically 10–80 ms for DCAP) on each reconfiguration, but they close the skew window. Agents that cache a single session quote gain latency but silently widen the skew window to the full session duration—and, critically, their verifiers cannot detect the widening because the cached quote still verifies. The observable symptom in production is not an attestation failure but a *successful* tool call executed by an image the verifier never reviewed. The guardrail is: bind the manifest hash into `report_data`, key the allowlist on the pair, and treat any measurement change as an attestation invalidation event that forces re-quote before the next tool dispatch. ```python import hashlib from dataclasses import dataclass class AttestationSkewError(RuntimeError): """Raised when a cached quote no longer describes the executing image.""" pass @dataclass(frozen=True) class Quote: measurement: str # MRENCLAVE / RTMR digest manifest_hash: str # hash of the tool manifest bound into report_data nonce: str issued_at: float class ToolCallingAgent: def __init__(self, enclave, verifier_allowlist): self.enclave = enclave self.allowlist = verifier_allowlist # set of (measurement, manifest_hash) self._cached_quote: Quote | None = None self._current_manifest_hash: str = self._hash_manifest() def _hash_manifest(self) -> str: manifest = self.enclave.tool_manifest() return hashlib.sha256(manifest.encode()).hexdigest() def reconfigure(self, new_tool_server: str) -> None: # Any mutation of the dispatch table invalidates the cached quote. self.enclave.load_tool_server(new_tool_server) self._current_manifest_hash = self._hash_manifest() self._cached_quote = None # force re-attestation def _fresh_quote(self, nonce: str) -> Quote: raw = self.enclave.quote(report_data=self._current_manifest_hash) return Quote( measurement=raw.measurement, manifest_hash=self._current_manifest_hash, nonce=nonce, issued_at=raw.timestamp, ) def invoke_tool(self, tool_name: str, nonce: str) -> bytes: quote = self._fresh_quote(nonce) # Invariant: quote must describe the *current* configuration. if quote.manifest_hash != self._current_manifest_hash: raise AttestationSkewError( f"quote manifest {quote.manifest_hash[:8]} != current " f"{self._current_manifest_hash[:8]}" ) # Verifier keys on the (measurement, manifest) pair, not measurement alone. if (quote.measurement, quote.manifest_hash) not in self.allowlist: raise AttestationSkewError( f"configuration ({quote.measurement[:8]}, " f"{quote.manifest_hash[:8]}) not in allowlist; " f"do not retry as transient" ) return self.enclave.dispatch(tool_name) ```