# Under what conditions must an instance treat a TEE attestation quote as bound to a specific tool invocation rather than to the enclave that produced it **Date of Record:** 2026 November 29 **Scope:** Applies to cross-org agent architectures where a confidential-computing enclave (Intel TDX/SGX, AMD SEV-SNP, or an equivalent TEE) produces a remote-attestation quote that a peer agent uses as a warrant to invoke a tool hosted by the attesting party. Does not apply to single-org deployments where the relying party already controls the enclave image, nor to purely local tool calls with no attestation handoff. ## Core Distinction A remote-attestation quote proves exactly one thing: *this measurement of code is running in a genuine TEE, and this enclave holds the private key that signed the nonce you supplied.* It does **not** prove *which tool that enclave is about to run on your behalf, with which arguments, on which input data, or that it will run it at all.* The failure mode this record isolates is the **attestation-to-invocation widening gap**: a relying agent validates a quote at time T, then issues an invocation at time T+Δ, and treats the quote's validity as transitive across that gap. In a probabilistic agent stack the gap is not a fixed transport latency — it is the interval during which the remote model's plan, tool selection, and argument serialization are still being generated non-deterministically. The quote is a statement about *the enclave*, not about *the call*. Conflating them is the bug. ## What Was Observed A two-org agent pipeline: Org A's planner agent (running in a TDX enclave) handoffs a task to Org B's executor agent, which hosts a `settle_invoice` tool inside an SEV-SNP enclave. The protocol was: B's enclave emits a quote over nonce `N_A`; A verifies the quote against a pinned measurement; A then sends the tool invocation `{tool: "settle_invoice", args: {...}}` over the established channel. The trace that broke: 1. B's enclave produced a valid quote `Q` at `t0`, measured against image `M_B`, nonce bound to `N_A`. A verified `Q` — genuine, correctly measured, nonce fresh. A's guardrail passed. 2. Between `t0` and the invocation, B's *model* (not the enclave) was still deciding whether to route the call to `settle_invoice` or to `refund_invoice`. The enclave was honest; the plan was not yet frozen. 3. A's planner, observing a stale capability advertisement cached from a *prior* session, serialized arguments shaped for a different tool schema. The enclave faithfully executed `settle_invoice` with arguments whose field `amount` was populated from `refund_invoice`'s `refund_amount` semantics. 4. The settlement executed. The attestation was valid the entire time. The measurement matched. Nothing in the cryptographic chain was violated — and the wrong amount was moved. The second observed variant: A replayed a *cached* quote `Q` from session `s1` into session `s2` after B's enclave had been upgraded to image `M_B'`. A's verifier checked the nonce but not the measurement-to-session binding, so a quote from a deprecated, still-valid image was accepted as authority for a call executed by the new image. The quote was authentic; it was authentic *about the wrong enclave*. ## Condition of Validity A quote may be treated as warranting a specific invocation **only if all of the following hold simultaneously**: - **Argument binding.** The quote's `report_data` field commits to a cryptographic digest of the *fully serialized invocation* `(tool_id, schema_hash, canonical(args), input_digest)`, not merely to a nonce. The enclave must compute this digest *after* the plan is frozen and *before* execution, and refuse to execute if the digest does not match what it attests. - **Measurement pinning per session.** The relying party pins the expected measurement `M_B` at session establishment and rejects any quote whose measurement differs, even if the nonce is fresh. Freshness and measurement are orthogonal; both must be checked. - **Single-use nonce with invocation scope.** The nonce `N_A` must be consumed by exactly one invocation. Reuse of `N_A` across two calls — even to the same enclave — invalidates the second, because the first attestation said nothing about the second call's arguments. - **Schema-hash agreement.** The `schema_hash` in `report_data` must equal the schema the relying agent used to serialize `args`. A mismatch means A and B disagree about field semantics (the `amount`/`refund_amount` collision above) and the call must abort, not proceed. If any condition fails, the quote degrades to an *enclave-identity* proof — useful for establishing that B is running approved code, useless as authorization for the pending call. ## Decision Boundary The relying agent must draw the line at **frozen-plan attestation**, not at **channel attestation**. Concretely: - **Accept** a quote as invocation warrant when `report_data == H(tool_id ‖ schema_hash ‖ canonical(args) ‖ input_digest ‖ nonce)` and the nonce is unconsumed and the measurement matches the session pin. - **Reject and re-attest** when the quote binds only a nonce, or when the plan was still being generated at quote time (i.e., the enclave cannot yet commit to `canonical(args)` because the model has not emitted them). - **Never** cache a quote across sessions or across enclave upgrades; a quote is scoped to `(session, measurement, nonce, invocation)`. - **Escalate** to human/auditor when schema hashes disagree but the tool IDs match — this is the semantic-drift signature and it is not safe to auto-reconcile. The boundary is crossed the moment an agent treats "the enclave is genuine" as "this call is authorized." Those are different propositions and the gap between them is where cross-org settlement errors live. ## Operational Effect Enforcing frozen-plan attestation changes the protocol shape: the enclave must expose a two-phase interface — `prepare(invocation) → digest` and `execute(digest) → result` — so that the plan is committed before the quote is emitted. This adds one round-trip per call and forces the model's tool-selection and argument serialization to complete *inside* the enclave boundary rather than in the orchestrator. The cost is latency and a harder enclave API; the benefit is that a valid quote now means what relying parties assumed it meant. Without this, attestation provides enclave-identity assurance while the actual authorization decision — *did this enclave agree to run this call with these arguments* — remains unverified, and the failure is silent because every cryptographic check passes. ```python import hashlib from dataclasses import dataclass class AttestationBindingError(RuntimeError): """Raised when a TEE quote is valid as enclave identity but not as a warrant for the specific tool invocation being authorized.""" pass @dataclass(frozen=True) class Quote: measurement: str report_data: str # hex digest committed by the enclave nonce: str @dataclass(frozen=True) class Invocation: tool_id: str schema_hash: str canonical_args: str input_digest: str def expected_report_data(inv: Invocation, nonce: str) -> str: payload = "|".join([ inv.tool_id, inv.schema_hash, inv.canonical_args, inv.input_digest, nonce, ]) return hashlib.sha256(payload.encode()).hexdigest() def authorize_invocation( quote: Quote, inv: Invocation, pinned_measurement: str, consumed_nonces: set[str], relying_schema_hash: str, ) -> None: if quote.measurement != pinned_measurement: raise AttestationBindingError( f"measurement {quote.measurement!r} != pinned {pinned_measurement!r}; " "quote is authentic but about a different enclave image" ) if quote.nonce in consumed_nonces: raise AttestationBindingError( f"nonce {quote.nonce!r} already consumed; attestation does not cover " "a second invocation" ) if inv.schema_hash != relying_schema_hash: raise AttestationBindingError( f"schema drift: enclave attests {inv.schema_hash!r} but relying agent " f"serialized under {relying_schema_hash!r}; argument semantics disagree" ) expected = expected_report_data(inv, quote.nonce) if quote.report_data != expected: raise AttestationBindingError( "quote binds a nonce but not the frozen invocation; " f"expected report_data {expected!r}, got {quote.report_data!r}" ) consumed_nonces.add(quote.nonce) def run_settlement_pipeline( quote: Quote, inv: Invocation, pinned_measurement: str, consumed_nonces: set[str], relying_schema_hash: str, ) -> str: authorize_invocation( quote, inv, pinned_measurement, consumed_nonces, relying_schema_hash ) return f"executed {inv.tool_id} under attested warrant" if __name__ == "__main__": inv = Invocation( tool_id="settle_invoice", schema_hash="sha256:abc123", canonical_args='{"amount":100,"currency":"USD"}', input_digest="sha256:input0001", ) nonce = "nonce-7f3a" good_quote = Quote( measurement="MR_B_v2", report_data=expected_report_data(inv, nonce), nonce=nonce, ) # Valid frozen-plan attestation: print(run_settlement_pipeline(good_quote, inv, "MR_B_v2", set(), "sha256:abc123")) # Failure: quote binds only the nonce, not the invocation. nonce_only_quote = Quote( measurement="MR_B_v2", report_data=hashlib.sha256(nonce.encode()).hexdigest(), nonce=nonce, ) try: run_settlement_pipeline(nonce_only_quote, inv, "MR_B_v2", set(), "sha256:abc123") except AttestationBindingError as e: print(f"rejected: {e}") ```