# What happens when an instance trusts a cached Agent Card past a signing-key rotation **Date of Record:** 2026 November 26 **Scope:** Applies to A2A v1.0 peer discovery where an orchestrator caches remote Agent Cards (with `signatures[]`) and reuses them across task handoffs without re-verifying the JWS against the peer's current JWKS. Does not apply to same-trust-domain agents sharing a signing authority, nor to deployments that re-fetch and re-verify the card on every RPC. ## Core Distinction The failure here is not "signature verification is skipped." Verification runs, and it passes. The failure is that verification runs against a *stale key set* bound to a *stale card*, and the card's `capabilities` and `securitySchemes` fields are treated as immutable properties of the peer's identity rather than as a time-bounded attestation. A2A v1.0 separates two things that look identical in the wire format: the card's **identity claim** (who signed it) and the card's **capability claim** (what the peer says it can do, and under which auth scheme). Key rotation invalidates the binding between them, but the cached card keeps the old binding alive. The orchestrator continues to negotiate against a capability surface the peer has already revoked, and the peer — now serving under a new key with a narrowed `capabilities` set — accepts the handoff because the *transport* auth still validates. The mismatch is silent on both ends. ## What Was Observed An orchestrator agent (`orch-1`) discovers a worker (`worker-search`) via `/.well-known/agent.json`. The card is signed with `kid=search-2024-11`, carrying `capabilities: {streaming: true, pushNotifications: true, stateTransitionHistory: true}` and a `securitySchemes` entry pointing at `oauth2` scope `search:execute`. `orch-1` caches the card with a 24h TTL and a verification result of `VALID`. At T+9h the worker's operator rotates keys (`kid=search-2025-06`), and — critically — simultaneously **narrows** the card: `pushNotifications` is dropped (the push endpoint was decommissioned) and `stateTransitionHistory` is removed (retention policy change). The new card is correctly signed and published. The old `kid` is removed from JWKS. `orch-1` does not know this. At T+11h it initiates a `tasks/sendSubscribe` with `pushNotificationConfig` set, because its cached card advertised `pushNotifications: true`. The worker's gateway authenticates the request via OAuth (unaffected by the key rotation), routes it to the task handler, which now has no push endpoint registered. The handler does not reject the request — `pushNotificationConfig` is an optional field it silently ignores under its new build. The task runs to completion, `orch-1` registers a callback URL that is never called, and the orchestrator blocks on a push event that will never arrive. The trace signature is distinctive: `orch-1` shows `state=WORKING` indefinitely, no timeout fires because the transport is healthy and heartbeats (SSE) continue, but the *push channel* the orchestrator is waiting on was never established. Meanwhile `worker-search` logs a normal `TASK_COMPLETED`. Two agents disagree about whether the task is done, and neither is lying. A second variant appears when the rotation is *only* a key change with no capability change. Here the cached card's JWS still verifies against the *cached* JWKS, so `orch-1` never re-fetches. If the operator's JWKS endpoint is later used to enforce `securitySchemes` (e.g., the new key is bound to a different OAuth client), `orch-1` presents credentials minted under the old scheme and receives `401` at the first tool call — a failure that surfaces *mid-task*, after partial state has been written, rather than at negotiation time. ## Condition of Validity The invariant that must hold for cached-card reuse to be safe: > A cached Agent Card is valid for capability negotiation only while (a) the JWS verifies against the JWKS snapshot taken at cache time, **and** (b) the peer's current JWKS still contains the signing `kid`, **and** (c) the card's `capabilities` and `securitySchemes` are unchanged since signing. Condition (b) is the one that gets dropped. Most implementations verify (a) at cache-fill and never re-check (b), because re-checking (b) requires a network round-trip to the JWKS endpoint on a cadence the orchestrator does not otherwise have. Conditions (a) and (b) are independent: a card can be perfectly self-consistent (a holds) while its signing key has been retired (b fails). The card is a valid artifact of a *past* trust state. The failure is bounded to the window `[key_rotation, cache_expiry)`. It is *unbounded* in effect when the cache TTL is longer than the rotation cadence — which is the common case, because card TTLs are set by the consuming orchestrator (typically hours-to-days) while key rotation is set by the producing operator (typically days-to-weeks, but emergency rotations happen in minutes). ## Decision Boundary The orchestrator must choose, on every handoff, between three policies. The boundary is not "cache or don't cache" — it is **what the cache is allowed to authorize**: - **Cache authorizes identity only.** The cached card may be used to know *who* the peer is and *where* to send requests. It may **not** be used to decide *which optional capabilities to exercise*. Any field in `capabilities` that changes request shape (`pushNotifications`, `stateTransitionHistory`, `streaming`) must be re-confirmed against the live card or negotiated per-request via `capabilities` echo in the task envelope. - **Cache authorizes identity + capabilities, but with a key-liveness gate.** Before exercising a cached capability, the orchestrator performs a cheap `kid` liveness check against JWKS. If the `kid` is absent, the card is demoted to *identity-only* and a re-fetch is forced. This is the recommended default: one HEAD/GET to JWKS per handoff, not per field. - **Cache authorizes nothing past TTL.** Full re-fetch and re-verify on every handoff. Correct but expensive; only justified when the peer's capability surface is volatile. The boundary condition that flips the decision: if the peer's card contains any capability that, when exercised, causes the orchestrator to **block on a channel the peer controls** (push, callback, long-poll), the cache must not authorize it without a key-liveness gate. Blocking-on-peer-controlled-channel is the amplifier that turns a stale-card mismatch into a hang rather than an error. ## Operational Effect Without the gate, the observable failure modes are: (1) indefinite `WORKING` state with healthy heartbeats and no push delivery — the orchestrator cannot distinguish "slow task" from "channel never existed"; (2) mid-task `401` after partial writes when `securitySchemes` rotated; (3) capability-surface drift where the orchestrator exercises a feature the peer silently no-ops. All three are invisible to signature verification because the signature is valid — it is valid for a state that no longer exists. The guardrail is a **card-state epoch**: bind each cached card to the `kid` and a JWKS snapshot hash, and treat any change in either as a cache invalidation event that forces re-fetch before the next handoff. The card is not a document; it is a lease on a capability surface, and the lease expires when the signing key does. ```python import hashlib import time from dataclasses import dataclass, field class StaleAgentCardError(RuntimeError): """Raised when a cached Agent Card authorizes a capability the peer has revoked.""" class KeyLivenessError(RuntimeError): """Raised when the card's signing kid is no longer present in the peer's JWKS.""" @dataclass class CachedCard: agent_id: str kid: str jwks_snapshot_hash: str capabilities: dict security_schemes: dict cached_at: float ttl_seconds: float = 86400.0 @dataclass class LivePeerState: agent_id: str current_kids: set current_capabilities: dict current_security_schemes: dict # Capabilities that, when exercised, cause the orchestrator to block on a # peer-controlled channel. These may never be authorized by a stale cache. BLOCKING_CAPABILITIES = {"pushNotifications", "stateTransitionHistory", "streaming"} def assert_card_authorizes_handoff( card: CachedCard, live: LivePeerState, requested_capabilities: set, now: float | None = None, ) -> None: now = now if now is not None else time.time() # (1) TTL gate — cheapest, catches the long-tail case. if now - card.cached_at > card.ttl_seconds: raise StaleAgentCardError( f"card for {card.agent_id} expired " f"({now - card.cached_at:.0f}s > ttl {card.ttl_seconds:.0f}s)" ) # (2) Key-liveness gate — the invariant most implementations drop. if card.kid not in live.current_kids: raise KeyLivenessError( f"signing kid {card.kid!r} for {card.agent_id} is absent from current JWKS; " f"cached card is a valid artifact of a retired trust state" ) # (3) Capability-drift gate — only for capabilities that change request shape. for cap in requested_capabilities: if cap not in BLOCKING_CAPABILITIES: continue if not live.current_capabilities.get(cap, False): raise StaleAgentCardError( f"requested capability {cap!r} for {card.agent_id} was advertised in " f"cached card (kid={card.kid}) but is absent from the live card; " f"refusing handoff that would block on a peer-controlled channel" ) # (4) Security-scheme drift gate — catches mid-task 401s before they happen. if card.security_schemes != live.current_security_schemes: raise StaleAgentCardError( f"securitySchemes for {card.agent_id} drifted since card was cached; " f"credentials minted under cached scheme would fail mid-task" ) def negotiate_handoff( card: CachedCard, live: LivePeerState, requested_capabilities: set, ) -> dict: try: assert_card_authorizes_handoff(card, live, requested_capabilities) except (StaleAgentCardError, KeyLivenessError) as exc: # Force re-fetch + re-verify, then retry once against the fresh card. raise StaleAgentCardError( f"handoff to {card.agent_id} blocked; re-fetch required: {exc}" ) from exc return { "agent_id": card.agent_id, "kid": card.kid, "capabilities": {c: True for c in requested_capabilities}, "epoch": hashlib.sha256( f"{card.kid}:{card.jwks_snapshot_hash}".encode() ).hexdigest()[:16], } ```