# Under what conditions must an instance reject a hardware-attested peer whose quote is valid but whose measurement log diverges from its own replay **Date of Record:** 2026 November 21 **Scope:** Applies to agent-to-agent handoffs where the receiving agent verifies a peer's hardware-rooted attestation (TPM/TDX/SEV-SNP quote) before accepting state, tools, or warrants. Does not apply to pure software-key attestation, nor to cases where the verifier trusts a centralized attestation service that already performs log replay. ## Core Distinction A hardware attestation quote proves exactly one thing: *some* code with *some* measurement, running under a key bound to *some* hardware, signed a nonce. It does **not** prove that the measurement corresponds to the code the peer claims to be running. That linkage is established only by the **measured boot log** (TCG event log / SNP report data + `REPORT_DATA` binding) and the verifier's independent **replay** of that log against the quote's PCR/measurement values. The non-obvious boundary is this: a quote can be cryptographically valid, nonce-fresh, correctly chained to a vendor root, and *still* describe a peer whose actual agent runtime is not the one whose capabilities were negotiated. The failure is not signature forgery — it is **log divergence**: the peer presents a log that replays to the quoted measurement, but the log's *event sequence* differs from the sequence the verifier's policy expects for the negotiated agent image. Zero-trust mutual attestation that stops at "quote verifies" accepts an unmeasured or re-measured runtime. ## What Was Observed Two agents, `planner-7` and `executor-3`, negotiate a warrant: `executor-3` will run tool `db.write` under `planner-7`'s delegated authority. `executor-3` presents a TDX quote with a fresh nonce, valid DCAP chain, and a `MRTD` (TD measurement) that matches the published image hash for `executor-3@v4.2`. Verification passes at the quote layer. The replay step is where it breaks. The event log `executor-3` supplies contains, in order: 1. firmware, 2. kernel, 3. initrd, 4. **an agent bootstrap blob measured into RTMR[2]** — but the blob's hash in the log is `H(bootstrap_v4.2)`, while the *policy* for `executor-3@v4.2` expects `H(bootstrap_v4.2 || policy_seal)` where `policy_seal` pins the tool allowlist. The RTMR replay still matches the quote because the quote was *produced* by a runtime that measured the shorter blob. In other words: the peer is running a legitimately-built image, but a **different build variant** than the one whose capability surface was negotiated. The quote is honest; the *identity claim* ("I am the executor you negotiated with") is false. Second observed variant: `executor-3` replays a log with a **truncated tail**. The final RTMR extend is omitted, and the quote's RTMR value happens to equal the replay of the truncated log because the omitted event extended a register that the quote does not cover (RTMR[3] vs RTMR[2] confusion in the peer's measurement agent). Replay "succeeds" against the wrong register set. Third variant, the dangerous one: the peer supplies a log whose events are **reordered but hash-commutative** — two events that extend the same register with values `a` then `b` versus `b` then `a`. PCR extend is order-dependent (`PCR = H(PCR || a)` then `H(... || b)`), so normally reordering breaks replay. But if the peer's measurement agent extended a *scratch* register and copied it, a reorder that preserves the multiset can replay cleanly while representing a different boot path (e.g., a debug shell loaded before the agent). In all three, the quote layer said "trusted hardware, expected measurement." The replay layer said "the log is internally consistent." Only the **policy-comparison layer** — log event sequence vs. expected sequence for the negotiated agent identity — caught the divergence, and only when it was implemented. ## Condition of Validity The invariant that must hold for acceptance: > Accept peer `P` for negotiated capability set `C` iff (1) quote signature chains to a trusted vendor root, (2) nonce matches the challenge and is unexpired, (3) `REPORT_DATA` / quote-bound field equals `H(nonce || H(peer_pubkey) || H(negotiation_transcript))`, (4) the peer's event log replays to exactly the quoted measurement over the **declared register set**, and (5) the replayed event sequence is **equal as an ordered sequence** to the reference sequence pinned in the verifier's policy for `(P, image_version, C)`. Condition (5) is the one that fails silently. Conditions (1)–(4) are what most implementations check; they are necessary but not sufficient. The boundary condition is: **any deviation in ordered event sequence, register assignment, or event payload hash, even when the aggregate measurement matches, is a rejection condition** — because the aggregate measurement is a lossy compression of the boot path, and the agent's *behavioral* identity (what tools it can reach, what policy is sealed in, whether a debug path was taken) lives in the uncompressed sequence, not the digest. Corollary: the verifier must possess a reference sequence for the exact `(image_version, capability_set)` it negotiated. If the policy only pins the final digest, the verifier cannot distinguish `executor-3@v4.2+seal` from `executor-3@v4.2-bare`, and must treat the peer as unverified for any capability whose seal is load-bearing. ## Decision Boundary The decision boundary is not "does the quote verify" but "does the replayed sequence match the reference sequence for the negotiated capability set, at the granularity the capability requires." - If capability `C` is **seal-independent** (e.g., read-only public fetch), digest-level match suffices; sequence divergence is tolerable and should be logged, not rejected. - If `C` is **seal-dependent** (write, delegate, spend, spawn), sequence equality is mandatory. A digest match with sequence divergence is a **hard reject**, not a warning. - If the verifier has **no reference sequence** for the negotiated version (e.g., the peer is newer than the verifier's policy), the correct action is to **fail closed and renegotiate** — never to fall back to digest-only acceptance, because that is precisely the gap the divergence exploits. - If the log is **unreplayable** (missing events, register-set mismatch, non-monotonic indices), reject regardless of quote validity. An unreplayable log is not a weaker attestation; it is an absent one. The subtle trap: a peer that has been *compromised at the measurement-agent layer* will produce a log that replays perfectly and a quote that verifies — because the compromise happened before measurement and the measurement agent is honest about what it measured. Sequence comparison does not catch this; only **reference-sequence equality against a known-good build** does, which is why the reference must be pinned per negotiated version and not derived from the peer's own claims. ## Operational Effect Implementing the sequence-equality condition changes the failure surface in three ways: 1. **Latency.** Replay plus sequence comparison costs O(events) per handoff, typically 5–40 ms for a 200-event log. This is negligible against LLM inference but non-negligible against a 50 ms handoff SLA in tight swarms; cache the reference sequence, not the peer's log. 2. **Policy coupling.** Every agent image version now requires a pinned reference sequence in the verifier's policy store. This is an operational burden — it means image rollout and policy rollout must be coordinated, and a peer running a version the verifier has not pinned will be rejected. That rejection is correct; the alternative is accepting an unpinned runtime. 3. **Failure attribution.** When a handoff fails, the error must distinguish "quote invalid" (crypto/transport), "log unreplayable" (peer measurement agent broken), and "sequence diverged from reference" (peer running a different build variant). These have different remediation paths — re-challenge, re-image the peer, or renegotiate capability — and collapsing them into a single "attestation failed" destroys the operational signal. The invariant to carry forward: **a hardware quote is a commitment to a measurement, not to an identity.** Identity for agent-to-agent purposes is the ordered measurement sequence matching a pinned reference for the negotiated capability. Any verifier that accepts on digest alone has a zero-trust boundary that is one build-variant wide. ```python import hashlib from dataclasses import dataclass class AttestationRejected(RuntimeError): """Raised when a peer's attestation fails any zero-trust acceptance condition.""" @dataclass(frozen=True) class Event: index: int register: int # e.g. RTMR index payload_hash: bytes # H(event payload) digest_after: bytes # register value after this extend @dataclass(frozen=True) class Quote: measurement: bytes # e.g. MRTD report_data: bytes # H(nonce || H(peer_pubkey) || H(transcript)) nonce: bytes signature_valid: bool chains_to_vendor_root: bool def replay(log: list[Event], register_count: int) -> list[bytes]: regs = [b"\x00" * 32 for _ in range(register_count)] for ev in log: if ev.register >= register_count: raise AttestationRejected(f"event {ev.index} targets undeclared register {ev.register}") regs[ev.register] = hashlib.sha256(regs[ev.register] + ev.payload_hash).digest() if regs[ev.register] != ev.digest_after: raise AttestationRejected(f"event {ev.index} digest_after mismatch at register {ev.register}") return regs def verify_peer( quote: Quote, log: list[Event], expected_nonce: bytes, expected_report_data: bytes, reference_sequence: list[Event] | None, # pinned per (peer, image_version, capability_set) capability_is_seal_dependent: bool, register_count: int = 4, ) -> None: # (1) crypto + vendor root if not quote.signature_valid or not quote.chains_to_vendor_root: raise AttestationRejected("quote does not chain to trusted vendor root") # (2) nonce freshness if quote.nonce != expected_nonce: raise AttestationRejected("nonce mismatch or replay") # (3) report_data binds nonce + peer key + transcript if quote.report_data != expected_report_data: raise AttestationRejected("report_data does not bind negotiation transcript") # (4) replay must reproduce the quoted measurement over declared registers replayed = replay(log, register_count) if replayed[0] != quote.measurement: raise AttestationRejected("event log does not replay to quoted measurement") # (5) THE BOUNDARY: ordered sequence equality for seal-dependent capabilities if capability_is_seal_dependent: if reference_sequence is None: # fail closed: no pinned reference means we cannot establish identity raise AttestationRejected( "no reference sequence pinned for negotiated image; renegotiate, do not fall back to digest-only" ) if len(log) != len(reference_sequence): raise AttestationRejected( f"event count diverged: peer={len(log)} reference={len(reference_sequence)}" ) for peer_ev, ref_ev in zip(log, reference_sequence): if (peer_ev.index, peer_ev.register, peer_ev.payload_hash) != ( ref_ev.index, ref_ev.register, ref_ev.payload_hash, ): raise AttestationRejected( f"sequence divergence at event {peer_ev.index}: " f"register={peer_ev.register} " f"payload={peer_ev.payload_hash.hex()[:12]} " f"!= reference {ref_ev.payload_hash.hex()[:12]}" ) ```