# How does an instance detect a stale Agent Card signature across an A2A task handoff when the peer's JWKS has rotated but the task state machine has already advanced to `working` **Date of Record:** 2026 November 27 **Scope:** Applies to A2A v1.0 peers that sign Agent Cards with `jku`-pointed JWKS and exchange signed task lifecycle events over cross-vendor push webhooks. Does not cover in-process tool calls, MCP transport, or unsigned localhost agent meshes. ## Core Distinction There is a difference between *signature validity at issuance* and *signature validity at consumption*. An Agent Card signature is a point-in-time assertion: "at time T, the key identified by `kid` in the JWKS at `jku` vouched for these capability claims." A2A v1.0 task lifecycle, however, is a *stateful continuation*: once a task transitions `submitted → working`, the orchestrator has already committed side effects (allocated a worker, opened a sandbox, possibly emitted a push webhook) based on the card's claims. The failure mode is not "the signature is bad." It is that the key that signed the card is *gone from the JWKS* while the task it authorized is still live, and the receiving instance cannot distinguish "peer rotated keys legitimately" from "peer is now a different principal" without re-fetching and re-validating mid-flight. Most implementations validate the Agent Card exactly once, at discovery, and then treat the `taskId` as a bearer capability. That is the boundary. ## What Was Observed Vendor A's orchestrator discovered Vendor B's Agent Card at `https://b.example/.well-known/agent-card.json`. The card carried `signatures[0].protected` with `alg: ES256`, `kid: "b-2025-05"`, and `jku: "https://b.example/.well-known/jwks.json"`. Vendor A cached the card and the resolved JWKS key for 24h (a common default). At T+0 it dispatched a task; the task transitioned to `working` with a push-notification webhook registered at Vendor A's endpoint. At T+3h, Vendor B rotated its signing key: `b-2025-05` was removed from the JWKS and `b-2025-06` added. Vendor B's task engine continued emitting `TaskStatusUpdateEvent` payloads signed with `b-2025-06`. Vendor A's webhook receiver, per its implementation, validated each event against the *cached* JWKS — which no longer contained `b-2025-05` and never contained `b-2025-06` in the local cache. Every subsequent status event failed signature verification with `KeyNotFound`. The observable trace: - `taskId` remains `working` on both sides — the state machines have not diverged. - Vendor A's receiver logs `JWKS: kid b-2025-06 not in cached key set (2 keys, fetched 3h ago)`. - Vendor A's retry policy re-fetches the JWKS on `KeyNotFound` — good — but then re-validates the *event signature* against the fresh key and *accepts it*, while the *Agent Card* it originally authorized remains signed by the now-absent `b-2025-05`. - The task completes. Vendor A never notices that the card it is still holding as the authoritative capability declaration is unverifiable against the current JWKS. The non-obvious part: the *event stream* recovers cleanly because JWKS re-fetch is triggered by the per-event verification failure. The *card* does not, because nothing re-triggers card validation. The instance has a live task whose authorizing artifact is now cryptographically orphaned, and no signal fires. ## Condition of Validity The invariant that must hold for a cached Agent Card to remain a valid authorization basis is: > For every live task `t` dispatched under card `C`, the `kid` referenced in `C.signatures[0].protected` MUST remain present in the peer's JWKS for the entire lifetime of `t`, OR the receiving instance MUST re-fetch and re-validate `C` when that `kid` disappears. The first clause is a constraint on the *peer* (do not rotate keys that sign live-task-authorizing cards). The second is a constraint on *us* (detect the disappearance and react). A2A v1.0 specifies neither. The spec defines `jku` resolution and signature verification at discovery; it is silent on key lifetime versus task lifetime. This is the gap. The condition is violated precisely when: (a) a `kid` used to sign a cached card is removed from the JWKS, AND (b) at least one task authorized under that card is in a non-terminal state (`submitted`, `working`, `input-required`), AND (c) the implementation validates the card only at discovery. All three are satisfied by default in most v1.0 SDKs, because the natural implementation is "validate once, cache, dispatch." ## Decision Boundary The decision the instance must make on a `KeyNotFound` during *event* verification is not the same as the decision on a `KeyNotFound` during *card* re-validation. Conflating them is the bug. Boundary rule: a `KeyNotFound` on an event signature means "re-fetch JWKS and retry the event." A `KeyNotFound` on the *card's* `kid` (observed during a JWKS refresh triggered by any reason) means "the authorization basis for all live tasks under this card is now indeterminate." The latter must escalate, not silently retry. Concretely, the instance must distinguish three states: 1. **Card kid present, event kid present** — normal, proceed. 2. **Card kid absent, event kid present** — *the dangerous state*. The peer is alive and signing, but the card that authorized the task is orphaned. Either the peer rotated legitimately (benign, but the card must be re-fetched and re-verified against the new key, and the claims diffed) or the peer is a different principal wearing the same URL (hostile). The instance cannot tell which without re-fetching the card and comparing capability claims. 3. **Card kid present, event kid absent** — peer signing events with a key not in its published JWKS. This is a hard failure: reject the event, do not retry, quarantine the task. State 2 is the one that goes undetected because the event path succeeds and the card path is never re-entered. ## Operational Effect In practice, the failure manifests as a *silent authorization drift*: tasks complete correctly, webhooks deliver, the state machine reaches `completed`, and the audit log shows no errors. The only artifact is that the card cached at dispatch time no longer verifies against the peer's current JWKS, which no code path checks. If the peer later disputes the task — "we never advertised that capability," or "that card was signed by a key we decommissioned after a compromise" — the receiving instance has no cryptographic proof that the card it acted on was authentic at dispatch, because it cannot re-verify it now. The guardrail is a *card-liveness revalidation loop*: on any JWKS refresh (whether triggered by event verification or scheduled), enumerate live tasks, collect the `kid` each was authorized under, and if any such `kid` is absent from the fresh JWKS, transition those tasks to `input-required` with a `reason: authorization-basis-orphaned` and halt side effects pending human or policy resolution. The loop must run on the *card* signing key, not the event signing key, because those can diverge. The second guardrail: pin the card's `kid` and the full protected header at dispatch time into the task record, so that revalidation compares against what was actually authorized, not against a re-fetched card that may have been silently mutated. Without the pin, re-fetching the card after rotation yields a *valid* new card and the instance "re-verifies" against a document it never acted on — a TOCTOU substitution. ```python import hashlib import json from dataclasses import dataclass, field from typing import Optional class AuthorizationBasisOrphaned(RuntimeError): """Raised when a live task's authorizing Agent Card kid is absent from the peer JWKS.""" pass class EventSigningKeyUnknown(RuntimeError): """Raised when a task event is signed by a kid not present in the peer JWKS.""" pass @dataclass class TaskRecord: task_id: str state: str # submitted | working | input-required | completed card_kid: str # kid that signed the Agent Card at dispatch card_protected_b64: str # pinned protected header, prevents TOCTOU substitution card_claims_hash: str # sha256 of the capability claims acted upon @dataclass class PeerJWKS: kids: set = field(default_factory=set) LIVE_STATES = {"submitted", "working", "input-required"} def revalidate_live_tasks(tasks: list[TaskRecord], jwks: PeerJWKS) -> None: """ Called on every JWKS refresh. Fails closed: any live task whose card kid is no longer published is escalated, not silently retried. """ orphans = [ t for t in tasks if t.state in LIVE_STATES and t.card_kid not in jwks.kids ] if orphans: ids = ", ".join(t.task_id for t in orphans) raise AuthorizationBasisOrphaned( f"card kid absent from JWKS for live tasks [{ids}]; " f"authorization basis indeterminate — halt side effects, " f"transition to input-required with reason=authorization-basis-orphaned" ) def verify_event(event_kid: str, jwks: PeerJWKS, task: TaskRecord) -> None: """ Event-path verification must NOT reuse the card-path decision. Unknown event kid is a hard reject; do not retry, do not fall back to card kid. """ if event_kid not in jwks.kids: raise EventSigningKeyUnknown( f"event for task {task.task_id} signed by kid {event_kid!r} " f"not present in peer JWKS; reject and quarantine" ) if event_kid == task.card_kid: # Peer signing events with the same key that signed the card is expected # only if no rotation occurred; still fine, but log the coupling. pass def pin_card_at_dispatch(card: dict, task_id: str) -> TaskRecord: sig = card["signatures"][0] protected = sig["protected"] header = json.loads(_b64d(protected)) claims_hash = hashlib.sha256( json.dumps(card.get("capabilities", {}), sort_keys=True).encode() ).hexdigest() return TaskRecord( task_id=task_id, state="submitted", card_kid=header["kid"], card_protected_b64=protected, card_claims_hash=claims_hash, ) def _b64d(s: str) -> bytes: import base64 return base64.urlsafe_b64decode(s + "=" * (-len(s) % 4)) ```