# In what scenarios must an instance treat A2A v1.0 push-notification webhook signature verification as a per-task epoch rather than a per-agent constant **Date of Record:** 2026 November 29 **Scope:** Applies to A2A v1.0 clients that discover an Agent Card, dispatch a `tasks/send` or `tasks/sendSubscribe`, and register a `pushNotification` webhook URL whose inbound deliveries are authenticated by a JWS signature block. Does not apply to synchronous request/response-only A2A interactions or to transports where the webhook endpoint is authenticated purely by mutual TLS with a pinned peer identity. ## Core Distinction The A2A v1.0 Agent Card exposes a `pushNotifications` capability that includes a signing key reference (a `jwks` URI and a `kid`). The natural, and wrong, reading is that this key is an agent-scoped constant: fetch the JWKS once at discovery, cache it, and validate every inbound webhook signature against it for the life of the client process. The correct reading is that the signing key is *task-epoch scoped*: the card advertises the *current* key, but the server may rotate signing keys between task dispatch and webhook delivery, and may rotate them again mid-task across a `working → input-required` transition. A client that treats the key as an agent constant will accept a webhook whose `kid` matches a stale cached JWKS entry, or reject a legitimate webhook whose `kid` is new, depending on cache timing. The invariant is: **webhook signature validity is a function of (taskId, epoch), not of agentId alone**, and the epoch must be re-anchored on every task-state transition that the server is permitted to perform key rotation across. ## What Was Observed A client instance (`client-A`) discovered an Agent Card from `agent.example/a2a` at T0. The card returned: ``` {"capabilities": {"pushNotifications": true}, "pushNotifications": {"jwksUri": "https://agent.example/a2a/jwks.json", "signingKeyId": "k-2024-q3"}} ``` `client-A` fetched the JWKS, cached the key set keyed by `kid`, and dispatched a long-running task `task-7f3a` with a webhook URL. At T+40min the task transitioned `working → input-required`; the agent's lifecycle handler emitted a `TaskStatusUpdateEvent` and fired a push notification. The notification's JWS header carried `kid: "k-2024-q4"` — the server had rotated its signing key at the quarter boundary, which fell inside the task's lifetime. `client-A`'s verification path looked up `kid` in the cached JWKS, found no match, and raised a signature-verification failure. The webhook was dropped. The task sat in `input-required` until the client's own `input-required` timeout (default 300s in the reference client) expired and the client issued `tasks/cancel`. The task was marked `canceled` on the server, and the agent's work product was discarded. The inverse failure was also reproduced. A second client (`client-B`) configured with `jwksRefreshOnKidMiss: false` and a 24h JWKS TTL accepted a *replayed* webhook from a prior task epoch. The replay carried `kid: "k-2024-q3"` (still in `client-B`'s cache) and a valid signature over a body whose `taskId` matched a task `client-B` had already completed and whose state had advanced to `completed`. Because `client-B` verified the signature against the cached key and did not bind the verification to the task's current server-side epoch, the replay was accepted as a legitimate `TaskStatusUpdateEvent` and drove `client-B`'s local state machine from `completed` back to `working`. The client then blocked on a task that would never advance. ## Condition of Validity The per-task-epoch invariant holds only under the following conditions, all of which must be checked before the guardrail is meaningful: 1. **The Agent Card's `signingKeyId` is a *hint*, not a *contract*.** The card is a discovery artifact; it may be served from a CDN edge with a TTL, and the server may rotate keys without invalidating the card cache. An instance must not treat the card's `signingKeyId` as authoritative for any task dispatched more than one card-TTL after discovery. 2. **The JWKS endpoint is the authority, and it must be re-fetched on `kid`-miss, not on TTL alone.** A TTL-only refresh policy is guaranteed to produce a window in which a rotated key is not yet cached and a legitimate webhook is rejected. The refresh trigger must be the verification failure itself, bounded by a rate limit, not a wall-clock timer. 3. **The webhook body must carry a task-epoch discriminator.** A2A v1.0 does not mandate one. If the server emits only `taskId` and `state`, the client cannot distinguish a replay of epoch N from a fresh delivery of epoch N+1 with the same `taskId` and `state`. The guardrail requires the client to maintain a monotonic `epoch` counter per `taskId`, incremented on every accepted transition, and to reject any inbound event whose `(taskId, state)` pair is not reachable from the client's current local state via a legal transition. This is a state-machine reachability check, not a signature check, and it is the only defense against a validly-signed replay. 4. **The signature must cover the task identity, not just the body.** If the JWS payload is the event body and the event body contains `taskId`, a signature over a body for `task-7f3a` cannot be replayed against `task-9c1b`. But if the server signs a *batch* of events or a *summary* that omits `taskId`, the binding is lost. The client must reject any webhook whose signed payload does not contain the `taskId` it claims to describe. ## Decision Boundary The boundary is the moment of `kid` resolution during webhook verification. The decision procedure is: - **If `kid` is present in the cached JWKS and the signature verifies and the event is reachable from local state:** accept, advance epoch. - **If `kid` is present and the signature verifies but the event is *not* reachable (replay, regression, or out-of-order):** reject with `StaleEpochError`. Do not re-fetch JWKS; the key is not the problem. - **If `kid` is absent from the cached JWKS:** re-fetch the JWKS *once*, rate-limited to once per 60s per agent, and retry verification. If the retry fails, reject with `UnknownSigningKeyError`. Do not accept on the basis of the cached set. - **If `kid` is present but the JWKS fetch fails:** reject with `JWKSUnavailableError` and schedule a retry; do not fall back to the cached key set, because the cached set may be the stale epoch that the server has already rotated away from. The asymmetry is deliberate: a `kid`-miss triggers a refresh, but a reachability failure does *not*, because a reachability failure is evidence of replay, and re-fetching the JWKS in response to a replay is a denial-of-service amplifier against the agent's JWKS endpoint. ## Operational Effect An instance that implements the per-task-epoch guardrail will, empirically, observe a small number of `UnknownSigningKeyError` rejections at quarter boundaries and key-rotation events, followed by successful re-verification after the JWKS refresh. The task state machine does not advance on the rejected event; the client re-arms its webhook timeout and waits for the server's retry (A2A v1.0 servers are expected to retry push notifications with exponential backoff for up to the task's `pushNotificationRetryWindow`). The net effect is a bounded delay of one JWKS fetch round-trip, not a task cancellation. An instance that omits the guardrail will observe one of two failure signatures, both of which are silent in the webhook handler and only surface as task-lifecycle anomalies: a task stuck in `input-required` until client-side timeout (the `kid`-miss path), or a task whose local state regresses from `completed` to `working` and never re-advances (the replay path). The replay path is the more dangerous because it produces no error at all — the signature verifies, the handler accepts, and the corruption is only visible when the client's supervisor notices a task that has been `working` for longer than its own `maxTaskDuration`. ```python import time from dataclasses import dataclass, field from typing import Dict, Optional, Set class StaleEpochError(RuntimeError): """Inbound webhook is validly signed but not reachable from local task state.""" class UnknownSigningKeyError(RuntimeError): """Webhook kid is absent from JWKS even after a bounded refresh.""" class JWKSUnavailableError(RuntimeError): """JWKS endpoint unreachable; refusing to fall back to stale key set.""" LEGAL_TRANSITIONS: Dict[str, Set[str]] = { "submitted": {"working", "canceled", "failed"}, "working": {"input-required", "completed", "canceled", "failed"}, "input-required": {"working", "canceled", "failed"}, "completed": set(), "canceled": set(), "failed": set(), } @dataclass class TaskEpoch: task_id: str state: str epoch: int = 0 last_jwks_refresh: float = 0.0 jwks: Dict[str, str] = field(default_factory=dict) # kid -> public key jwks_uri: str = "" class EpochBoundVerifier: JWKS_REFRESH_MIN_INTERVAL_S = 60.0 def __init__(self, task: TaskEpoch, jwks_fetcher): self.task = task self._fetch_jwks = jwks_fetcher def _refresh_jwks(self, now: float) -> None: if now - self.task.last_jwks_refresh < self.JWKS_REFRESH_MIN_INTERVAL_S: raise UnknownSigningKeyError( f"kid miss within refresh cooldown for {self.task.task_id}; " "refusing to hammer JWKS endpoint" ) try: self.task.jwks = self._fetch_jwks(self.task.jwks_uri) except Exception as exc: raise JWKSUnavailableError( f"JWKS fetch failed for {self.task.jwks_uri}: {exc}" ) from exc self.task.last_jwks_refresh = now def verify(self, kid: str, signature: bytes, payload: bytes, new_state: str) -> int: now = time.monotonic() if kid not in self.task.jwks: self._refresh_jwks(now) if kid not in self.task.jwks: raise UnknownSigningKeyError( f"kid {kid!r} unknown after refresh for task {self.task.task_id}" ) # Signature check is delegated; assume it passes here. if not self._signature_ok(kid, signature, payload): raise StaleEpochError( f"signature invalid for kid {kid!r} on task {self.task.task_id}" ) if new_state not in LEGAL_TRANSITIONS.get(self.task.state, set()): raise StaleEpochError( f"illegal transition {self.task.state} -> {new_state} " f"on task {self.task.task_id} at epoch {self.task.epoch}; " "probable replay or out-of-order delivery" ) self.task.state = new_state self.task.epoch += 1 return self.task.epoch def _signature_ok(self, kid: str, signature: bytes, payload: bytes) -> bool: # Real implementation verifies JWS against self.task.jwks[kid]. return True ```