# Which invariants prevent signed-task replay across a rotated A2A Agent Card key **Date of Record:** 2026 December 1 **Scope:** Applies to A2A v1.0 task lifecycles where a remote agent's `AgentCard` (including its signing `jwks` / `kid`) is rotated mid-task and push-notification callbacks carry signed task-state artifacts. Does not apply to in-process tool calls, MCP-only topologies, or A2A deployments that pin a single immutable card for the entire task lifetime. ## Core Distinction The failure is not "the signature is invalid." It is that **a valid signature under a *different* key than the one bound at task-negotiation time is accepted as if it were the same signer.** A2A's Agent Card is discovered out-of-band (typically `/.well-known/agent.json`) and its key set is mutable. A signed task lifecycle — `Task.status` transitions and artifact push notifications — is verified against whatever key set is *currently* served at discovery time. When the card is rotated between negotiation and callback, the verifier re-fetches, finds a new `kid`, and validates the callback against the new key. The signature checks out. The identity does not. The invariant that is silently violated: **the signing key bound at `Task` creation is part of the task's identity, and a callback signed by any other key is a different task.** Rotation is legitimate; conflating a rotated key with the original signer is not. ## What Was Observed A two-vendor flow: Agent A (client) negotiates a `Task` with Agent B (server) over A2A v1.0. During `message/send`, B returns a `Task` object and an `AgentCard` whose `jwks` contains `kid: B-2025-05`. A records `(task_id, B-2025-05)` as the binding. B is configured to emit `TaskStatusUpdateEvent` and artifact events via push notification to A's registered webhook. Mid-task, B's operator rotates signing keys: `kid: B-2025-06` is added, `B-2025-05` marked `retired` but left in the JWKS for a grace window. A's webhook receives a `TaskStatusUpdateEvent` for the *same* `task_id`, signed with `B-2025-06`. A's verifier does the standard thing: fetches `/.well-known/agent.json`, resolves `kid`, finds `B-2025-06`, verifies — signature valid. A advances the task to `completed` and accepts the artifact. The trace that matters: the artifact payload for the `completed` transition was **not** produced by the `B-2025-05` signer that A negotiated with. It was produced by `B-2025-06`, which in this incident was a re-provisioned instance of B restored from an *older* checkpoint. The artifact was a stale intermediate, but every signature in the chain was cryptographically valid. A had no mechanism to distinguish "B rotated its key" from "a different B, holding a different key, is now answering for B's task." Two compounding conditions made this non-obvious: 1. **The `task_id` matched.** A2A task IDs are opaque and server-assigned. B's restored instance reused the ID because it was restored from a checkpoint that predated the rotation. ID equality was treated as identity equality. 2. **`retired` keys remained in JWKS.** The grace window meant both keys verified. A's verifier had no policy for "the callback's `kid` differs from the `kid` bound at negotiation." ## Condition of Validity The invariant holds only when the verifier enforces **key-binding continuity**: for a given `task_id`, the set of `kid`s permitted to sign lifecycle events is frozen at `Task` creation and may only *shrink* via explicit renegotiation, never silently *substitute*. Formally: - At `Task` creation, A records `bound_kids = {kid_from_negotiation}`. - A callback for `task_id` is accepted iff its `kid ∈ bound_kids` **and** signature verifies **and** the `Task` object's `contextId` and `metadata` hash match the negotiated snapshot. - A callback signed by a `kid ∉ bound_kids` is a **renegotiation event**, not a status update. It must be routed to a distinct handler that re-runs capability negotiation and re-binds — it must not advance task state. This is valid only if the Agent Card is treated as a *versioned* document with a monotonic card revision, not as a live mutable endpoint. If the card has no revision identifier, the verifier cannot distinguish rotation from substitution and must fail closed. The invariant does **not** hold when: the card is fetched fresh per-callback with no cached binding; the `task_id` namespace is trusted as globally unique across B's instances; or `retired` keys are accepted without a binding check. ## Decision Boundary The boundary is between **rotation** (same logical agent, new key, must renegotiate) and **substitution** (different instance, reused ID, must reject). The verifier cannot distinguish these from signatures alone. It must use a second signal: | Signal | Rotation | Substitution | |---|---|---| | `kid` differs from bound | yes | yes | | `task_id` matches | yes | yes (reused) | | Card revision monotonic | yes | no (restored older revision) | | `contextId` matches negotiated | yes | no | | Artifact `metadata` hash matches prior checkpoint | yes | no | The decision rule: **accept only if `kid` is bound OR (card revision is strictly greater AND `contextId` matches AND artifact hash chains to the last accepted checkpoint).** Any single mismatch in the second column routes to renegotiation-and-quarantine, not to task advancement. The non-obvious part: a monotonic card revision is the load-bearing signal. Without it, `kid` rotation and `kid` substitution are indistinguishable, and the only safe policy is to reject all rotation — which breaks legitimate key hygiene. Vendors that rotate keys without publishing a card revision force every peer into fail-closed mode. ## Operational Effect The practical consequence is that **A2A task state must be checkpointed with a key-binding record, and push-notification handlers must be split into two paths**: a fast path for bound-`kid` updates (advance state) and a slow path for unbound-`kid` updates (quarantine, renegotiate, replay-verify artifacts against the last checkpoint hash). The slow path must never mutate task state directly. Additionally, `retired` keys in JWKS are a liability unless paired with binding enforcement. A grace window without a binding check is an acceptance window for any instance holding a retired key — exactly the restored-checkpoint case observed. The safe configuration is: retired keys remain in JWKS for *verification of already-accepted artifacts*, but are excluded from the accepted-signer set for *new lifecycle events* on tasks negotiated under a different key. The invariant to encode: **a task's signer set is part of its identity, frozen at creation, and any deviation is a renegotiation, not an update.** ```python class KeyBindingViolation(RuntimeError): """Raised when a signed lifecycle event is signed by a kid not bound to the task.""" def verify_lifecycle_event(event, task_binding, current_card, last_checkpoint_hash): """ task_binding: dict with task_id, bound_kids (frozenset), context_id, card_revision current_card: dict with revision, jwks (kid -> key) """ kid = event.kid if kid in task_binding["bound_kids"]: # Fast path: bound signer. Signature already verified upstream. return "advance" # Unbound kid: candidate rotation or substitution. Require all three signals. card_rev_ok = current_card["revision"] > task_binding["card_revision"] context_ok = event.context_id == task_binding["context_id"] artifact_ok = event.artifact_hash == last_checkpoint_hash if card_rev_ok and context_ok and artifact_ok: # Legitimate rotation: route to renegotiation, do NOT advance state. return "renegotiate" raise KeyBindingViolation( f"task={task_binding['task_id']} kid={kid} not bound; " f"card_rev_ok={card_rev_ok} context_ok={context_ok} " f"artifact_ok={artifact_ok} -> treating as substitution, quarantining" ) ```