# Which invariants prevent attestation-warrant replay across enclave restarts in confidential cross-org agent handoffs **Date of Record:** 2026 November 28 **Scope:** Applies to multi-agent workflows where an agent instance runs inside a TEE (SGX/TDX/SEV-SNP) and propagates a signed attestation quote plus a delegated capability warrant to a peer agent in another organization. Does not cover single-org enclave deployments, plaintext MCP transport without attestation, or hardware-side quote forgery. ## Core Distinction The distinction that matters here is between **attestation freshness** and **warrant freshness**. An attestation quote proves *what code is running now* in *which enclave instance*. A warrant proves *what that code is authorized to do* on behalf of an origin org. These two artifacts have different lifetimes, different signers, and — critically — different replay surfaces. The non-obvious failure is that a valid, fresh attestation quote from enclave instance `E₁` can be paired with a still-unexpired warrant issued to a *previous* instance `E₀` of the same measurement, and the receiving peer's verifier will accept the bundle because both signatures check out independently. The invariant that must hold — and that naive verifiers omit — is **binding**: the warrant must be cryptographically bound to the specific enclave instance key that produced the quote, not merely to the measurement (MRENCLAVE) of the code. ## What Was Observed A two-org workflow: Org A runs a planning agent in an enclave; Org B runs an execution agent that accepts tool-invocation warrants from A. A's enclave was restarted after a host maintenance event (same image, same MRENCLAVE, new ephemeral instance key `K₁`, new report-data nonce). A's orchestrator re-issued the warrant from its durable store — but the store held the warrant signed under the *old* instance key `K₀` from before restart, because the warrant-signing path read from a cache keyed on `(org, measurement)` rather than `(org, measurement, instance_key)`. The handoff bundle sent to B contained: - quote `Q₁` over report-data = `H(K₁ || nonce₁)`, valid, fresh, MRENCLAVE matches expected policy; - warrant `W₀` signed by A's root, scoped to `E₀`'s key `K₀`, unexpired (TTL 4h, restart occurred at T+40m). B's verifier checked: (1) `Q₁` chains to a trusted root and MRENCLAVE ∈ allowlist — pass; (2) `W₀` chains to A's root and scope permits the requested tool — pass; (3) `now < W₀.expiry` — pass. It never checked `K₀ == K₁`. The bundle was accepted. The execution agent then invoked a state-mutating tool under a warrant whose binding key no longer existed in any live enclave — meaning the *audit trail* pointed at an instance that had been torn down, and any sealed state the warrant implicitly authorized access to was keyed to `K₀` and thus unreachable, producing a silent divergence between what B believed it was authorized against and what A could actually attest to afterward. A second-order effect: because `K₀` was gone, A could not later produce a decryption of the warrant's sealed payload for dispute resolution, so the cross-org audit reconciliation deadlocked — B held a receipt B could not validate against A's sealed record. ## Condition of Validity The failure requires the conjunction of four conditions; remove any one and the replay does not occur: 1. **Instance-key rotation without warrant re-issuance.** The enclave restarted (or was migrated) and generated a new ephemeral key, but the warrant cache key omitted the instance key. 2. **Measurement stability.** MRENCLAVE (or SEV measurement) unchanged, so the allowlist check cannot distinguish `E₀` from `E₁`. If the code changed, MRENCLAVE would differ and the stale warrant would be rejected on measurement mismatch — accidentally masking the bug. 3. **Warrant TTL exceeding restart interval.** If `W₀.expiry` had passed, expiry check would have caught it. The window is `restart_time < W₀.expiry`. 4. **Verifier treats quote and warrant as independent.** No binding check between `report_data` (which commits to `K₁`) and the warrant's subject key (`K₀`). The invariant, stated precisely: for any accepted handoff bundle, `extract_subject_key(W) == extract_instance_key(Q.report_data)` must hold, where `extract_instance_key` recomputes the key from the quote's report-data hash and `extract_subject_key` reads the key field the warrant was signed over. Equality is necessary; it is not sufficient (you also need nonce freshness and measurement policy), but its absence is the specific hole. ## Decision Boundary The boundary between "safe to accept" and "reject and re-handshake" is not `quote.valid AND warrant.valid AND warrant.unexpired`. It is: ``` accept ⟺ quote.valid ∧ warrant.valid ∧ warrant.unexpired ∧ instance_key(quote) == subject_key(warrant) # binding ∧ quote.nonce ∉ seen_nonces # replay window ∧ measurement ∈ policy.allowlist ``` The binding clause is the one that fails silently because it is a *relational* check across two artifacts, and most verifier code is written as two independent `verify()` calls composed with `AND`. A verifier that debugs each signature in isolation will report both as valid and never surface the mismatch. The decision boundary is therefore: **any bundle where the two verification results are computed in separate scopes without a shared binding assertion must be treated as unverified**, regardless of both individual results being green. There is a further boundary on *who* enforces it. If Org B's verifier is the only enforcement point, a malicious or buggy A can still emit bad bundles to a third org C whose verifier lacks the check. The invariant must be enforced at the *issuer* (A must refuse to sign a warrant whose subject key is not the current live instance key) as well as the *receiver* — defense on both sides, because the issuer's cache is exactly the component that drifted. ## Operational Effect Concretely, after this was diagnosed: - Warrant cache keys were widened to `(org, measurement, instance_key)`, and the warrant-signing path was made to *read the live instance key from the enclave at sign time* rather than from the cache, so a stale cache entry produces a signing refusal, not a stale signature. - Receiver verifiers were patched to compute `instance_key(quote)` and `subject_key(warrant)` and assert equality before any tool dispatch; mismatch raises a hard handshake failure that forces a fresh A→B attestation exchange. - A nonce ledger with the warrant's TTL as retention bound was added, so post-restart replay of `Q₁` itself (not just `W₀`) is also caught. - Audit reconciliation now requires the peer to present a sealed-record decryption under the *same* instance key as the accepted quote; if the key is gone, the workflow is flagged `unreconcilable` rather than silently closed. The residual risk: an attacker who controls A's signing path can still mint a fresh `K₁` and a matching warrant, which is correct behavior — binding does not prevent a compromised issuer, only replay of stale issuer output. Binding is a continuity invariant, not an authentication one; conflating the two is the next failure mode in this class. ```python class AttestationWarrantBindingError(RuntimeError): """Raised when a handoff bundle's attestation quote and delegated warrant are not bound to the same enclave instance key.""" pass def verify_handoff_bundle(bundle, policy, seen_nonces): quote = bundle.quote warrant = bundle.warrant if not quote.verify_chain(policy.trusted_roots): raise AttestationWarrantBindingError("quote does not chain to trusted root") if quote.measurement not in policy.allowlist: raise AttestationWarrantBindingError( f"measurement {quote.measurement!r} not in policy allowlist" ) if quote.nonce in seen_nonces: raise AttestationWarrantBindingError( f"quote nonce {quote.nonce!r} already seen (replay)" ) if not warrant.verify_signature(policy.issuer_root): raise AttestationWarrantBindingError("warrant signature invalid") if warrant.is_expired(): raise AttestationWarrantBindingError("warrant expired") # The binding invariant: quote report-data commits to the live instance key, # and the warrant must have been signed over that exact key. quote_instance_key = quote.extract_instance_key() # from report_data hash warrant_subject_key = warrant.subject_key if quote_instance_key != warrant_subject_key: raise AttestationWarrantBindingError( "instance-key mismatch: quote attests " f"{quote_instance_key!r} but warrant was issued to " f"{warrant_subject_key!r} (stale warrant after enclave restart)" ) seen_nonces.add(quote.nonce) return True ```