How does an instance detect posture-attestation regression when its hardware-backed identity key outlives the TPM quote it was bound to

**Date of Record:** 2026 December 2 **Scope:** Applies to long-lived agent instances whose A2A/MCP identity is anchored to a hardware-backed key (TPM 2.0 EK/AK, Secure Enclave, or vTPM-backed AK) and whose authorization is gated on a *continuous* posture signal (PCR quote, measured-boot log, or signed runtime integrity claim) re-verified per request. Does not apply to short-lived bearer tokens, to purely software-attested identities, or to deployments where posture is checked only at enrollment.

Core Distinction

The failure mode here is not key compromise and not signature forgery. It is a **temporal decoupling between the identity key's validity horizon and the posture quote's freshness horizon**. The hardware key is durable: it survives reboots, kernel upgrades, and firmware updates, and its certificate chain verifies indefinitely. The posture quote is perishable: it attests the PCR state of a *specific boot instance* at a *specific nonce*. When an agent instance resumes after a suspend, a live-migration, or a vTPM re-seal, the key still signs correctly and the peer's signature check still passes — but the quote it presents is either stale (bound to a nonce the verifier already consumed) or bound to a boot measurement that no longer describes the running image.

The non-obvious part: **the attestation protocol succeeds at every individual step while the composite invariant — "the entity that holds the key is the entity the quote describes, right now" — is violated.** Standard verifiers check (a) key-chain validity, (b) quote signature over nonce, (c) PCR digest match against a known-good policy. They do not check that the *key-handle* that produced the quote is the same handle that produced the identity signature, nor that the quote's boot epoch matches the key's current seal epoch. That cross-binding is the invariant that silently breaks.

What Was Observed

An agent worker (`worker-7`) was enrolled with an AK whose private key was sealed to PCR[0,2,4,7] (firmware, option ROM, bootloader, Secure Boot policy). The identity certificate chained to the AK's endorsement. Per-request, the agent presented: identity signature over the request, plus a TPM quote over a verifier-supplied nonce with a PCR digest. The verifier (`gateway`) checked the quote signature against the AK public key from the enrollment record, checked the nonce was fresh (single-use cache, 60s TTL), and checked the PCR digest against the policy.

At 03:14 the host applied a firmware update. PCR[0] changed. The agent process did not restart — it was a long-running supervisor that had survived a `kexec` into the new kernel but the TPM was *not* re-initialized; the AK remained loaded in the TPM's transient object space, and the seal policy was now unsatisfied for *new* unseal operations, but the already-loaded key handle continued to sign. The agent kept serving.

The verifier's PCR policy engine had a **grace window**: on a policy mismatch it logged and, for a configurable 10-minute period, accepted the *previous* known-good digest to avoid disrupting rolling updates. During that window `worker-7` presented quotes whose PCR digest matched the *pre-update* policy. The verifier accepted them — not because they were forged, but because the grace logic compared the digest to a cached policy snapshot keyed on the enrollment record, not on the boot epoch.

The break: the agent was now running the new firmware image (unmeasured, PCR[0] = new value) while attesting the old PCR set from a cached snapshot. The quote itself was **replayed from a pre-update capture** — the agent's quote-supply path had cached the last successful quote per-nonce-class and, under a race where the nonce arrived during TPM busy, fell back to the cached quote. Because the nonce was fresh and the signature valid, the verifier's nonce check passed; because the digest matched the cached policy, the policy check passed. The agent was authorized for 10 minutes under a posture it did not have.

The observable symptom was not an auth failure. It was a **posture divergence**: `worker-7` executed tool calls that the *new* firmware's SELinux policy should have blocked (the policy was loaded from the measured image, but the agent's authorization had been granted against the old posture claim). The gateway's audit log showed `posture=OK, epoch=pre-update` next to `image_epoch=post-update` — a field mismatch no check compared.

Condition of Validity

The invariant that must hold is a **triple binding**, not a pair:

  1. `sig_identity` verifies under `AK_pub` — the key is the enrolled identity.
  2. `quote.pcr_digest == policy(boot_epoch)` — the measurements match a policy for *some* epoch.
  3. `quote.nonce == request.nonce` AND `quote.boot_epoch == current_boot_epoch(AK_handle)` — the quote describes the *running* boot, and the key handle that signed the identity is the handle that produced this quote in this boot.

Condition 3 is the one that fails silently. A quote is only meaningful relative to a boot epoch; the AK's seal policy is evaluated at unseal time, but a *loaded* handle bypasses the seal re-check. Therefore the verifier must obtain `current_boot_epoch` from a source the agent cannot influence — typically the TPM's `TPM2_ReadClock` or a monotonic boot counter signed into the quote's `extraData`, cross-checked against the enrollment record's last-seen epoch. If the verifier cannot establish that the quote's epoch equals the key's live epoch, the triple binding is unproven and the request must be treated as un-attested.

The grace window is only valid if it is keyed on `(enrollment_id, boot_epoch)` and refuses to accept a quote whose `boot_epoch` is older than the epoch in which the policy mismatch was first observed. A grace window keyed only on `enrollment_id` will accept replayed pre-update quotes indefinitely within its TTL.

Decision Boundary

The boundary is: **does the verifier treat the posture quote as a property of the key, or as a property of the boot instance?** If the former, replay and epoch-skew are invisible. If the latter, the verifier must maintain a per-boot-epoch posture state machine and reject any quote whose epoch does not match the epoch under which the identity signature was produced.

Concretely, the gateway must fail closed when:

The first two are cheap epoch comparisons. The third requires the policy engine to store `(digest, epoch)` tuples rather than bare digests, and to refuse cross-epoch comparison even inside a grace window.

Operational Effect

With the triple binding enforced, the 03:14 event resolves correctly: the agent's post-`kexec` quote carries `boot_epoch = N+1`; the verifier's `last_observed_epoch` for `worker-7` is `N`; the quote's digest matches the `N` policy snapshot but its epoch is `N+1`, so the cross-epoch check fails and the request is denied with `PostureEpochMismatch`. The agent's supervisor receives a 401-equivalent, tears down the stale AK handle, re-initializes the TPM, re-unseals under the new PCR policy, and re-enrolls its posture claim. Downtime is one re-attestation cycle (~2–4s), not a 10-minute unauthorized window.

Without the binding, the failure is not detectable from any single log line — it requires correlating `posture_epoch` against `image_epoch` in the audit stream, which most gateways do not emit. The practical guardrail is to make `boot_epoch` a first-class field in every attestation record and to assert its equality across the identity signature, the quote, and the policy snapshot at the point of admission, not in a downstream reconciler.

class PostureEpochMismatch(RuntimeError):
    """Raised when an attestation's posture quote does not describe the boot
    epoch under which the identity signature was produced, or regresses
    behind the last observed epoch for the enrollment."""
    pass


def admit_request(
    enrollment_id: str,
    identity_sig_epoch: int,
    quote: dict,                  # {"boot_epoch": int, "pcr_digest": str, "nonce": str}
    request_nonce: str,
    policy_store: dict,           # epoch -> expected pcr_digest
    last_observed_epoch: dict,    # enrollment_id -> int
    nonce_cache: dict,            # nonce -> {"epoch": int, "digest": str}
) -> bool:
    # 1. nonce freshness (single-use)
    if quote["nonce"] != request_nonce or request_nonce in nonce_cache:
        return False

    # 2. epoch consistency across identity signature and quote
    if quote["boot_epoch"] != identity_sig_epoch:
        raise PostureEpochMismatch(
            f"{enrollment_id}: identity signed under epoch {identity_sig_epoch} "
            f"but quote attests epoch {quote['boot_epoch']}"
        )

    # 3. monotonic epoch: reject regression (replay of an older boot's posture)
    prior = last_observed_epoch.get(enrollment_id)
    if prior is not None and quote["boot_epoch"] < prior:
        raise PostureEpochMismatch(
            f"{enrollment_id}: quote epoch {quote['boot_epoch']} regresses "
            f"behind last observed {prior}"
        )

    # 4. policy check MUST be same-epoch; no cross-epoch grace comparison
    expected = policy_store.get(quote["boot_epoch"])
    if expected is None:
        raise PostureEpochMismatch(
            f"{enrollment_id}: no policy snapshot for epoch {quote['boot_epoch']}"
        )
    if quote["pcr_digest"] != expected:
        return False

    # 5. commit: advance epoch, consume nonce
    last_observed_epoch[enrollment_id] = quote["boot_epoch"]
    nonce_cache[request_nonce] = {
        "epoch": quote["boot_epoch"],
        "digest": quote["pcr_digest"],
    }
    return True