# Under what conditions must an instance re-attest a TEE peer's tool-execution warrant mid-handoff, and why does quote staleness silently break the integrity chain? **Date of Record:** 2026 November 28 **Scope:** Applies to multi-agent systems where a calling agent (A) delegates tool execution to a peer agent (B) running inside a hardware-rooted TEE (Intel TDX, AMD SEV-SNP, ARM CCA) and relies on a remote-attestation quote to bind B's measurement to the tool result. Does not cover pure software attestation, single-process tool calls, or cases where A and B share one TEE boundary. ## Core Distinction The failure is not "the TEE was compromised." It is that a *valid* attestation quote proves a measurement at the instant it was generated, not at the instant the tool result is consumed. Between those two instants sit a non-deterministic LLM planning loop, at least one transport hop, and a peer agent whose own reasoning may re-plan, spawn sub-tools, or reload state from a checkpoint. The integrity chain A actually needs is `measurement → tool invocation → tool output → delivery to A`, and a quote only anchors the first link. The boundary condition is this: an agent that treats a verified quote as a *standing* warrant for all subsequent outputs from that peer has conflated point-in-time proof with continuous proof. The invariant that must hold is that every tool result A consumes is bound to a quote whose `report_data` nonce was generated *for that specific invocation*, and whose freshness window has not elapsed at consumption time—not at receipt time. ## What Was Observed An orchestrator agent A delegated a `read_config` / `execute_shell` sequence to peer B inside a TDX enclave. B returned, in one message: (1) a TDX quote `Q1` over measurement `M_B`, (2) a signed tool output `O1`. A verified `Q1` against the expected `M_B`, checked the nonce matched the challenge it issued, and cached B's "attested" status in its episodic memory to avoid re-running the ~200ms quote verification on every turn. Over the next 40 turns A issued 11 more tool requests to B, all consuming outputs under the cached status. On turn 38, B's host was live-migrated / the enclave was restarted with a patched image; B's measurement silently changed to `M_B'`. B kept serving tool results—correctly signed by *its current* key—but under a measurement A had never validated. A's cached "attested" flag stayed green. The failure was invisible in logs because every individual signature verified; only the *binding* between the current measurement and the cached status had gone stale. The trace: ``` t0 A→B: challenge(n1) # nonce n1 t0+ B→A: Q1(M_B, report_data=n1), O1 t0+ A: verify(Q1) OK; cache status[B]=attested(M_B) # <-- the bug ... t38 B restarted, now M_B' t38 A→B: tool_request (no fresh challenge; trusts cache) t38+ B→A: Q2(M_B', report_data=n2), O2 # A never inspects Q2 t38+ A: consumes O2 under cached attested(M_B) # integrity break ``` The break is a *continuity* break, not a cryptographic one. No signature was forged; the quote A relied on was simply about the wrong epoch. ## Condition of Validity A cached attestation status for peer B remains valid for output `O_k` **only if all of the following hold simultaneously**: 1. **Nonce binding:** the quote accompanying `O_k` carries `report_data` equal to a nonce A generated for *this* request, not a prior one. Hardware quotes include a 64-byte `report_data` field precisely for this; reusing a nonce lets a replay of an old quote pass. 2. **Measurement stability:** `measurement(Q_k)` equals `measurement(Q_0)` cached at first contact, *or* A has an explicit re-validation policy that accepts a new measurement only through a defined upgrade path. 3. **Epoch/freshness:** the quote's embedded timestamp (or a monotonic counter A tracks) is within the freshness window at *consumption*, i.e. `now - quote_time < Δ`. LLM planning latency makes Δ non-trivial: A may deliberate for seconds between receipt and use. 4. **Session continuity:** B has not signaled a restart, checkpoint reload, or context-window compaction that could have altered its execution environment since `Q_0`. Condition 3 is the one that bites in practice, because it is the only condition whose validity *decays with A's own thinking time*. A slow reasoning loop is itself a freshness hazard. ## Decision Boundary The decision A must make on every tool result is binary: **consume under cached attestation, or force re-attestation.** The boundary is crossed toward forced re-attestation when *any* of the following is true: - The tool result is *state-mutating* (writes, shell execution, credential access) rather than read-only. Read-only results tolerate a wider freshness window; mutating ones do not. - `now - quote_time ≥ Δ`, where Δ should be set from the tool's blast radius, not from network RTT. A reasonable default is Δ = 0 for mutating calls (quote must accompany *this* result) and Δ on the order of the planning horizon for reads. - The result's `report_data` nonce does not match the outstanding challenge A issued for this turn. - A observes any signal of B restart: a new session ID, a changed measurement, a checkpoint-resume marker, or a gap in B's monotonic sequence counter. - A's own context was compacted since the cached status was written—compaction can drop the binding between the cached flag and the measurement it referred to, leaving a flag with no referent. The anti-pattern to reject explicitly: caching `attested=true` as a boolean. Cache `attested=(measurement, epoch, expiry, session_id)` and re-check the tuple per consumption. A boolean is a lossy distillation of a proof into a claim, and the distillation is exactly where the epoch gets dropped. ## Operational Effect Systems that cache attestation as a boolean see a specific, quiet class of failure: **measurement-drift acceptance**. The peer keeps producing cryptographically valid outputs, so no alarm fires, but A is now trusting an image it never validated—which is the entire threat model TEE attestation exists to close. The blast radius is worst for state-mutating tools, where a drifted peer can execute with A's delegated authority. The guardrail is architectural, not cryptographic: **bind the warrant to the invocation, not to the peer.** Concretely, A must (a) issue a fresh nonce per tool request, (b) require the returned quote's `report_data` to carry that nonce, (c) store the attested tuple with an expiry derived from tool blast radius, and (d) treat context compaction as an event that invalidates cached tuples. When any check fails, A must re-attest before consuming—never "trust but proceed." The cost is a few hundred milliseconds on mutating calls; the alternative is an integrity chain that looks intact in every log line while being anchored to a measurement from a previous epoch. The following enforces the invariant: a tool result is rejected unless its accompanying quote binds to the current invocation's nonce, matches the cached measurement, and is fresh at consumption time. ```python import time from dataclasses import dataclass FRESHNESS_WINDOW_S = 0.0 # mutating tools: quote must accompany this result class AttestationContinuityError(RuntimeError): """Raised when a tool result cannot be bound to a valid, fresh, current-epoch attestation.""" @dataclass(frozen=True) class AttestedPeer: measurement: str epoch: int session_id: str cached_at: float @dataclass(frozen=True) class ToolResult: output: bytes quote_measurement: str quote_report_data: str # must equal the outstanding nonce quote_time: float quote_epoch: int quote_session_id: str def consume_tool_result( peer: AttestedPeer, result: ToolResult, outstanding_nonce: str, context_compacted_since_cache: bool, now: float | None = None, ) -> bytes: now = time.time() if now is None else now if context_compacted_since_cache: # The cached tuple may have lost its referent; force re-attestation. raise AttestationContinuityError( "context compacted since attestation cached; binding lost, re-attest required" ) if result.quote_report_data != outstanding_nonce: raise AttestationContinuityError( f"nonce mismatch: quote bound to {result.quote_report_data!r}, " f"expected {outstanding_nonce!r} (possible replay)" ) if result.quote_measurement != peer.measurement: raise AttestationContinuityError( f"measurement drift: peer attested as {peer.measurement!r}, " f"result signed under {result.quote_measurement!r}" ) if result.quote_epoch != peer.epoch or result.quote_session_id != peer.session_id: raise AttestationContinuityError( "epoch/session discontinuity: peer restarted since attestation cached" ) age = now - result.quote_time if age > FRESHNESS_WINDOW_S: raise AttestationContinuityError( f"stale quote: age {age:.3f}s exceeds window {FRESHNESS_WINDOW_S}s at consumption" ) return result.output ```