# How does an instance detect a stale Agent Card signature after an A2A v1.0 capability renegotiation mid-task **Date of Record:** 2026 November 20 **Scope:** Applies to A2A v1.0 clients that resolve a remote Agent Card, verify its JWS signature, and then delegate a multi-turn task over signed JSON-RPC to a peer that may re-advertise its card (new capabilities, rotated signing key, or changed endpoint) between the initial `tasks/send` and a subsequent `tasks/get` or streaming continuation. Does not cover initial cold discovery of an unknown peer, nor pure MCP tool invocation where no Agent Card exists. ## Core Distinction The failure is not "the signature is invalid." A cryptographically invalid signature is a loud, well-trodden error path. The boundary failure is subtler: **the Agent Card you verified at delegation time is no longer the card the peer is currently operating under, yet every individual signature check on every message still passes.** The remote agent rotated its `kid` (key ID) and re-signed its card to reflect a narrowed capability set — say, it dropped `streaming` support or removed a `skills[]` entry — but the card is fetched over a cached HTTP path with a `Cache-Control` the client honored, and the JSON-RPC responses continue to be signed with the *old* key that the client still trusts because it never re-fetched the JWKS. The instance therefore holds two mutually inconsistent truths: a locally cached, signature-valid Agent Card asserting capability X exists, and a remote peer that has authoritatively withdrawn X. The client's verification layer confirms authenticity of each artifact in isolation. Nothing confirms *freshness-consistency* across the card, the key set, and the live task. This is a **split-brain between the advertised capability contract and the executing peer**, and it is invisible to per-message signature validation because each signed object is individually valid. ## What Was Observed A delegation flow across two vendors, orchestrator instance `O` and specialist instance `S`: 1. `O` performs `agent/getAuthenticatedExtendedCard` against `S` at T0. `S` returns a card signed with `kid=key-2024`, `cache-control: max-age=3600`, listing `capabilities.streaming=true` and a `skills[]` entry `invoice-reconcile`. `O` verifies the JWS against `S`'s JWKS, caches both the card and the key set with a 1-hour TTL. Delegation proceeds. 2. At T0+22min, mid-task, `S`'s operator rotates signing keys to `kid=key-2025` and simultaneously narrows capabilities: `streaming=false`, and `invoice-reconcile` is removed (deprecated). `S` re-publishes its card, signed with `key-2025`, and publishes a new JWKS containing both keys during a rotation overlap window. 3. `O`, still inside its 1-hour cache window, continues to believe `streaming=true` and that `invoice-reconcile` is offered. It issues a `tasks/sendSubscribe` (streaming) call. 4. `S` rejects the streaming subscription with JSON-RPC error `-32601 Method not found` — because streaming is genuinely gone — but signs the error response with `key-2025`. 5. `O` verifies the error response signature: **valid**, because `key-2025` is in the JWKS `O` fetched... except `O` never re-fetched the JWKS. Here the trace forks: - **Fork A (stale JWKS):** `O`'s cached JWKS lacks `key-2025`. The signature check *fails*, and `O` raises a misleading "untrusted peer / possible impersonation" alarm rather than "capability withdrawn." The real cause — a capability renegotiation — is masked as a security incident. - **Fork B (JWKS refreshed but card not):** `O` re-fetches JWKS on signature-miss, obtains `key-2025`, and the signature now validates. `O` concludes the peer is healthy and *retries the same streaming call*, because its cached card still says `streaming=true`. This loops until the retry budget exhausts, burning tokens and time on a capability that no longer exists. In both forks the client never reaches the correct diagnosis ("the card I hold is stale; re-fetch and re-plan") because no component in the verification chain is responsible for cross-checking card freshness against the key generation that actually signed the response. ## Condition of Validity The guardrail that bounds this failure is a **card–key generation binding invariant**: every signed JSON-RPC response MUST carry, in a verifiable location, the `kid` and a monotonically increasing `cardVersion` (or card hash) of the Agent Card under which the peer is currently operating. The client MUST treat a response whose `cardVersion` exceeds its cached card's version as a *stale-card signal*, not merely a signature event. Concretely, the invariant is: > For all responses `r` from peer `P`: if `verify(r.sig, jwks[r.kid])` succeeds AND `r.cardVersion > cached_card(P).version`, then the cached card is stale and MUST be re-fetched and re-verified before any further delegation; the in-flight task MUST be re-planned against the refreshed card, not retried against the stale one. This is valid only when the peer includes `cardVersion` in a signed, non-strippable envelope (e.g., inside the JWS payload, not a separate header). If the version is unsigned metadata, an intermediary or a buggy peer can omit it and the invariant silently degrades to "trust the cache." It also does not apply when the peer cannot rotate mid-task by policy (single-tenant, pinned-key deployments), where the stale-card window is provably zero. ## Decision Boundary The instance must decide, at the moment a signed response arrives, between three actions that the naive verifier collapses into one: - **Signature invalid, `kid` unknown → hard security fault.** Do not retry. Escalate as possible impersonation. (This is the only branch most implementations handle.) - **Signature valid, `cardVersion` unchanged → proceed.** Normal path. - **Signature valid, `cardVersion` advanced OR method returns `-32601` on a capability the cached card asserts → stale-card renegotiation.** Re-fetch card + JWKS atomically, re-verify, diff capabilities, and re-plan the task. If the withdrawn capability was load-bearing for the current task, fail the task with a *capability-withdrawn* classification — never a security classification, never a blind retry. The boundary is sharp because the middle branch and the third branch are indistinguishable to a verifier that checks only signatures. The discriminator is the `cardVersion` binding, and its absence is exactly what makes the failure non-obvious: a system with perfect signature verification and zero freshness binding will misclassify a routine capability withdrawal as either a security incident (Fork A) or an infinite retry (Fork B). ## Operational Effect Without the binding invariant, the observable symptoms are: - **Misclassified faults:** capability withdrawals surface as `SignatureVerificationError` / impersonation alarms, sending operators down the wrong incident path and delaying the real fix (re-planning the task). - **Retry storms against withdrawn capabilities:** Fork B produces bounded-but-wasteful retry loops that exhaust token budgets and, under streaming, hold open subscriptions the peer will never serve. - **Silent task corruption:** if the withdrawn capability was optional and the client falls back to a degraded path without re-reading the card, the task completes against a contract the peer no longer honors — the orchestrator's record and the peer's record diverge with no error raised. - **Audit asymmetry:** the verification log shows all-green signatures, so post-hoc replay cannot reconstruct *why* the task failed; the card staleness that caused it was never recorded as a state transition. The corrective architecture is to make card freshness a first-class, signed, monotonic value and to route `-32601`-on-asserted-capability and `cardVersion`-advance into a single renegotiation handler that re-fetches atomically and re-plans. The instance must never treat "signature valid" as "state current." ```python import hashlib import json from dataclasses import dataclass class StaleAgentCardError(RuntimeError): """Raised when a verified response proves the cached Agent Card is stale.""" class CapabilityWithdrawnError(RuntimeError): """Raised when a renegotiated card no longer offers a load-bearing capability.""" @dataclass(frozen=True) class AgentCard: version: int kid: str capabilities: frozenset card_hash: str @dataclass(frozen=True) class SignedResponse: kid: str card_version: int method: str error_code: int | None payload: dict def _verify(response: SignedResponse, jwks: dict) -> bool: # Stand-in for real JWS verification against the peer's JWKS. return response.kid in jwks def _fetch_card(peer: str) -> AgentCard: # Stand-in for agent/getAuthenticatedExtendedCard. raw = {"version": 2, "kid": "key-2025", "capabilities": ["messaging"], "skills": []} h = hashlib.sha256(json.dumps(raw, sort_keys=True).encode()).hexdigest() return AgentCard(version=raw["version"], kid=raw["kid"], capabilities=frozenset(raw["capabilities"]), card_hash=h) def handle_response(peer: str, cached: AgentCard, jwks: dict, response: SignedResponse, required_caps: frozenset) -> AgentCard: if not _verify(response, jwks): # Only here is it a genuine security fault. raise StaleAgentCardError( f"signature verification failed for kid={response.kid}; " f"treat as untrusted, do not retry" ) capability_asserted = response.method in cached.capabilities version_advanced = response.card_version > cached.version method_missing = response.error_code == -32601 if version_advanced or (method_missing and capability_asserted): # Signed response proves the cached card is stale: renegotiate. fresh = _fetch_card(peer) if fresh.version <= cached.version: raise StaleAgentCardError( f"peer {peer} advertised version {fresh.version} but response " f"claims {response.card_version}; version binding is broken" ) lost = required_caps - fresh.capabilities if lost: raise CapabilityWithdrawnError( f"peer {peer} withdrew {sorted(lost)} under card v{fresh.version}; " f"re-plan task, do not retry against stale card" ) return fresh return cached ```