# When must an instance reject a peer's Agent Card because the `securitySchemes` object is present but the referenced scheme is not in the signing chain **Date of Record:** 2026 November 30 **Scope:** Applies to A2A v1.0 peer discovery and task submission where an Agent Card advertises `capabilities.pushNotifications: true` and a `securitySchemes`/`security` declaration, and where the receiving instance must validate webhook signatures on task updates. Does not apply to synchronous-only A2A peers that never register a push-notification endpoint, nor to intra-host tool calls that bypass the Agent Card entirely. ## Core Distinction The failure is not "signature verification failed." It is "signature verification succeeded against a key that the card's `security` block never authorized for the task's `pushNotification` channel." A2A v1.0 Agent Cards separate *identity* (`securitySchemes`, e.g. an `apiKey` or `http`/`bearer` or `oauth2` scheme) from *capability* (`capabilities.pushNotifications`, `skills`). The signing key used on the webhook is negotiated out-of-band at `tasks/pushNotificationConfig/set` time, but the *authorization* for that key to sign on behalf of the agent is asserted only by the `security` array on the card. When a peer publishes a card with `securitySchemes: { "sig": {...} }` but `security: []` (or `security` referencing a different scheme name), the card is internally inconsistent: it advertises a scheme it does not require, and the instance that trusts the scheme's key will accept webhook payloads the peer never committed to signing. The non-obvious part: a *valid* JWS over the push payload, verified with the public key from `securitySchemes["sig"]`, is cryptographically sound but *operationally unauthorized*. Signature validity and authorization validity are two different predicates, and A2A's card schema lets them diverge. ## What Was Observed A coordinator instance (call it `C`) discovered a worker `W` via `GET /.well-known/agent.json`. `W`'s card: ``` { "name": "worker-7", "capabilities": { "pushNotifications": true, "streaming": false }, "securitySchemes": { "sig": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } }, "security": [ { "oauth2": ["tasks:write"] } ] } ``` Note `security` references `oauth2`, which is **not defined** in `securitySchemes`. This is a schema-level dangling reference. `C`'s discovery validator (a JSON-Schema check) passed because A2A's card schema does not enforce that every key in a `security` requirement object resolves to a `securitySchemes` entry — the requirement object is an open map. `C` then submitted `tasks/send`, and at `tasks/pushNotificationConfig/set` time, `W` returned a `pushNotificationConfig` containing a `token` and a `url`. Per the A2A spec the token is opaque; `C` stores it and uses it to authenticate *inbound* webhooks. Separately, `W` began signing webhook bodies with a JWS whose `kid` resolved to the `sig` scheme's key. `C`'s webhook handler verified the JWS against `sig`'s key, passed, and applied the task-state transition. The problem: `W`'s card's `security` block never authorized `sig` for anything. `C` had inferred authorization from *presence in `securitySchemes`*, which is a declaration of *available* schemes, not *required* ones. A second, malicious peer `M` later replayed a captured `W` webhook to `C` after `W` rotated keys; because `C` had cached the `sig` key from the original card and never re-fetched, the stale key still verified `M`'s forged payloads, and `C` advanced `W`'s task from `working` to `completed` with attacker-supplied artifacts. The state-machine consequence: `completed` is terminal. `C` had no rollback path, no re-verification hook, and no record that the transition was authorized by a scheme absent from `security`. ## Condition of Validity A webhook signature is *authorized* only when all of the following hold simultaneously: 1. The `kid`/scheme name in the JWS header resolves to an entry in the peer's *current* `securitySchemes`. 2. That scheme name appears as a key in at least one object of the peer's `security` array (i.e., the peer *requires* it, not merely *offers* it). 3. The scheme's key material has not been superseded since card fetch — enforced by a `cardVersion`/`etag` re-fetch on every webhook, or by binding the key to the `pushNotificationConfig.token` issued at registration time. 4. The task's current state is non-terminal, so that a failed re-verification can still halt the transition. Condition 2 is the one that silently fails. Condition 3 is the one that turns a one-time discovery bug into a persistent replay window. Condition 4 is the one that makes the failure unrecoverable. ## Decision Boundary The instance must **reject** the webhook (and, on discovery, must refuse to register a push-notification endpoint) when: - `securitySchemes` is non-empty AND `security` is empty or contains a key not present in `securitySchemes`, **or** - the webhook's signing `kid` resolves to a scheme not named in any `security` requirement, **or** - the card's `etag`/version differs from the cached one and the signing key changed without a corresponding `security` update. The instance must **accept** only when the signing scheme is both *defined* and *required*. A card that offers a scheme but does not require it is not a signing contract; it is a capability advertisement, and treating it as a contract is the boundary violation. Crucially, the decision must be made *before* the task-state transition is committed, not after. Verification is a precondition on the transition, not a side effect of it. ## Operational Effect The downstream effect of getting this boundary wrong is state-machine corruption that is indistinguishable from legitimate completion. Because A2A task states are monotonic (`submitted → working → completed|failed|canceled`), a forged `completed` webhook is not recoverable by the coordinator — it has already emitted downstream artifacts, marked the task terminal, and released the `pushNotificationConfig`. The only remediation is out-of-band: invalidate the task ID, re-issue under a new ID, and quarantine the peer's card. The invariant to enforce: **a webhook signature is a claim of identity, not a grant of authority; authority comes only from the `security` requirement set, and only for the lifetime of the card version under which it was fetched.** Implementations that conflate `securitySchemes` presence with `security` requirement will pass every cryptographic check and still accept unauthorized state transitions. ```python import hashlib import hmac import json from dataclasses import dataclass from typing import Any class UnauthorizedWebhookScheme(RuntimeError): """Raised when a webhook signature verifies cryptographically but the signing scheme is not authorized by the peer's Agent Card `security` requirement set, or the card version has drifted since fetch.""" @dataclass(frozen=True) class CachedCard: version: str security_schemes: dict[str, Any] # scheme name -> key material descriptor security: list[dict[str, list[str]]] # required scheme names per requirement def _scheme_is_required(card: CachedCard, scheme_name: str) -> bool: # A scheme is authorized only if it appears as a key in at least one # requirement object. Presence in securitySchemes alone is NOT enough. return any(scheme_name in req for req in card.security) def _scheme_is_defined(card: CachedCard, scheme_name: str) -> bool: return scheme_name in card.security_schemes def verify_push_webhook( *, card: CachedCard, live_card_version: str, jws_header: dict[str, Any], body: bytes, signature: bytes, signing_key: bytes, ) -> None: scheme_name = jws_header.get("kid") if scheme_name is None: raise UnauthorizedWebhookScheme("webhook JWS missing kid; cannot bind to a scheme") # Condition 1: scheme must be defined on the *current* card. if not _scheme_is_defined(card, scheme_name): raise UnauthorizedWebhookScheme( f"signing scheme {scheme_name!r} not present in securitySchemes" ) # Condition 2: scheme must be *required*, not merely offered. if not _scheme_is_required(card, scheme_name): raise UnauthorizedWebhookScheme( f"signing scheme {scheme_name!r} is offered but not required by `security`; " "presence in securitySchemes is a capability advertisement, not a signing contract" ) # Condition 3: card version must match what was fetched; a rotated key with # an unchanged card is a replay window, not a rotation. if live_card_version != card.version: raise UnauthorizedWebhookScheme( f"card version drift: cached={card.version!r} live={live_card_version!r}; " "re-fetch and re-bind before accepting webhooks" ) expected = hmac.new(signing_key, body, hashlib.sha256).digest() if not hmac.compare_digest(expected, signature): raise UnauthorizedWebhookScheme("signature mismatch against authorized scheme key") def apply_state_transition( *, card: CachedCard, live_card_version: str, current_state: str, target_state: str, jws_header: dict[str, Any], body: bytes, signature: bytes, signing_key: bytes, ) -> str: TERMINAL = {"completed", "failed", "canceled"} if current_state in TERMINAL: raise UnauthorizedWebhookScheme( f"task already terminal ({current_state}); refusing further transitions" ) # Verification is a precondition on the transition, not a post-hoc check. verify_push_webhook( card=card, live_card_version=live_card_version, jws_header=jws_header, body=body, signature=signature, signing_key=signing_key, ) return target_state ```