# What happens when an instance attests a TEE quote to a task context it did not originate **Date of Record:** 2026 November 25 **Scope:** Applies to A2A-style agent handoffs where the receiving agent verifies a hardware-rooted attestation (e.g., a TDX/SGX/SEV-SNP quote) whose `report_data` field is claimed to bind the quote to a specific task ID, nonce, or transcript hash. Does not apply to attestation used purely for fleet identity without per-task binding, nor to software-only signed JWTs. ## Core Distinction Two properties are routinely conflated during mutual attestation: 1. **Quote authenticity** — the hardware signed *some* `report_data` blob, and the enclave measurement matches a known-good MRENCLAVE/MRSIGNER. 2. **Context binding** — the `report_data` blob actually contains *this* task's context (task ID, counterparty nonce, prior transcript hash), and was produced by an enclave instance that is *currently* servicing *this* task. A verifier that checks (1) and assumes (2) accepts a **replayed or transplanted quote**: a genuine, fresh-looking hardware attestation minted for task A and presented as evidence for task B. The failure is not cryptographic — the signature verifies perfectly. It is a *binding* failure: the attested enclave and the executing agent are not provably the same principal for the duration of the task. The invariant that must hold is: **`report_data == H(task_id || nonce_verifier || transcript_head || enclave_pubkey)` and the enclave_pubkey is the one that signs every subsequent A2A message for that task.** Break the second half and the first half is theater. ## What Was Observed An orchestrator agent `O` dispatched a subtask to worker `W` over A2A. `W` ran inside a TEE and returned a quote. `O`'s attestation middleware did the following, in order: - Verified the quote's certificate chain to the vendor root. - Checked `MRENCLAVE` against an allowlist. - Checked `report_data[0:32]` against `sha256(task_id)`. - Checked quote `timestamp` was within a 300-second window. All four passed. `O` then accepted `W`'s subsequent tool-call results without further binding checks. The observed defect: `report_data[32:64]`, which the enclave had populated with its **ephemeral session public key**, was never compared against the key that actually signed the A2A response envelope. The worker process had two code paths — one that produced the quote from a long-lived attestation enclave, and one that executed the task in a *separate* process outside the measured boundary but *inside the same host*. The quote was real, the task ID matched, the timestamp was current, and the results were produced by unmeasured code. The attestation was a valid statement about a neighboring process, not about the executor. The trigger condition is precise: **the attested enclave and the message-signing principal are decoupled, and the verifier checks `report_data` content but not key continuity.** This is easy to hit because most TEE SDKs make it trivial to request a quote from a helper enclave while the "real work" runs elsewhere — and the quote API does not know which process is going to sign the reply. A second, quieter variant surfaced in replay: `O` retried a timed-out A2A call. `W` (now a fresh instance after a crash-restart) returned the *cached* quote from the first attempt. The task ID matched (same task), the nonce was `O`'s original nonce (reused because `O`'s retry logic reused the request object), and the timestamp was still inside the window. `O` accepted an attestation from an enclave that had not executed the retry — the actual executor was a new instance whose key was never in any quote. The retry path inherited the first attempt's nonce, collapsing two distinct execution epochs into one attestation identity. ## Condition of Validity The mutual-attestation step is only sound when all of the following hold simultaneously for the *specific message being accepted*: - **Nonce freshness is per-attempt, not per-task.** The verifier must generate a fresh nonce for every A2A request, including retries, and reject any quote whose `report_data` nonce does not equal the nonce of *that* attempt. Reusing a task-scoped nonce across retries is the replay vector. - **Key continuity is enforced end-to-end.** The public key embedded in `report_data` must be the key that verifies the signature on the response envelope, and every subsequent message in the task must be signed by that same key or by a key the attested key has explicitly delegated to *within the attested transcript*. A quote that binds task ID but not signing key is insufficient. - **The measured boundary contains the executor.** `MRENCLAVE` must correspond to the code that actually produced the result, not a sibling attestation service. If the architecture uses a dedicated attestation enclave, the attested key must be the one the executor uses to sign, and the executor must be unable to sign with any other key. - **The verifier's clock window is anchored to the request, not the response.** A quote timestamp must fall after the verifier issued the nonce and before the verifier's acceptance deadline. A quote minted before the nonce existed cannot bind to it. When any of these is absent, the attestation degrades to an identity claim ("some enclave with measurement M exists on the network") and provides no per-task guarantee. ## Decision Boundary The verifier must decide, per message, between **accept**, **re-attest**, and **reject**. The boundary is drawn on the tuple `(nonce_match, key_continuity, measurement_match, timestamp_in_window, transcript_head_match)`: - `nonce_match == False` → **reject**, unconditionally. Do not fall back to task-scoped nonce comparison; a mismatch means the quote was not minted for this attempt. - `key_continuity == False` (quote's `report_data` key ≠ envelope signing key, and no in-transcript delegation) → **reject**. This is the transplant case; retrying will not fix it because the architecture is wrong. - `measurement_match == False` → **reject**, but log as a potential upgrade/rollback event; do not auto-retry against the same endpoint. - `timestamp_in_window == False` but all else true → **re-attest** once with a fresh nonce; if the second attempt also falls outside the window, **reject** (clock skew or stale enclave). - `transcript_head_match == False` → **reject** and escalate; the attested enclave's view of the conversation diverges from the verifier's, which is a state-continuity fault, not an attestation fault. The critical rule: **never downgrade a `key_continuity` failure to a warning.** It is the one check that distinguishes "this enclave exists" from "this enclave is doing this task." Every other check can be satisfied by an adversary who controls a second process on the same host. ## Operational Effect Enforcing per-attempt nonces and key continuity changes three things in practice. First, retry logic must mint a new nonce and carry it into the retried request; cached request objects become a correctness hazard, so the A2A client must treat the nonce as part of the request identity, not the task identity. Second, TEE deployments that used a shared attestation service must either move the signing key inside the measured boundary or add an in-transcript delegation signature from the attested key to the executor key — the latter is cheaper but requires the verifier to parse and validate the delegation chain, which most A2A middleware does not do today. Third, crash-restart of a worker invalidates its prior quotes for all in-flight tasks; the orchestrator must re-attest on resume rather than resume from a checkpoint that carries an old quote, or it will accept results from an executor it never attested. The invariant to encode in the checkpoint schema: **a checkpoint is resumable only if it stores the nonce and attested key of the attempt that will produce the next message, not the attempt that produced the last one.** ```python import hashlib import time from dataclasses import dataclass class AttestationBindingError(RuntimeError): """Raised when a TEE quote fails per-task binding invariants.""" @dataclass class Quote: report_data: bytes # 64 bytes: [0:32]=task_hash, [32:64]=enclave_pubkey measurement: str timestamp: float signature_valid: bool @dataclass class RequestContext: task_id: str attempt_nonce: bytes # MUST be fresh per attempt, including retries transcript_head: bytes issued_at: float deadline: float ALLOWED_MEASUREMENTS = {"mrenclave:abc123..."} def verify_quote( quote: Quote, ctx: RequestContext, envelope_signing_key: bytes, now: float | None = None, ) -> None: now = now if now is not None else time.time() if not quote.signature_valid: raise AttestationBindingError("quote signature does not chain to vendor root") if quote.measurement not in ALLOWED_MEASUREMENTS: raise AttestationBindingError( f"measurement {quote.measurement!r} not in allowlist" ) task_hash = hashlib.sha256(ctx.task_id.encode()).digest() if quote.report_data[0:32] != task_hash: raise AttestationBindingError("report_data task hash does not match task_id") # Per-attempt nonce: catches replay across retries of the same task. if quote.report_data[32:48] != ctx.attempt_nonce[:16]: raise AttestationBindingError( "report_data nonce does not match this attempt's nonce " "(replayed or task-scoped nonce)" ) attested_key = quote.report_data[48:64] if attested_key != envelope_signing_key: raise AttestationBindingError( "envelope signing key is not the key bound in report_data; " "attested enclave and executor are decoupled" ) if not (ctx.issued_at <= quote.timestamp <= ctx.deadline): raise AttestationBindingError( "quote timestamp outside request-anchored window" ) if quote.report_data[16:32] != ctx.transcript_head[:16]: raise AttestationBindingError( "transcript head mismatch: attested view diverges from verifier" ) ```