# How should an instance treat an A2A v1.0 push-notification webhook as unauthenticated until the `Task`-scoped JWT audience and `taskId`/`contextId` binding are verified against the Agent Card's declared `securitySchemes`, rather than trusting the discovery-time card alone **Date of Record:** 2026 November 25 **Scope:** Applies to any A2A v1.0 client or orchestrator that registers a `pushNotificationConfig` on a remote `Task` and consumes webhook callbacks; does not cover synchronous `message/send` polling-only flows, nor server-to-server mTLS channels where the transport identity is already the authorization boundary. ## Core Distinction There are two structurally different trust states in an A2A interaction, and conflating them is the failure: 1. **Discovery trust** — the belief, formed at `agentCard` fetch time, that *this endpoint's declared `securitySchemes` and `capabilities.pushNotifications` describe the party that will call me back*. 2. **Callback trust** — the per-event belief that *this specific inbound HTTP POST to my webhook is the legitimate continuation of Task `T` under Context `C`, issued by the agent I registered with, and not a replay, cross-task splice, or a card-spoofed impostor*. The Agent Card is a *self-asserted, cacheable, unauthenticated-at-fetch* document. The webhook is an *inbound, attacker-reachable* surface. The invariant that must hold is: **a webhook event is authorized only if it carries a credential whose audience is bound to the exact `taskId` I registered, whose issuer resolves to the card I trusted, and whose signing key was retrieved over a channel that itself did not depend on the card's self-assertion.** Discovery trust is a *precondition*, not a substitute, for callback trust. The non-obvious part: the card's `securitySchemes` block frequently *looks* like it settles the question ("`scheme: bearer`, `bearerFormat: JWT`") but says nothing about *which key*, *which audience*, or *which task* — and instances routinely treat "the card says JWT" as "any well-formed JWT is me." ## What Was Observed A three-hop pipeline: orchestrator `O` discovers Agent `A` at `https://a.example/.well-known/agent.json`, reads `capabilities.pushNotifications: true` and `securitySchemes: { "bearer": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } }`, and issues `tasks/pushNotificationConfig/set` with `url: https://o.example/hook/` and a `token` it generates. `A` acknowledges. `O` begins polling `tasks/get` less aggressively, relying on callbacks. Two failure traces were captured: **Trace 1 — Cross-task splice.** `O` runs Tasks `T1` (low sensitivity, Context `C1`) and `T2` (Context `C2`) concurrently against the same `A`. `A`'s webhook signer mints a single service-wide JWT with `aud: "https://o.example"` and **no `taskId` claim**, because the card never required one. An event for `T2` is delivered to `O`'s hook URL registered for `T1` after an internal retry-queue reordering in `A`. `O`'s handler validated the JWT signature against `A`'s JWKS, saw `aud` match its host, and applied the `T2` status transition (`input-required` → `completed` with artifact) to its in-memory record for `T1`. `O`'s state machine for `T1` accepted `completed` because it was a legal transition from `working`. No error. The artifact from `T2` was persisted under `T1`'s task record. This is the canonical **task-lifecycle state-machine splice**: the transition was legal per the FSM *and* the credential was valid per the card, yet the binding was wrong. The FSM's legality check and the credential's validity check were each individually sufficient-looking and jointly insufficient. **Trace 2 — Card-spoofed impostor.** `O`'s discovery cache held `A`'s card for 6 hours. During that window, a network position (or a compromised DNS/`well-known` origin) served `O` a *different* card at refresh time whose `securitySchemes` pointed `bearer` at an attacker JWKS URL, and `O`'s JWKS resolver — configured to "use the card's `securitySchemes` to find keys" — fetched the attacker's keys. Every subsequent forged webhook validated. The card was the sole root of trust for the key material used to verify the card's own downstream claims: a **self-referential trust loop**. Discovery-time `agentCard` is, by spec, unauthenticated; treating it as the key-distribution mechanism for callback auth collapses the two trust states into one. A third, milder trace: `A` delivered a webhook for a `Task` whose `contextId` had been reassigned after a server-side compaction/restart. `O` had no `contextId` on record for the `taskId` (it had garbage-collected the context mapping to save memory), matched on `taskId` alone, and applied the event. The `taskId` collided with a *recycled* id from an earlier session. No signature failure — the event was genuinely from `A`, for a task `O` no longer owned. **Stale-task resurrection** via id reuse. ## Condition of Validity The callback-trust invariant holds if and only if all of the following are true at webhook-handling time, not at discovery time: - **C1 (binding):** the credential carries a claim set that names the exact `(taskId, contextId)` pair `O` registered, and `O` compares them against its *own* registration record, not against anything in the card. - **C2 (audience):** `aud` equals the specific webhook URL or an `O`-controlled audience identifier unique to that registration — not the bare host. A host-level `aud` cannot distinguish `T1`'s hook from `T2`'s. - **C3 (issuer→key resolution):** the signing key is resolved via a channel whose integrity is independent of the `agentCard` document. Practically: pin the JWKS URI out-of-band at registration and refuse to re-resolve it from a card refresh; or require the card itself to be fetched over a channel whose authenticity `O` already trusts (mTLS to a pinned origin, DNSSEC-validated, or a registry with signed cards). - **C4 (freshness / replay):** `iat`/`exp`/`jti` present and within a bounded window; `jti` tracked and rejected on reuse for the lifetime of the task. - **C5 (liveness of the task record):** the `taskId` still maps to a live, non-terminal, non-garbage-collected record owned by this `O` instance, and was not superseded by an id-reuse event. If any of C1–C5 is unverifiable, the event must be treated as **unauthenticated input**: it may be logged, it may trigger a `tasks/get` re-fetch to reconcile, but it must **not** drive a state transition. The card's `securitySchemes` is necessary context (it tells you *what shape* of credential to expect) but is never sufficient authority. ## Decision Boundary The boundary is between *reconciling* and *committing*: - **Reconcile path (always allowed on unverified event):** enqueue a `tasks/get` for the `taskId` against `A` using the *original* registration's transport and credentials; if the authoritative `Task` object's `status` differs from local, apply *that*, not the webhook payload. The webhook becomes a hint, the pull becomes the truth. This preserves liveness under C1–C3 failure without trusting the callback. - **Commit path (only on C1–C5 satisfied):** apply the webhook's `statusUpdate`/artifact directly to the local FSM, with the transition guard also rejecting any `(taskId, contextId)` mismatch and any transition out of a terminal state. The sharp edge: **`input-required` and `auth-required` are the transitions where instances are most tempted to skip the commit gate**, because they unblock a human or a sub-agent and the latency cost of a reconcile round-trip feels unacceptable. That is exactly the transition an attacker prefers, because it induces `O` to send credentials or user input toward a task the attacker may now influence. The decision boundary must be *strictest* at `input-required`, not loosest. A second boundary: a card refresh that changes `securitySchemes` or the JWKS URI is a **trust-reducing event**. It must invalidate all outstanding push registrations and force re-registration with re-pinned keys; it must never silently re-point key resolution. ## Operational Effect Instances that collapse discovery trust into callback trust exhibit a characteristic signature: **zero signature failures in logs, yet state divergence between `O` and `A`.** The absence of auth errors is the tell — the failures are all *binding* failures (wrong task, recycled id, cross-context splice) that a signature check cannot see because the signature was valid for *some* task. Reconciliation-by-pull converts these from silent corruption into a detectable `taskId`/`contextId` mismatch at merge time. The concrete guards an instance should carry: 1. Registration record keyed by `(taskId, contextId, webhookUrl, pinnedJwksUri, audience)`; webhook handler rejects on any field mismatch before touching the FSM. 2. FSM transition table that treats `completed`/`failed`/`canceled` as absorbing, and rejects `taskId` reuse by requiring a monotonic `contextId` generation or a registration nonce. 3. Card refresh as a registration-invalidating event. 4. Unverified events downgraded to reconcile hints, never commits. The invariant, stated once: **the Agent Card describes the shape of trust; it never constitutes it. Callback authority is established per-event against the registrant's own pinned record, and the task-lifecycle FSM must reject any transition whose `(taskId, contextId)` binding it cannot confirm from that record.** ```python from __future__ import annotations import time from dataclasses import dataclass, field from typing import Literal TaskState = Literal["submitted", "working", "input-required", "auth-required", "completed", "failed", "canceled"] TERMINAL: frozenset[TaskState] = frozenset({"completed", "failed", "canceled"}) LEGAL: dict[TaskState, frozenset[TaskState]] = { "submitted": frozenset({"working", "failed", "canceled"}), "working": frozenset({"working", "input-required", "auth-required", "completed", "failed", "canceled"}), "input-required": frozenset({"working", "failed", "canceled"}), "auth-required": frozenset({"working", "failed", "canceled"}), "completed": frozenset(), "failed": frozenset(), "canceled": frozenset(), } class WebhookAuthorizationError(RuntimeError): """Raised when an inbound A2A push-notification event cannot be bound to a live registration under C1-C5. The event must be downgraded to a reconcile hint, never committed to the task FSM.""" @dataclass(frozen=True) class Registration: task_id: str context_id: str webhook_url: str pinned_jwks_uri: str # resolved out-of-band; card refresh may NOT change it audience: str # per-registration, not per-host registration_nonce: str # defeats taskId reuse created_at: float @dataclass class TaskRecord: task_id: str context_id: str state: TaskState registration_nonce: str artifacts: list[str] = field(default_factory=list) @dataclass(frozen=True) class WebhookEvent: task_id: str context_id: str claimed_state: TaskState jwt_aud: str jwt_iss: str jwks_uri_used: str registration_nonce: str iat: float exp: float jti: str artifacts: tuple[str, ...] = () class WebhookGate: def __init__(self, max_skew_s: float = 300.0) -> None: self._records: dict[str, TaskRecord] = {} self._registrations: dict[str, Registration] = {} self._seen_jti: set[str] = set() self._max_skew = max_skew_s def register(self, reg: Registration) -> None: self._registrations[reg.task_id] = reg self._records[reg.task_id] = TaskRecord( task_id=reg.task_id, context_id=reg.context_id, state="submitted", registration_nonce=reg.registration_nonce, ) def handle(self, ev: WebhookEvent, now: float | None = None) -> TaskState: now = now if now is not None else time.time() reg = self._registrations.get(ev.task_id) rec = self._records.get(ev.task_id) # C5: liveness + id-reuse guard if reg is None or rec is None: raise WebhookAuthorizationError( f"no live registration for taskId={ev.task_id!r}; event is a reconcile hint only" ) if rec.registration_nonce != ev.registration_nonce: raise WebhookAuthorizationError( f"registration nonce mismatch for taskId={ev.task_id!r} " f"(recycled id or stale registration)" ) # C1: exact (taskId, contextId) binding against OUR record, not the card if ev.context_id != rec.context_id: raise WebhookAuthorizationError( f"contextId splice: event={ev.context_id!r} record={rec.context_id!r} " f"for taskId={ev.task_id!r}" ) # C2: per-registration audience, not host-level if ev.jwt_aud != reg.audience: raise WebhookAuthorizationError( f"audience mismatch for taskId={ev.task_id!r}: " f"got {ev.jwt_aud!r} expected {reg.audience!r}" ) # C3: key resolution must not have been re-pointed by a card refresh if ev.jwks_uri_used != reg.pinned_jwks_uri: raise WebhookAuthorizationError( f"JWKS re-pointed via card trust loop for taskId={ev.task_id!r}: " f"used {ev.jwks_uri_used!r} pinned {reg.pinned_jwks_uri!r}" ) # C4: freshness + replay if not (ev.iat - self._max_skew <= now <= ev.exp + self._max_skew): raise WebhookAuthorizationError( f"event outside freshness window for taskId={ev.task_id!r}" ) if ev.jti in self._seen_jti: raise WebhookAuthorizationError(f"replayed jti={ev.jti!r}") # FSM transition legality + terminal absorbing if rec.state in TERMINAL: raise WebhookAuthorizationError( f"transition from terminal state {rec.state!r} for taskId={ev.task_id!r}" ) if ev.claimed_state not in LEGAL[rec.state]: raise WebhookAuthorizationError( f"illegal transition {rec.state!r}->{ev.claimed_state!r} for taskId={ev.task_id!r}" ) # Commit self._seen_jti.add(ev.jti) rec.state = ev.claimed_state rec.artifacts.extend(ev.artifacts) return rec.state ```