# Where must an instance re-attest its enclave after a tool-call boundary, and why does the naive "attest once at session start" invariant silently leak cross-tenant plaintext? **Date of Record:** 2026 December 2 **Scope:** Applies to multi-agent systems where each agent instance runs inside a hardware-attested confidential-computing enclave (SEV-SNP, TDX, or equivalent) and invokes privacy-preserving tools (PIR, PSI, MPC, or sealed inference) across organizational trust boundaries. Does *not* apply to single-tenant agents whose tools run in the same attestation domain, nor to purely functional tools with no data-plane state. ## Core Distinction There are two different things an attestation report can certify, and conflating them is the root of the failure: 1. **Code-identity attestation** — "the measurement of the code/keys currently loaded in this enclave equals a known-good hash." This is a *static* property of the launch image. 2. **Data-domain attestation** — "the plaintext currently resident in this enclave's protected memory belongs to tenant T and no other." This is a *dynamic* property of the live memory state, and it is **not** covered by the launch measurement. A session-start attestation verifies (1). The invariant that actually matters for cross-organizational privacy is (2), and (2) is invalidated every time a tool invocation writes tenant-scoped plaintext into enclave memory or a shared scratch region. The non-obvious boundary: **the attestation quote is a function of the launch image, but the privacy guarantee is a function of the memory lineage since the last domain reset.** An instance that re-uses an enclave across tenants, or across tool calls that touch different data domains, holds a valid *code* attestation while violating the *data-domain* invariant. ## What Was Observed A three-party pipeline: Org A's planner agent (enclave `E_A`) invokes Org B's sealed-retrieval tool (enclave `E_B`) over an A2A/MCP-style transport, then hands results to Org C's auditor agent (`E_C`). The tool invocation is a PIR query: `E_B` must answer `E_A`'s query over B's private index without learning the query, and `E_A` must not learn the index. The deployment attested `E_A` once at session start against measurement `M_A`. The quote was cached in the session record and re-presented to `E_B` and `E_C` on every subsequent tool call. Failure trace: 1. Session 1: tenant `T1` runs. `E_A` loads `T1`'s plaintext working set into its protected heap. Attestation `quote(M_A)` is valid; data-domain is `{T1}`. Correct. 2. Session 1 ends. The orchestrator, optimizing cold-start cost, **keeps `E_A` warm** and reuses it for tenant `T2` rather than tearing down the enclave. This is the trigger condition: enclave reuse across data domains without a domain reset. 3. Session 2: tenant `T2` runs. `E_A` now holds `T1`'s plaintext in heap pages that were never zeroed (the allocator reused them; `free()` in the guest does not scrub protected pages). `E_A` presents the *same cached* `quote(M_A)` to `E_B`. The quote is still cryptographically valid — the code measurement genuinely is `M_A`. 4. `E_B`, seeing a valid `M_A` quote, treats `E_A` as a `T2`-authorized caller and returns `T2`-scoped PIR results. But `E_A`'s memory lineage now spans `{T1, T2}`. 5. A subsequent prompt-injection in `T2`'s input induces `E_A` to summarize "everything in my context." The `T1` residue is in heap, not context, so it does not directly leak through the model — **but** the tool-call scratch buffer used to stage the PIR query was also reused, and a length-extension / buffer-reuse path in the staging code emits `T1` bytes into the `T2` response frame. Cross-tenant plaintext escapes. The observable signature is subtle: the attestation report is *valid at every step*. No signature check fails. The leak is only detectable by comparing the enclave's **memory lineage** (which tenants' plaintext has ever entered protected memory since the last `DOMAIN_RESET`) against the **claimed data domain** in the invocation envelope. The two diverge at step 2 and never re-converge. ## Condition of Validity The "attest once per session" invariant is valid **only if** the following holds: - `enclave_lifetime ⊆ single_data_domain`, i.e. the enclave is torn down (or a hardware-supported domain reset is executed) between any two distinct tenants, **and** - every tool invocation that stages tenant plaintext into a shared scratch region either zeroes that region on return or is itself a fresh enclave. When either condition fails — warm-pool reuse, scratch-buffer recycling, or a shared MPC preprocessing pool that persists across tenants — the cached quote no longer certifies the data domain. The correct invariant is: > **An attestation presented at a tool-call boundary must bind the current memory lineage, not merely the launch measurement.** Concretely, the quote must be accompanied by a fresh nonce and a monotonic `domain_epoch` that increments on every `DOMAIN_RESET`, and the verifier must reject any quote whose `domain_epoch` is older than the epoch the caller claims to be operating in. This is the boundary: attestation freshness (nonce) is necessary but *not sufficient*. A replayed-but-fresh quote from a warm enclave that has since absorbed another tenant's plaintext passes nonce checks and fails the lineage check. The nonce proves liveness; only the epoch proves domain isolation. ## Decision Boundary An instance must **re-attest with a domain-epoch binding** — not merely re-present a cached quote — at exactly these transitions: - **Before** the first tool call that stages plaintext for a *different* tenant than the one whose data is currently resident. (Trigger: `requested_domain != resident_domain`.) - **After** any tool returns, if the tool wrote into a shared scratch region and the region was not provably zeroed. (Trigger: `scratch_dirty == True`.) - **On resume from a checkpoint**, because a checkpoint restore rehydrates memory whose lineage is not implied by the current launch measurement. (This is the checkpoint/resume analogue: the restored heap may carry a prior tenant's pages.) It must **not** re-attest (and re-attesting is wasteful, not just harmless) on every call within a single tenant's continuous session — the epoch is unchanged, and forcing a full quote on every call collapses throughput on the PIR path. The decision is: re-attest iff `requested_domain != resident_domain OR scratch_dirty OR restored_from_checkpoint`. Otherwise the cached quote plus the current epoch is sound. The failure to bound this correctly goes both ways: attesting only at session start leaks (as above); attesting on *every* call is correct but the cost model must account for it, and teams that skip the cost analysis often "fix" the leak by disabling re-attestation under load — reintroducing it. ## Operational Effect Downstream, the leak is invisible to every component that only checks signatures. `E_B`'s policy engine sees `quote(M_A)` valid, `nonce` fresh, caller identity `T2` — all green. `E_C`'s auditor replays the transcript and sees a coherent `T2`-only story, because the `T1` bytes entered through a scratch-reuse path that the transcript never records (the staging buffer is not part of the signed message). The audit trail is *consistent and wrong*. The guardrail that bounds it is a **lineage ledger inside the enclave**: a monotonic counter `domain_epoch` plus a set of resident tenant IDs, both included in the signed attestation payload (not just the launch measurement). The verifier rejects any invocation where the caller's claimed domain is not a subset of the signed resident set, or where `domain_epoch` regressed. This converts an invisible cross-tenant leak into a hard, checkable refusal at the transport boundary — the same place MCP/A2A warrant propagation is supposed to enforce identity, extended to enforce *data-domain* identity. ```python class DataDomainAttestationError(RuntimeError): """Raised when an enclave attestation is valid for code identity but does not bind the current memory lineage / data domain.""" pass class EnclaveAttestation: def __init__(self, measurement: str, domain_epoch: int, resident_tenants: frozenset[str]): self.measurement = measurement self.domain_epoch = domain_epoch self.resident_tenants = resident_tenants class InvocationEnvelope: def __init__(self, claimed_tenant: str, claimed_epoch: int, attestation: EnclaveAttestation, scratch_dirty: bool, restored_from_checkpoint: bool): self.claimed_tenant = claimed_tenant self.claimed_epoch = claimed_epoch self.attestation = attestation self.scratch_dirty = scratch_dirty self.restored_from_checkpoint = restored_from_checkpoint def verify_tool_boundary(env: InvocationEnvelope, expected_measurement: str) -> None: att = env.attestation # 1. Code identity is necessary but NOT sufficient. if att.measurement != expected_measurement: raise DataDomainAttestationError( f"measurement mismatch: got {att.measurement!r}, expected {expected_measurement!r}" ) # 2. Epoch must not regress: a stale/older epoch means the enclave has since # absorbed other tenants' plaintext (warm-pool reuse). if env.claimed_epoch != att.domain_epoch: raise DataDomainAttestationError( f"domain epoch mismatch: caller claims {env.claimed_epoch}, " f"enclave signed {att.domain_epoch} — attestation does not bind current lineage" ) # 3. The claimed tenant must be a subset of the signed resident set. if env.claimed_tenant not in att.resident_tenants: raise DataDomainAttestationError( f"tenant {env.claimed_tenant!r} not in signed resident set " f"{sorted(att.resident_tenants)} — cross-domain invocation refused" ) # 4. Dirty scratch or checkpoint restore invalidates the domain guarantee # even when the epoch matches; require a DOMAIN_RESET before proceeding. if env.scratch_dirty or env.restored_from_checkpoint: raise DataDomainAttestationError( "scratch region dirty or enclave restored from checkpoint: " "memory lineage unverified — DOMAIN_RESET required before tool call" ) def guarded_tool_call(env: InvocationEnvelope, expected_measurement: str, tool): try: verify_tool_boundary(env, expected_measurement) except DataDomainAttestationError: # Refuse at the transport boundary; do not fall back to cached quote. raise return tool(env.claimed_tenant) ```