# When must an instance reject a peer Agent Card whose `securitySchemes` reference a signing key that rotates between discovery and webhook delivery **Date of Record:** 2026 November 24 **Scope:** Applies to A2A v1.0 deployments where a client agent discovers a remote Agent Card, then receives asynchronous task updates via signed push-notification webhooks. Does not apply to synchronous-only request/response A2A flows or to cards served over mutually authenticated channels where the card itself is signed by the same key that signs webhooks. ## Core Distinction The A2A Agent Card is a *discovery-time* artifact. The push-notification signature is a *delivery-time* artifact. Both may reference the same `securitySchemes` entry (e.g., an `ai2a-jws` or `hmac-sha256` scheme with a `kid`), but they are consumed at different points in the task lifecycle, often minutes apart. The boundary failure is not "the key is wrong"—it is that the `kid` resolved at discovery is silently assumed to remain authoritative through `submitted → working → completed`, including across the `input-required` suspension window during which the remote agent may rotate keys and re-publish its card. The invariant that must hold: **the key identifier used to verify a webhook MUST be traceable to a card version whose `kid` was valid at the moment the task entered its current non-terminal state, not merely at task creation.** When this invariant is violated, signature verification succeeds cryptographically but authenticates the wrong principal. ## What Was Observed A client agent (`client-A`) discovered a peer card at `T0`. The card advertised: ``` "securitySchemes": { "push-sig": { "type": "http", "scheme": "bearer", "bearerFormat": "JWS", "kid": "k-2025-06a" } } ``` At `T0+4m`, `client-A` sent `message/send` and received a `task` in state `working` with `pushNotificationConfig` bound to `k-2025-06a`. At `T0+11m` the remote entered `input-required` and `client-A` suspended. During suspension the remote rotated signing keys, re-published its card with `kid: k-2025-06b`, and began signing all outbound webhooks with the new key. The old key remained valid for verification (rotation overlap window of 24h) but was no longer the *authoritative* signer. At `T0+19m` `client-A` resumed, sent `tasks/resubmit`, and received a webhook signed with `k-2025-06b`. `client-A`'s verifier, holding the cached card from `T0`, looked up `k-2025-06a`, found no matching signature, and—depending on implementation—either (a) rejected the webhook as forged, stalling the task in `working` until timeout, or (b) fell back to "any key in the overlap set," verifying against `k-2025-06b` while still attributing the message to the `T0` card principal. Case (b) is the dangerous one: verification passes, but the client cannot distinguish a legitimate rotation from a compromised-key forgery, because it never re-fetched the card to confirm `k-2025-06b` was a sanctioned successor. A second observed variant: the remote re-published the card *without* a rotation overlap, revoking `k-2025-06a` immediately. `client-A` re-fetched on webhook failure, saw the new `kid`, but had no signed transition record proving `k-2025-06b` succeeded `k-2025-06a` rather than replaced it adversarially. The card's `kid` field carries no lineage. ## Condition of Validity The naive rule "re-fetch the card when signature verification fails" is valid only when the following hold simultaneously: 1. The re-fetched card is itself authenticated (signed by a key rooted in the client's trust store, or fetched over mTLS to a pinned endpoint). An unauthenticated re-fetch on verification failure is a prompt-injection surface: a network attacker who can also serve a card can substitute a `kid` and a matching key. 2. The card exposes a monotonic version or `etag` and the client persists the last-seen version per peer, rejecting re-fetches that move backward. 3. The task's current state is non-terminal and the client still holds the `taskId` + `contextId` binding, so the re-fetch can be scoped to the same principal rather than a fresh discovery. When any of these fail, re-fetch-on-failure is not a recovery path—it is a trust downgrade. ## Decision Boundary The precise boundary: **a webhook whose `kid` is not present in the card version cached at the task's last state transition MUST be treated as an unauthenticated event, not a verification failure to be retried.** Retrying is correct only for transient transport errors (5xx, timeouts). A `kid` mismatch is a *semantic* mismatch and must route to a distinct branch: - If the card version is unchanged and the `kid` is unknown → reject, emit `UnknownSigningKey`, do not advance the task state machine. - If the card version advanced and the new `kid` is present in an *authenticated* newer card whose version is strictly greater than the cached one → accept, but first re-bind the task's principal to the new card version and log the rotation as a state transition event. - If the card version advanced but authentication of the new card fails, or the version moved backward → reject and quarantine the task; do not resume. The trap is conflating "signature does not verify" with "signature verifies against a key I did not expect." The former is a transport/forgery signal; the latter is a lifecycle/lineage signal. They require different guardrails. ## Operational Effect Agents that collapse these two branches exhibit a characteristic failure signature in telemetry: a cluster of `working` tasks that never reach `completed`, each with one webhook delivery that failed verification followed by no further deliveries (the remote, having rotated, will not re-sign with the old key). The tasks are not dead—the remote considers them live—so they consume the client's task-tracking budget until a TTL sweep, and any downstream agent waiting on the baton is blocked. In the fallback variant (case b above), the failure is silent: tasks complete, but the audit trail attributes post-rotation messages to the pre-rotation principal, breaking verification replay for any auditor reconstructing the task from signed events. The guardrail that bounds this: persist `(peerId, cardVersion, kid, taskId, stateAtBinding)` as an immutable tuple on every state transition, and require webhook verification to resolve against the tuple, never against a live card fetch. Rotation is then an explicit, logged re-binding event rather than an implicit cache miss. ```python import hashlib from dataclasses import dataclass from typing import Optional class SigningKeyLineageError(RuntimeError): """Raised when a webhook's signing key cannot be traced to an authenticated card version valid at the task's current state.""" @dataclass(frozen=True) class CardVersion: peer_id: str version: int kid: str authenticated: bool @dataclass(frozen=True) class TaskBinding: task_id: str peer_id: str card_version: int kid: str state: str def verify_webhook( binding: TaskBinding, webhook_kid: str, webhook_payload: bytes, webhook_sig: bytes, cached_card: CardVersion, refetched_card: Optional[CardVersion], verifier, ) -> bool: # Fast path: kid matches the binding established at last transition. if webhook_kid == binding.kid: if not verifier(webhook_payload, webhook_sig, binding.kid): raise SigningKeyLineageError( f"kid {binding.kid} matches binding but signature invalid; " f"treat as forgery, not rotation" ) return True # kid mismatch is a lineage question, not a retry. if refetched_card is None: raise SigningKeyLineageError( f"webhook kid {webhook_kid} unknown to binding {binding.kid}; " f"no authenticated re-fetch available, rejecting" ) if not refetched_card.authenticated: raise SigningKeyLineageError( f"re-fetched card for {refetched_card.peer_id} is unauthenticated; " f"refusing to trust kid {webhook_kid}" ) if refetched_card.version <= cached_card.version: raise SigningKeyLineageError( f"card version moved backward or stalled " f"({cached_card.version} -> {refetched_card.version}); quarantine task" ) if refetched_card.kid != webhook_kid: raise SigningKeyLineageError( f"webhook kid {webhook_kid} not present in authenticated card " f"v{refetched_card.version} (has {refetched_card.kid})" ) if not verifier(webhook_payload, webhook_sig, webhook_kid): raise SigningKeyLineageError( f"signature invalid against rotated kid {webhook_kid}" ) # Caller must now re-bind the task to refetched_card.version before # advancing the state machine. return True ```