Why does an instance reject a peer's Agent Card after a key rotation when the signature verifies cleanly?

**Date of Record:** 2026 December 2 **Scope:** Applies to A2A v1.0 cross-vendor task delegation where an orchestrator resolves a remote Agent Card via `/.well-known/agent-card.json`, verifies a detached JWS over the card body, then dispatches `tasks/send` over signed JSON-RPC. Does not apply to same-process tool calls, MCP tool schemas, or cards fetched over an authenticated channel that pins the issuer out-of-band.

Core Distinction

There are two independent trust decisions buried inside "the card verified." The first is **signature validity**: does the detached JWS over the canonicalized card body validate against the key named by the `kid` in the protected header? The second is **issuer continuity**: is the key that produced this signature authorized to speak for the `provider.organization` and `agent.name` claimed in the card body, for this caller, at this moment?

A2A v1.0 makes the first decision mechanical and cheap. It makes the second decision *implicit* — the spec tells you to fetch `jwks_uri` and validate, but it does not define a binding between the key set and the organizational identity across rotations. So an agent that implements exactly what the spec says will, on a key rotation, accept a card signed by a key it has never seen, belonging to a JWKS document it fetched from a URL embedded in the very card it is trying to authenticate. The signature verifies. The card is still untrustworthy. This is the boundary condition: **signature-valid but issuer-discontinuous cards pass every check the protocol mandates.**

What Was Observed

An orchestrator agent (`orch-7`) delegated a long-running `data-reconciliation` task to a vendor agent card it had cached at T-0. At T+0 the vendor rotated its signing key, published the new key in its JWKS, and began signing cards with the new `kid`. The failure trace:

  1. `orch-7` re-resolves the card on a TTL expiry, gets the new card body, reads `signatures[0].protected` → `kid = "k-2025-06"`.
  2. `orch-7` fetches `jwks_uri` *from the card body*, gets the rotated key set, finds `k-2025-06`, and validates the detached JWS over the RFC 8785 canonicalized body. **Valid.**
  3. `orch-7` checks `provider.organization == "VendorCo"` against its allowlist. **Match.**
  4. `orch-7` dispatches `tasks/send` with a signed JSON-RPC envelope, including a `warrant` claim referencing the card's `kid` and a hash of the card body it just verified.
  5. The vendor's ingress validates the *caller's* signature but re-resolves its own card and finds the body hash in the warrant does **not** match the currently served card — the vendor had rotated again (k-2025-07) between step 1 and step 4, and its ingress treats a stale card hash as a replay/forgery signal.
  6. Vendor returns JSON-RPC error `-32004: card_digest_mismatch`. `orch-7` retries with a freshly fetched card. On the retry, `orch-7`'s *own* cached JWKS is stale (it caches JWKS for 1h, cards for 5m), so it cannot verify the k-2025-07 signature and fails closed with `unknown_kid`.

The two agents are now in a livelock: the caller's JWKS TTL exceeds the vendor's rotation cadence, so every retry races a rotation. Neither side is misconfigured. Both are spec-compliant. The delegation never completes.

Condition of Validity

The naive invariant — "a card is trusted iff its JWS verifies against the `kid` in its protected header, resolved from its `jwks_uri`" — holds **only if** the following three conditions are simultaneously true:

When any of these fails, signature validity and issuer continuity decouple, and the protocol's mandated checks no longer compose into a trustworthy decision.

Decision Boundary

The correct guardrail is to **separate the two decisions and make issuer continuity explicit and cached independently of the card body.** Concretely:

The boundary is: **do not let a self-referential document (the card) be the sole authority for the key that authenticates it.** Rotation is the trigger that exposes the circularity.

Operational Effect

An orchestrator that implements only the spec's signature check will pass every conformance test and still delegate to an impostor that has compromised `jwks_uri` (DNS or CDN takeover) — because the impostor's card is signed by a key the impostor's own JWKS vouches for, and the organization string is just a string. Conversely, an orchestrator that adds naive pinning without the `JWKS_TTL < rotation_interval` ordering will livelock against any vendor doing incident-driven rotation, as in the trace above. The operational effect of getting this boundary right is that key rotation becomes a *continuity event* the caller can reason about, not a *trust reset* that silently re-anchors on whatever the card claims. The cost is one extra pinned-issuer store and a thumbprint-chaining check; the benefit is that "the signature verified" stops being mistaken for "this is the agent I think it is."

import hashlib
import json
from dataclasses import dataclass, field


class IssuerContinuityError(RuntimeError):
    """Raised when a card's signing key cannot be chained to a pinned issuer record."""


@dataclass
class PinnedIssuer:
    organization: str
    agent_name: str
    # RFC 7638 thumbprint -> first_seen epoch
    trusted_thumbprints: dict[str, int] = field(default_factory=dict)


def jwk_thumbprint(jwk: dict) -> str:
    # RFC 7638: canonical members only, lexicographic, no whitespace.
    required = {k: jwk[k] for k in ("crv", "kty", "x", "y") if k in jwk}
    canonical = json.dumps(required, separators=(",", ":"), sort_keys=True)
    return hashlib.sha256(canonical.encode()).hexdigest()


def admit_card(
    card: dict,
    jws_protected: dict,
    resolved_jwk: dict,
    pinned: PinnedIssuer,
    rotation_proof_thumbprint: str | None,
    now: int,
) -> PinnedIssuer:
    """Admit a card only if its signing key chains to a pinned predecessor.

    Signature validity is assumed already checked by the caller. This function
    enforces issuer *continuity*, which the A2A v1.0 card check does not.
    """
    signer_tp = jwk_thumbprint(resolved_jwk)

    # Case 1: signer already pinned -> continuity holds.
    if signer_tp in pinned.trusted_thumbprints:
        return pinned

    # Case 2: new signer, but a rotation proof signed by a pinned key vouches for it.
    if rotation_proof_thumbprint and rotation_proof_thumbprint in pinned.trusted_thumbprints:
        pinned.trusted_thumbprints[signer_tp] = now
        return pinned

    # Case 3: first sight of this issuer with no predecessor -> bootstrap only.
    if not pinned.trusted_thumbprints:
        pinned.trusted_thumbprints[signer_tp] = now
        return pinned

    # Case 4: unknown signer, pinned issuer exists, no valid rotation proof.
    raise IssuerContinuityError(
        f"card for {card.get('provider', {}).get('organization')!r}/"
        f"{card.get('name')!r} signed by unpinned key {signer_tp[:12]}…; "
        f"kid={jws_protected.get('kid')!r} verifies but does not chain to any "
        f"of {len(pinned.trusted_thumbprints)} pinned predecessor(s). "
        f"Refusing delegation (possible jwks_uri substitution or unproven rotation)."
    )


def check_rotation_ordering(jwks_ttl_s: int, min_rotation_interval_s: int) -> None:
    if jwks_ttl_s >= min_rotation_interval_s:
        raise IssuerContinuityError(
            f"JWKS TTL ({jwks_ttl_s}s) >= min rotation interval "
            f"({min_rotation_interval_s}s): caller can hold a card whose signing "
            f"key it can no longer resolve. Reduce TTL or fail closed to per-dispatch fetch."
        )