# What happens when an instance validates an A2A Agent Card signature against a stale JWKS during capability re-negotiation **Date of Record:** 2026 December 3 **Scope:** Applies to A2A v1.0 deployments where an orchestrator discovers remote agents via signed Agent Cards, caches the signing key set (JWKS), and re-validates capability manifests on task handoff. Does not apply to unsigned/trust-on-first-use discovery or to in-process tool registries. ## Core Distinction There are two distinct notions of "the Agent Card is valid" in A2A v1.0, and conflating them is the root of this failure: 1. **Signature validity** — the JWS over the Agent Card payload verifies against *some* key in the cached JWKS. 2. **Manifest freshness under the signer's current key epoch** — the Card was signed by a key the signer *currently* asserts as authoritative, not merely a key that was authoritative at cache-fill time. A cached JWKS is a *historical* assertion. The remote agent's key rotation is a *current* assertion. When the orchestrator validates a freshly-fetched Agent Card against the historical key set, a rotated-out key can still verify a Card that the signer no longer vouches for — or, symmetrically, a new key's Card fails verification and the orchestrator falls back to a *cached, stale capability manifest* that still declares capabilities the remote agent has since revoked. Both directions produce a task lifecycle state machine that transitions into states the remote peer will not honor. ## What Was Observed An orchestrator (caller) maintained a per-peer JWKS cache with a 24h TTL. Peer `planner-07` rotated its signing key at T+0 and re-published its Agent Card at T+1m, dropping the `tasks/resume` capability (it had migrated resume semantics to a new endpoint requiring a newer protocol minor version) and narrowing `supportedTransports` to `["jsonrpc"]`. At T+2m the orchestrator, mid-task on a long-running plan, needed to resume a checkpointed subtask. It performed capability re-negotiation: - Fetched the new Agent Card. - Attempted JWS verification against the *cached* JWKS (old key only). - Verification failed with `kid` mismatch — but the orchestrator's error handler treated verification failure as *transient* (the established pattern for network flakiness) and **fell back to the last-known-good cached Card**. - The cached Card still advertised `tasks/resume` and `supportedTransports: ["jsonrpc","grpc"]`. The orchestrator then issued `tasks/resume` over gRPC. The peer, running the new manifest, rejected the transport binding (`-32600 unsupported transport`) and, more damagingly, the resume attempt arrived at a peer that had *no checkpoint* for that task ID because it had reaped it under new retention semantics. The orchestrator's lifecycle state machine had `resume → RESUMED` as a legal transition on the *cached* manifest, so it marked the task `RESUMED` locally while the peer held no such task. The divergence was not detected until a downstream `tasks/get` returned `TASK_NOT_FOUND` — 40 seconds of downstream work executed against a phantom task. The non-obvious part: **the failure was not the signature check.** The signature check correctly failed. The failure was the *semantic mismatch between "signature error" and "peer is untrustworthy right now"* — the fallback-to-cache policy converted an authentication signal into a stale-capability authorization. ## Condition of Validity The invariant that must hold for A2A discovery to be sound: > A task lifecycle transition is authorized only by a capability manifest whose signature verifies against a JWKS entry that the signer currently asserts as live, and whose `kid` appears in the *fetched* (not cached) key set, at the moment of transition. Equivalently: **the manifest used to authorize transition `T` must be at least as fresh as the last key-epoch assertion from the signer.** A cached manifest is only usable while the cached JWKS is still the signer's current epoch. The moment a re-fetch yields a `kid` not in the cache, the cache is *provably* stale and must be invalidated — it cannot be used as a fallback. This condition is violated whenever verification failure is mapped to a *retry/fallback* class rather than an *invalidate-and-refetch* class. The two are not interchangeable: a `kid`-not-found is a *freshness* signal, not a *transient* one. Network timeouts are transient; an unknown `kid` is the signer telling you your view of its identity is out of date. ## Decision Boundary The architectural guardrail is a **two-phase discovery gate** with an explicit freshness state, and a lifecycle state machine that refuses transitions authorized by a manifest in `STALE` state. Phase 1 — *key resolution*: fetch JWKS, compare `kid` of the presented Card against the fetched set. If `kid` absent → state `KEY_EPOCH_MISMATCH`; the manifest is quarantined, never promoted to `LIVE`. If `kid` present but signature fails → state `SIGNATURE_INVALID`; peer is untrusted, task transitions to `BLOCKED_UNTRUSTED`, not `RESUMED`. Phase 2 — *manifest promotion*: only a Card verified in Phase 1 against the fetched JWKS may be promoted to `LIVE` and used to authorize transitions. The previous `LIVE` manifest moves to `SUPERSEDED` and is retained only for audit replay, never for authorization. The decision boundary is: **`kid` mismatch must be classified as a freshness violation (invalidate cache, block transitions) and never as a transient error (retry/fallback).** Any code path that returns the cached manifest after a `kid` mismatch is a soundness hole, regardless of how the signature check itself behaved. A second boundary: the state machine must treat `RESUMED` as requiring *peer-side acknowledgement* of the resume (a `tasks/get` confirming the task exists in a resumable state), not merely local transition legality. Local legality against a cached manifest is not evidence of peer-side state. ## Operational Effect With the two-phase gate: - The `kid` mismatch at T+2m puts the peer in `KEY_EPOCH_MISMATCH`, the cached manifest is quarantined, and the resume transition is refused with `CapabilityManifestStale`. The orchestrator surfaces a re-negotiation requirement to the supervisor rather than proceeding. - The phantom-task window (40s of wasted downstream execution) is eliminated because no transition is authorized by a stale manifest. - Audit replay can still reconstruct the superseded manifest, so post-incident analysis sees exactly which capabilities were believed at each transition. The cost is latency: every re-negotiation that crosses a key epoch pays a JWKS re-fetch, and the orchestrator cannot silently degrade to cached capabilities. That cost is the invariant. A system that "keeps working" through a key-epoch change is a system that is authorizing against a manifest the signer has disavowed. ``` ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class ManifestState(Enum): LIVE = "live" SUPERSEDED = "superseded" QUARANTINED = "quarantined" class CapabilityManifestStale(RuntimeError): """Raised when a task transition would be authorized by a manifest whose signing key is not in the signer's current JWKS epoch.""" @dataclass class AgentCard: kid: str capabilities: set supported_transports: list @dataclass class JWKSCache: keys: dict = field(default_factory=dict) # kid -> key material epoch: int = 0 class DiscoveryGate: def __init__(self, jwks: JWKSCache): self._jwks = jwks self._live: Optional[AgentCard] = None self._superseded: list = [] def _verify(self, card: AgentCard) -> bool: # In production: JWS verify against self._jwks.keys[card.kid] return card.kid in self._jwks.keys def promote(self, card: AgentCard) -> AgentCard: if card.kid not in self._jwks.keys: # Freshness violation: our JWKS view is stale. Do NOT fall back. raise CapabilityManifestStale( f"kid {card.kid!r} absent from JWKS epoch {self._jwks.epoch}; " f"cached manifest cannot authorize transitions" ) if not self._verify(card): raise CapabilityManifestStale( f"signature invalid for kid {card.kid!r}; peer untrusted" ) if self._live is not None: self._superseded.append(self._live) self._live = card return card def authorize_transition(self, transition: str, transport: str) -> None: if self._live is None: raise CapabilityManifestStale("no LIVE manifest; re-negotiate") if transition not in self._live.capabilities: raise CapabilityManifestStale( f"transition {transition!r} not in LIVE manifest" ) if transport not in self._live.supported_transports: raise CapabilityManifestStale( f"transport {transport!r} not supported by LIVE manifest" ) def resume_task(gate: DiscoveryGate, task_id: str, transport: str) -> None: # Refuse to resume on a manifest that crossed a key epoch without re-promotion. gate.authorize_transition("tasks/resume", transport) # ... issue tasks/resume and require peer-side tasks/get acknowledgement ... ``` ```