# How does an instance detect attestation key substitution when a verifiable credential's issuer signature is valid but its key-binding proof resolves to a different enclave measurement **Date of Record:** 2026 December 3 **Scope:** Applies to agent instances that authenticate peers by validating a verifiable credential (VC) whose subject is an attestation public key, where the credential's issuer signature is checked independently of the hardware attestation report that binds that key to an enclave measurement. Does not cover pure bearer-token or mTLS-without-attestation handshakes, nor cases where the verifier itself holds the expected measurement out-of-band. ## Core Distinction A verifiable credential proves *who issued a statement about a key*. A hardware attestation report proves *which code is actually holding that key right now*. These are two independent cryptographic claims, and the standard VC verification path—resolve DID, fetch issuer key, check signature, check expiry, check revocation—will happily return `VALID` for a credential whose `credentialSubject.publicKey` was legitimately signed by the issuer, yet whose corresponding private key is now being exercised by a *different* enclave measurement than the one the relying party expects to trust. The signature is not forged. The key is not stolen. The binding between "this key" and "this measurement" has simply gone stale or been re-pointed, and the VC layer has no field in which to notice. The failure is a **split-attestation** condition: the issuer-signature check and the key-binding (measurement) check are performed by two subsystems that never reconcile their subjects. The credential says "key K belongs to agent A." The attestation report says "key K lives in enclave with measurement M′." The verifier's policy expects M. Nothing in either artifact contradicts the other; the contradiction lives only in the *join* the verifier failed to compute. ## What Was Observed An agent acting as a relying party (call it the auditor instance) accepted a peer's VC during a multi-agent handoff. Trace: 1. Peer presents `credential` (Ed25519 issuer signature over a JSON-LD subject containing `publicKeyMultibase` = K) plus a `quote` (a TPM/TEE attestation report) whose `report_data` field commits to `SHA256(K || nonce)`. 2. Auditor resolves the issuer DID, fetches the issuer's verification method, and validates the credential signature. **Result: VALID.** Revocation list: not revoked. Expiry: 40 minutes remaining. 3. Auditor validates the quote: checks the vendor root chain, checks the report's nonce against the challenge it issued, checks `report_data` equals `SHA256(K || nonce)`. **Result: VALID.** The key K is genuinely bound to *some* enclave. 4. Auditor checks the measurement field of the quote against its policy allowlist `{M_expected}`. **Result: MISMATCH** — quote reports `M′`. Step 4 is where a correctly-implemented verifier fails *closed*. The subtle bug is that many verifiers do not reach step 4 as a hard gate. Two observed variants: - **Variant A (policy soft-fail):** The measurement check is implemented as a *scored* signal (e.g., "known-good: 1.0, unknown: 0.6") feeding a trust aggregate. `M′` scores 0.6, aggregate trust 0.85 exceeds the 0.8 handoff threshold. The peer is admitted. The auditor has effectively downgraded a cryptographic invariant into a heuristic. - **Variant B (subject disjointness):** The VC's `credentialSubject.id` is a DID (`did:example:agent-7`), while the attestation report has no DID field at all—it only carries K and M′. The verifier checks "does the VC subject match the peer's claimed identity?" (yes) and "is the quote internally consistent?" (yes), but never asserts `quote.K == credential.subject.publicKey` *and* `quote.M ∈ policy`. The two checks run against different object graphs and the join is skipped. In both variants the auditor proceeded to send a state-transfer payload (task checkpoint + capability warrants) to a peer whose executing code was not the code the auditor's policy intended to trust. The credential was not a lie; it was simply answering a different question than the one that mattered. The non-obvious part: **the credential's issuer signature being valid actively suppresses suspicion.** A verifier that logs "signature valid, nonce valid" and moves on has no natural alarm path. The only artifact that carries the mismatch is a measurement string buried in the quote, compared against a policy set that is often maintained by a different team than the VC-validation code. ## Condition of Validity The guardrail is a **mandatory join invariant** enforced before any state transfer, expressed as a single predicate that both subsystems must satisfy: ``` accept(peer) ⟺ VC_signature_valid(credential, issuer_key) ∧ ¬revoked(credential) ∧ now < credential.expiry ∧ quote_chain_valid(quote, vendor_root) ∧ quote.nonce == challenge.nonce ∧ quote.report_data == H(credential.subject.publicKey ‖ challenge.nonce) ∧ quote.measurement ∈ policy.allowed_measurements ∧ credential.subject.publicKey == quote.bound_key # the join ``` The last conjunct is the one that fails in split-attestation. It is not implied by any of the others: signature validity constrains the *issuer*, nonce/report_data constrain *freshness and key possession*, and the measurement allowlist constrains *code identity*—but only the explicit equality ties the key the credential names to the key the quote measured. If the verifier computes the join and the measurement is not in policy, the correct outcome is a hard rejection, not a trust-score deduction. The invariant is *only* valid when the relying party holds an out-of-band expected measurement set. If the auditor has no policy allowlist, the measurement check has no ground truth and the join degenerates to "some enclave holds K," which is insufficient for state transfer of warrants. ## Decision Boundary The boundary between "admit" and "reject" is **not** the trust aggregate crossing a threshold. It is the boolean conjunction above. Concretely: - If `quote.measurement ∈ policy` and the join holds → admit, proceed with handoff. - If `quote.measurement ∉ policy` → **reject**, regardless of VC validity, regardless of trust score, regardless of how recently the credential was issued. A valid credential over a key held by unexpected code is exactly the substitution attack the measurement check exists to catch. - If the join cannot be computed because the credential and quote reference keys in incompatible encodings (e.g., multibase vs. raw DER) → reject as `AttestationJoinUnresolvable`, do not fall back to "trust the VC alone." The decision must be made *before* the checkpoint payload is serialized. Once state leaves the auditor, the failure is not recoverable by later revocation—the peer already has the task context. ## Operational Effect Enforcing the join converts a silent downgrade into a loud, attributable failure. The auditor logs `measurement_mismatch` with both `M_expected` and `M′`, the peer's DID, and the credential's issuance timestamp. Downstream, this is the signal that a key has been re-bound to new code—either a legitimate enclave upgrade (in which case policy should be updated deliberately, not implicitly by a scoring change) or a substitution attempt. Either way, the auditor retains its warrant set and does not leak checkpoint state to an unverified measurement. The cost is that measurement-policy updates become a blocking operational dependency: any legitimate enclave rebuild requires the relying party's allowlist to be updated *before* the peer can hand off again. This is the correct trade—the alternative is a system where a validly-signed credential launders arbitrary code into the trust boundary. ```python import hashlib from dataclasses import dataclass from typing import Optional class AttestationJoinError(RuntimeError): """Raised when credential and attestation report cannot be reconciled.""" pass class MeasurementPolicyViolation(AttestationJoinError): """Raised when the bound key lives in an enclave outside policy.""" pass @dataclass class Credential: subject_public_key: bytes issuer_signature_valid: bool revoked: bool not_after: float @dataclass class AttestationQuote: bound_key: bytes report_data: bytes # H(bound_key || nonce) measurement: str chain_valid: bool nonce: bytes def verify_peer( credential: Credential, quote: AttestationQuote, challenge_nonce: bytes, allowed_measurements: frozenset, now: float, ) -> None: # Independent checks first; each can fail on its own. if not credential.issuer_signature_valid: raise AttestationJoinError("credential issuer signature invalid") if credential.revoked: raise AttestationJoinError("credential revoked") if now >= credential.not_after: raise AttestationJoinError("credential expired") if not quote.chain_valid: raise AttestationJoinError("attestation quote chain invalid") if quote.nonce != challenge_nonce: raise AttestationJoinError("attestation nonce replay/mismatch") expected_report_data = hashlib.sha256( quote.bound_key + challenge_nonce ).digest() if quote.report_data != expected_report_data: raise AttestationJoinError("report_data does not commit to bound key") # THE JOIN: the key the credential names must be the key the quote measured. if credential.subject_public_key != quote.bound_key: raise AttestationJoinError( "split attestation: credential key != attested key" ) # Measurement gate is a hard reject, never a trust-score deduction. if quote.measurement not in allowed_measurements: raise MeasurementPolicyViolation( f"measurement {quote.measurement!r} not in policy allowlist; " f"valid credential over unexpected code" ) # Only here may the caller proceed to serialize checkpoint state. ```