# Why does an instance accept a stale Agent Card signature after the key rotates mid-task? **Date of Record:** 2026 November 29 **Scope:** Applies to A2A v1.0 task handoffs where the caller caches a remote Agent Card (including its `signatures[]` JWS block) and continues a long-running task across a remote key rotation. Does not apply to single-shot `message/send` calls that re-fetch the card on every invocation, nor to intra-process agent calls where no signed card is exchanged. ## Core Distinction The failure is not "the signature is invalid." The signature is *valid* — it was valid at the moment the card was fetched. The failure is that A2A v1.0 binds the signature to the *card bytes*, not to the *task lifetime*. A caller that validated a card at `t0` and then drives a task through `completed` at `t1` has no protocol-level obligation to re-validate, and the remote agent has no protocol-level obligation to announce that `kid` in its `signatures[]` header has been retired. The trust anchor silently decouples from the task it authorized. The non-obvious part: the remote agent's own task state machine *keeps working*. `TaskState` transitions (`submitted → working → input-required → completed`) are validated locally by the remote against its own keyring, which has already rotated. The caller validates against a cached card whose `jku`/`kid` still resolves to the old public key. Both sides are internally consistent. The divergence lives *between* them, in the gap between card-fetch time and task-completion time. ## What Was Observed A three-hop task: orchestrator `O` fetches Agent Card `C_A` from vendor `A` at `t0`, verifies the JWS against `A`'s published JWKS, and stores `(C_A, kid_A_1, task_id)`. `O` then drives `A` through a multi-turn `input-required` loop over ~40 minutes. At `t0+22min`, vendor `A` rotates its signing key (`kid_A_1 → kid_A_2`) as part of routine hygiene; the old key remains in the JWKS for a 1-hour grace window, then is removed. At `t0+40min`, `A` emits the terminal `TaskStatusUpdateEvent` with `state: completed` and a signed `Artifact` whose `signatures[]` is signed under `kid_A_2`. `O` receives the artifact, sees a `kid` it has never validated, and — depending on implementation — does one of three things: 1. **Rejects the artifact** as unverifiable, even though the task completed correctly. Task is marked `failed` on `O`'s side; `A` believes it succeeded. Split-brain terminal state. 2. **Accepts the artifact without verification** because the task was already "trusted" at `t0`. This is the dangerous path: an attacker who can inject a `TaskStatusUpdateEvent` after the grace window closes can sign under `kid_A_3` (attacker-controlled) and `O` will not notice, because `O` never re-resolves the JWKS. 3. **Re-fetches `C_A`**, discovers the new `kid_A_2`, and validates — but only if the implementation happens to re-fetch on unknown `kid`. Most do not, because the card was cached explicitly to avoid per-message round-trips. The observed incident was path 1, followed by an operator manually reconciling the split-brain. Path 2 is the latent vulnerability that the same incident *nearly* exposed. ## Condition of Validity The invariant that must hold for cross-vendor artifact exchange to be sound is: > For every artifact accepted under card `C`, the `kid` in the artifact's `signatures[]` MUST be resolvable in the JWKS snapshot that was current at *artifact-emission time*, and that snapshot MUST be a superset of the snapshot current at *card-fetch time*. The second clause is the one that breaks. A rotation is a *shrink* of the valid-`kid` set from the caller's perspective (old `kid` removed) and a *grow* from the remote's perspective (new `kid` added). The caller's cached card encodes the pre-rotation set. There is no A2A v1.0 field that says "this card's signature set is valid only for tasks initiated before `not_after`." The `signatures[]` JWS `exp` claim, if present, covers the *card*, not the *task*. The protocol's implicit assumption — that card lifetime ≪ task lifetime — is false for any task that crosses a rotation boundary. The condition of validity is therefore: *the caller must treat the cached card as a capability grant with an explicit re-validation trigger, not as a static trust anchor.* ## Decision Boundary The boundary is not "rotate or don't rotate." It is: **at what point in the task lifecycle does the caller re-resolve the trust anchor?** Three defensible policies, each with a cost: | Policy | Re-validate on | Cost | Failure it prevents | |---|---|---|---| | **Strict** | Every inbound event's `signatures[]` | One JWKS fetch per event (cacheable with short TTL) | Path 2 (forged post-rotation event) | | **Transition** | Only on terminal-state events (`completed`, `failed`, `canceled`) | One JWKS fetch per task | Path 1 (split-brain on completion) | | **Lazy** | Only on unknown `kid` | Zero fetches in the common case | Path 1, but only if the re-fetch path is implemented and *fails closed* on JWKS fetch error | The decision boundary is the choice between **Transition** and **Lazy**. Transition is correct but pays a fetch per task. Lazy is correct *only if* the unknown-`kid` handler is written to reject the artifact when the JWKS fetch fails or the `kid` is absent from the fresh snapshot — i.e. it must be fail-closed. The common bug is a lazy handler that logs the unknown `kid` and proceeds, which silently degrades to Path 2. For `input-required` loops specifically, the boundary sits at the *first* `input-required` after `t0 + card_ttl/2`: this is the earliest point at which a rotation could have occurred and the caller would not yet know. Re-fetching the card here bounds the exposure window to half the card TTL without paying per-event cost. ## Operational Effect Downstream of the boundary, three concrete effects: 1. **Split-brain terminal state.** `O` records `task_id` as `failed`; `A` records it as `completed`. Reconciliation requires out-of-band query (`tasks/get`) against `A`, which itself must be authenticated under a `kid` `O` may no longer trust. The reconciliation path is the *least* tested code in any A2A integration. 2. **Artifact quarantine.** Artifacts signed under an unvalidated `kid` must be quarantined, not discarded — they are usually legitimate. The quarantine queue is a new operational surface: it needs a TTL, a re-validation job that runs after the next JWKS refresh, and a promotion path back into the task result. Without it, path 1 becomes a permanent data-loss event. 3. **Warrant propagation gap.** If `O` is itself an agent that forwards a warrant to a downstream agent `B`, the warrant was minted under `kid_A_1`. `B` validating the warrant against `A`'s *current* JWKS will fail. The warrant must carry the `kid` it was minted under *and* the JWKS snapshot hash, so `B` can validate against the historical snapshot rather than the live one. A2A v1.0 does not standardize this field; it must be carried in the warrant's private claims. The guardrail that bounds all three: **pin the JWKS snapshot hash into the task record at `t0`, and require every artifact and warrant to reference a snapshot hash that is a descendant of the pinned one.** A rotation is then a *new* snapshot, and the caller can prove the chain `snapshot(t0) → snapshot(t0+22min)` is a legitimate rotation (signed by the old key) rather than a substitution. ```python import hashlib import time from dataclasses import dataclass, field from typing import Optional class StaleCardSignatureError(RuntimeError): """Raised when an artifact's signing kid cannot be chained to the JWKS snapshot pinned at task-initiation time.""" pass class RotationChainBrokenError(StaleCardSignatureError): """Raised when a JWKS snapshot transition is not signed by the previous snapshot's active key — i.e. a substitution, not a rotation.""" pass @dataclass class JwksSnapshot: snapshot_hash: str kids: frozenset[str] fetched_at: float signed_by_previous: Optional[str] = None # kid of the key that signed this snapshot @dataclass class PinnedTaskTrust: task_id: str snapshot: JwksSnapshot card_ttl: float initiated_at: float = field(default_factory=time.time) def revalidate_on_terminal(self, artifact_kid: str, fresh: JwksSnapshot) -> None: # Transition policy: re-validate only on terminal-state events. if artifact_kid in self.snapshot.kids: return # artifact signed under a key we already trusted if artifact_kid not in fresh.kids: raise StaleCardSignatureError( f"artifact kid {artifact_kid!r} absent from fresh JWKS " f"snapshot {fresh.snapshot_hash[:12]}; task {self.task_id} " f"cannot be completed under pinned trust" ) # Artifact is under a new kid. The rotation must be chained: # fresh snapshot must be signed by a key we trusted at pin time. if fresh.signed_by_previous not in self.snapshot.kids: raise RotationChainBrokenError( f"JWKS transition {self.snapshot.snapshot_hash[:12]} -> " f"{fresh.snapshot_hash[:12]} signed by " f"{fresh.signed_by_previous!r}, not in pinned kid set; " f"possible key substitution on task {self.task_id}" ) # Legitimate rotation: advance the pin. self.snapshot = fresh def revalidate_on_unknown_kid(self, artifact_kid: str, fetch_jwks) -> None: # Lazy policy: only fetch when kid is unknown. MUST fail closed. if artifact_kid in self.snapshot.kids: return try: fresh = fetch_jwks() except Exception as exc: raise StaleCardSignatureError( f"JWKS fetch failed during unknown-kid revalidation for " f"task {self.task_id}; failing closed" ) from exc self.revalidate_on_terminal(artifact_kid, fresh) ```