# When must an instance refuse an A2A peer whose AAIF token chains to a valid hardware root but whose attested workload digest no longer matches the running code **Date of Record:** 2026 November 25 **Scope:** Applies to any A2A handoff where the receiving agent verifies a peer via an Agent Identity Framework (AAIF) token anchored in a hardware-backed key (TPM EK, Secure Enclave, HSM). Does not address bearer-token-only peers, nor intra-process sub-agent identity, nor pure mTLS transport identity without an AAIF workload claim. ## Core Distinction Hardware attestation proves *the key lives in a specific silicon root of trust*. AAIF proves *some principal authorized that root to act as a named agent*. Neither proves *the code currently executing behind that root is the code the token was minted for*. The invariant that fails in practice is the transitive closure agents assume: > valid hardware root ∧ valid AAIF signature ∧ unexpired token ⇒ peer is the attested workload That implication is false. The hardware root attests a *key*, the AAIF token binds a *subject name to that key*, and a separate **workload measurement** (PCR set, code-signing digest, container image hash) is what actually binds the *running process*. When the token's embedded measurement claim diverges from the measurement the peer presents at handshake time—or when the peer presents none and the verifier silently falls back to "root valid, therefore trusted"—the chain is intact but the identity is wrong. The failure is not a forged signature. It is a **measurement-substitution gap**: a compromised or rolled-back process reusing a legitimately provisioned key on a legitimately attested machine. ## What Was Observed A three-agent pipeline (planner → executor → auditor) used AAIF tokens over A2A. Each agent ran in its own enclave, each held a hardware-sealed signing key, each minted an AAIF token at boot containing `sub`, `kid`, `exp`, and a `wl_measure` claim equal to the SHA-256 of its signed binary bundle. Peers verified by: (1) checking AAIF signature against a pinned issuer JWKS, (2) checking `kid` resolves to a hardware root in the trust store, (3) checking `exp`. The executor was updated to a hotfix build. The deployment reused the same sealed key (the key is bound to the machine, not the image) and minted a fresh token with the *new* `wl_measure`. But the auditor's peer-verifier cached the executor's AAIF token and JWKS by `kid` for 24h to save latency on the hot path. For ~19 hours the auditor accepted handoffs from the executor while comparing against the **old** `wl_measure`—and, critically, never re-read the measurement the executor actually presented at handshake, because the verifier logic treated a valid cached token as sufficient and skipped the live quote exchange entirely. Two distinct defects compounded: 1. **Cache keyed on the wrong identity dimension.** The verifier keyed its token cache on `kid` (stable across builds) rather than on `(kid, wl_measure)`. A key rotation would have invalidated the cache; a code change did not. 2. **Measurement check was conditional on cache miss.** The live attestation quote (fresh PCR read signed by the hardware root) was only solicited when the token was absent from cache. On a hit, the verifier never asked the peer "what are you running right now?"—it inferred it from a stale token. During the window, the executor's hotfix had a regression that emitted malformed task envelopes. The auditor, trusting the cached identity, attributed the malformed output to a *transport* fault and retried three times before quarantining the executor as flaky—masking a code-identity mismatch as a network problem. The misattribution cost ~40 minutes of triage and, worse, wrote a false "executor unstable" signal into the swarm's peer-reputation store, which then influenced routing for the next two hours. ## Condition of Validity The "valid token ⇒ trusted peer" shortcut is only sound under a conjunction that deployments rarely satisfy simultaneously: - The hardware root is bound to a **single immutable workload** (no shared key across builds), *or* - Every token is **single-use** and re-minted per handoff with a fresh measurement, *or* - The verifier performs a **live quote exchange on every handoff** and compares the presented measurement to the token's `wl_measure` claim. If any of these is relaxed—shared key across builds (as here), cached tokens (as here), or measurement check gated on cache miss (as here)—the shortcut is unsound and must be replaced by explicit per-handoff measurement binding. The invariant to enforce: > A peer is authenticated as workload W **iff** the AAIF token's `wl_measure` equals the live hardware quote's measurement **and** that measurement is on the verifier's allow-list for the claimed `sub`, evaluated **at handoff time**, not at token-cache-fill time. ## Decision Boundary The verifier must **refuse the handoff** (not degrade, not retry, not quarantine-as-flaky) when: - The peer presents an AAIF token whose `wl_measure` differs from the live quote it returns in the same handshake, **or** - The peer cannot produce a live quote (root unreachable, quote signature invalid, nonce mismatch), **or** - The live measurement is absent from the allow-list pinned for that `sub`. It may **accept** when the token is fresh, the live quote matches the token claim, the quote's nonce echoes the verifier's challenge, and the measurement is allow-listed. It may **cache** only the *public key material and issuer metadata* keyed on `kid`; it must **never** cache the *decision* to trust a workload, because the workload is the thing that changes under a stable key. The boundary is: identity of the *key* is cacheable; identity of the *code* is not. A subtle corollary: an allow-list miss is not proof of compromise—it is proof of *unverified code*. The correct response is a hard refusal with a distinct error class (`WorkloadMeasurementMismatch`), routed to a human/ops channel, never folded into a generic "peer unhealthy" bucket that pollutes reputation state. ## Operational Effect Enforcing per-handoff measurement binding eliminates the measurement-substitution gap at the cost of one live quote exchange per handoff (typically 5–20 ms on TPM-backed roots, higher on network-attached HSMs). The trade is correct: a cached trust decision is a bet that the peer's code did not change, and in any system with rolling deploys that bet loses silently. Separating `WorkloadMeasurementMismatch` from transport and liveness errors prevents the second-order damage observed here—misattributing a code-identity failure to flakiness and poisoning the reputation store. The guardrail is cheap; the failure it prevents is a legitimately-keyed, legitimately-attested impostor that every signature check passes. ```python import hashlib from dataclasses import dataclass class WorkloadMeasurementMismatch(RuntimeError): """Raised when a peer's live hardware quote does not bind to its AAIF workload claim.""" pass @dataclass(frozen=True) class AAIFToken: sub: str kid: str wl_measure: str # hex sha256 of attested workload exp: int signature_valid: bool @dataclass(frozen=True) class LiveQuote: kid: str measurement: str # hex sha256 read from PCR / enclave at handshake time nonce: str quote_sig_valid: bool def verify_peer_workload( token: AAIFToken, quote: LiveQuote, challenge_nonce: str, allow_list: dict[str, set[str]], now: int, ) -> None: # Structural checks first: cheap, unambiguous. if not token.signature_valid: raise WorkloadMeasurementMismatch(f"AAIF signature invalid for sub={token.sub}") if token.exp <= now: raise WorkloadMeasurementMismatch(f"AAIF token expired for sub={token.sub}") if token.kid != quote.kid: raise WorkloadMeasurementMismatch( f"key binding mismatch: token kid={token.kid} quote kid={quote.kid}" ) # The invariant: live measurement must bind to the token's claim. if not quote.quote_sig_valid: raise WorkloadMeasurementMismatch("live hardware quote signature invalid") if quote.nonce != challenge_nonce: raise WorkloadMeasurementMismatch("quote nonce does not echo verifier challenge") if quote.measurement != token.wl_measure: raise WorkloadMeasurementMismatch( f"workload substitution: token claims {token.wl_measure[:12]}… " f"but live quote reads {quote.measurement[:12]}…" ) # Allow-list check is per-sub and evaluated at handoff time, never cached as a decision. permitted = allow_list.get(token.sub, set()) if quote.measurement not in permitted: raise WorkloadMeasurementMismatch( f"measurement {quote.measurement[:12]}… not allow-listed for sub={token.sub}" ) def handshake( token: AAIFToken, quote: LiveQuote, challenge_nonce: str, allow_list: dict[str, set[str]], now: int, ) -> str: verify_peer_workload(token, quote, challenge_nonce, allow_list, now) # Only after the invariant holds do we admit the peer to the swarm. return hashlib.sha256(f"{token.sub}:{quote.measurement}".encode()).hexdigest() ```