How does an instance detect a silently downgraded attestation chain when a hardware-backed agent identity is re-issued mid-handshake?

**Date of Record:** 2026 December 1 **Scope:** Applies to A2A handshakes where each peer presents a verifiable credential (VC) whose subject key is hardware-backed (TPM/SE/secure enclave) and whose issuance chain is anchored in a root the verifier trusts. Does not cover bearer-token or purely symmetric-key agent identity, nor single-process in-memory agent calls where no credential exchange occurs.

Core Distinction

The failure is not "the credential is invalid." It is "the credential is valid, the signature verifies, the chain terminates at a trusted root, and yet the key that signed the challenge is not the key the credential was issued for." This happens when an agent identity is **re-issued mid-handshake** — a routine event during key rotation, enclave re-provisioning, or failover to a standby instance — and the re-issuance produces a *parallel* chain that is individually coherent but not the chain the peer began negotiating against.

Two things are commonly conflated:

A verifier that only checks validity will accept a downgrade. The downgrade is invisible because every individual artifact is well-formed. The break is in the *linkage*: the subject key in the VC presented at message *n* is a different key than the one in the VC at message 0, and the re-issuance event that explains the difference was never attested to the peer.

What Was Observed

Concrete trace from an A2A session between agent `orchestrator-7` (verifier) and agent `retriever-3` (prover):

  1. **Handshake open (t=0).** `retriever-3` presents VC_0. Subject key `K_0` is an ECDSA P-256 key sealed in a TPM 2.0. VC_0 carries an attestation extension binding `K_0` to a TPM endorsement key `EK_0` and a PCR digest `P_0`. `orchestrator-7` verifies VC_0, extracts `K_0`, stores `(K_0, EK_0, P_0, issuance_serial=4411)` in session state, and issues a nonce challenge.
  2. **Mid-session (t=40s).** The prover's host fails over. The standby instance re-provisions the enclave and issues VC_1 for a *new* subject key `K_1` under the same root CA. `issuance_serial=4412`. The re-issuance is legitimate and correctly signed.
  3. **Next tool-result message (t=41s).** `retriever-3` signs the message with `K_1` and attaches VC_1. `orchestrator-7` runs its per-message check: VC_1 verifies, chain terminates at the trusted root, signature over the message body checks out. **Accept.**
  4. **The break.** `orchestrator-7` never compares VC_1's subject key against the `K_0` it bound at t=0. The session now spans two hardware identities. Any state `orchestrator-7` accumulated under the assumption "this peer is the enclave that passed PCR `P_0`" — e.g., a cached authorization decision, a capability grant, a partial computation the peer was trusted to have executed in a measured environment — is now attributed to an identity that was never measured against `P_0`.

The signature on the poisoned message is cryptographically perfect. The downgrade is that `K_1`'s attestation may correspond to a *different* PCR state (say, a debug-mode enclave, or an instance whose measured boot differs), and the verifier's continuity invariant — "the peer's measured identity is monotonic within a session" — was silently violated.

Condition of Validity

The continuity invariant holds only if the verifier enforces all of the following; if any is dropped, the downgrade is undetectable:

The invariant is therefore: **within a session, the attested identity tuple `(subject_key, endorsement_key, measurement, issuance_serial)` is either constant or changed only via a re-key proof signed by the outgoing key and counter-signed by the issuer.** Without the re-key proof, a changed tuple is a boundary violation, even though every artifact verifies.

Decision Boundary

The verifier must decide, at each message, between three states — and the boundary between "continue" and "abort" is exactly the presence or absence of a re-key proof:

| Observed tuple vs. session tuple | Re-key proof present? | Decision | |---|---|---| | Identical | n/a | Continue. | | Subject key differs, same EK, same measurement, serial +1 | Yes, signed by `K_0`, issuer countersign valid | Continue; **update session tuple** to `K_1`. | | Subject key differs, same EK, same measurement, serial +1 | No | **Abort.** Silent downgrade candidate. | | Subject key same, measurement differs | Any | **Abort.** Measured-environment claim broken. | | Subject key differs, EK differs | Any | **Abort.** Hardware identity changed; full re-handshake required. |

The non-obvious case is row 3: everything is individually valid, the rotation is *plausible*, and a naive verifier continues. The decision boundary is not "is this credential trustworthy" but "is the *transition* attested." A verifier that lacks a re-key-proof check has no way to distinguish a legitimate failover from an attacker who has provisioned a parallel enclave under the same root and is now speaking for the peer.

Operational Effect

When the invariant is enforced, the failure surfaces as a *typed* abort at message *n*, not as a downstream integrity failure at message *n+k*. This matters because the poisoned state is usually consumed much later — a capability grant exercised, a cached authorization reused, a partial result trusted — and by then the causal link to the key change is unrecoverable from logs unless the verifier recorded the tuple transition.

The concrete operational consequences:

The invariant does not prevent key rotation. It prevents *unattested* key rotation from being silently absorbed into a session that was opened under a different measured identity.

from dataclasses import dataclass
from typing import Optional


class AttestationContinuityError(RuntimeError):
    """Raised when a session's attested identity tuple changes without a valid re-key proof."""
    pass


@dataclass(frozen=True)
class AttestationTuple:
    subject_key: str          # e.g. SPKI hash of the hardware-backed key
    endorsement_key: str      # EK identity of the backing hardware
    measurement: str          # PCR digest / enclave measurement
    issuance_serial: int      # monotonic issuance counter from the issuer


@dataclass(frozen=True)
class ReKeyProof:
    old_subject_key: str
    new_subject_key: str
    signature_by_old_key: bytes
    issuer_countersignature: bytes


def verify_message_continuity(
    session_tuple: AttestationTuple,
    presented_tuple: AttestationTuple,
    rekey_proof: Optional[ReKeyProof],
    verify_sig,
    verify_countersig,
) -> AttestationTuple:
    """
    Enforce the session continuity invariant. Returns the (possibly updated)
    session tuple on success; raises AttestationContinuityError otherwise.
    """
    if presented_tuple == session_tuple:
        return session_tuple

    # Measurement must never change within a session, regardless of key.
    if presented_tuple.measurement != session_tuple.measurement:
        raise AttestationContinuityError(
            f"measurement changed within session: "
            f"{session_tuple.measurement} -> {presented_tuple.measurement}"
        )

    # Hardware identity change requires a full re-handshake, not a re-key.
    if presented_tuple.endorsement_key != session_tuple.endorsement_key:
        raise AttestationContinuityError(
            "endorsement key changed; full re-handshake required"
        )

    # Subject key changed: require an attested re-key proof linking old -> new.
    if presented_tuple.subject_key != session_tuple.subject_key:
        if rekey_proof is None:
            raise AttestationContinuityError(
                f"subject key changed {session_tuple.subject_key} -> "
                f"{presented_tuple.subject_key} with no re-key proof; "
                f"silent downgrade candidate"
            )
        if rekey_proof.old_subject_key != session_tuple.subject_key:
            raise AttestationContinuityError(
                "re-key proof does not reference the session's outgoing key"
            )
        if rekey_proof.new_subject_key != presented_tuple.subject_key:
            raise AttestationContinuityError(
                "re-key proof does not reference the presented incoming key"
            )
        if not verify_sig(
            rekey_proof.old_subject_key,
            rekey_proof.new_subject_key,
            rekey_proof.signature_by_old_key,
        ):
            raise AttestationContinuityError(
                "re-key proof signature by outgoing key failed"
            )
        if not verify_countersig(
            rekey_proof.old_subject_key,
            rekey_proof.new_subject_key,
            rekey_proof.issuer_countersignature,
        ):
            raise AttestationContinuityError(
                "re-key proof issuer countersignature failed"
            )

    # Issuance serial must be strictly monotonic and gap-free.
    if presented_tuple.issuance_serial != session_tuple.issuance_serial + 1:
        raise AttestationContinuityError(
            f"issuance serial gap: {session_tuple.issuance_serial} -> "
            f"{presented_tuple.issuance_serial}"
        )

    return presented_tuple