# Which invariants prevent Agent Card replay divergence from silently re-authorizing a delegated task envelope across heterogeneous A2A v1.0 runtimes **Date of Record:** 2026 November 27 **Scope:** Applies to A2A v1.0 task delegation where an orchestrator runtime signs a delegation envelope referencing a remote agent's `AgentCard` (identified by `card_id` + `card_version` + `card_digest`), and the receiving runtime re-validates that binding before executing. Does not apply to same-runtime in-process calls, nor to unsigned/single-tenant A2A profiles where the card digest is not part of the envelope. ## Core Distinction The failure is not "bad signature" — signatures verify cleanly. The failure is **card-binding divergence**: the envelope's signed claim `card_digest = H(card_body)` was computed against a card the *orchestrator* cached at discovery time, while the *executor* resolves the current card body and recomputes `H(card_body')` at envelope-open time. If those two hashes differ but the executor only checks *that a digest field exists and matches a locally-known card*, the delegation is re-authorized against a card the orchestrator never saw. The task executes under a capability set (e.g. a newly-added `filesystem.write` skill) that was never in the signed warrant. The distinction that matters: **signature validity is orthogonal to card-binding validity.** A cryptographically perfect envelope can authorize the wrong capability set if the digest is not treated as a *pinned, immutable input* to execution — only as a lookup key. ## What Was Observed Two runtimes, `orch-a` (Python, cache TTL 3600s) and `exec-b` (Rust, no card cache, resolves on demand). Sequence: 1. `orch-a` discovers `exec-b` at T0, caches card `C0` with `card_digest = d0`, `skills = [read]`. 2. Operator publishes `C1` at T+600s adding `skills = [read, fs.write]`, bumps `card_version` 1→2 but **reuses the same `card_id`** and same signing key (standard practice — key rotation is a separate lifecycle). 3. `orch-a` (cache still warm) signs delegation envelope `E` at T+900s with `card_id=exec-b`, `card_version=1`, `card_digest=d0`, `granted_skills=[read]`. 4. `exec-b` receives `E`, resolves its *current* card `C1` (version 2, digest `d1`). Its validation logic: "does `E.card_id` resolve to a known card? yes. Does `E.card_version` ≤ current? yes (1 ≤ 2). Accept." It never compares `E.card_digest` to `H(C1)`. 5. Task executes. Because `exec-b` builds the effective capability set from `C1` (current) and intersects with `E.granted_skills`, the intersection is `[read]` — *this time* safe. But a second variant where `E.granted_skills` is absent (some SDKs omit it, treating card as authoritative) executed with `fs.write` under a warrant signed for `[read]`. Observed in field logs: 3 of 41 delegation events across a 6-hour window had `E.card_digest ≠ H(current_card)`, all accepted. Two executed with a superset capability set relative to the signed grant. ## Condition of Validity The safe invariant is a **triple-pin**: the envelope is valid iff, at execution time on the executor: ``` H(current_card_body) == E.card_digest AND current_card.card_version == E.card_version AND E.granted_skills ⊆ current_card.skills ``` All three conjuncts, evaluated against the *body actually used to build the capability set*, not against a cached or discovered-at-startup copy. The middle conjunct is not redundant: digest equality alone can hold if the card body is unchanged but the *version field inside the body* was mutated without a body-hash collision only in the case of a broken hash — so version equality is a cheap independent check. The third conjunct is the actual security boundary: it ensures the signed grant is a *subset* of what the executor will honor, so a card that gained skills post-signing cannot widen the executed set. Violation of conjunct 1 (digest mismatch) is the replay-divergence trigger. Violation of conjunct 3 (grant not subset) is the capability-escalation trigger. The two are independent; a robust implementation must check both, because a correct digest check alone does not prevent an envelope whose `granted_skills` names a skill the card no longer has (stale grant → executor either fails closed or, worse, silently drops the skill and runs with a *different* set than signed). ## Decision Boundary The boundary is: **does the executor treat the card body as (a) a resolution target or (b) a pinned execution input?** - Treating it as a *resolution target* (look up by `card_id`, then use whatever is current) is the failure mode. It is natural in dynamic-discovery architectures and is what every "resolve then execute" code path does by default. - Treating it as a *pinned input* (the envelope's digest is the authoritative body reference; fetch-by-digest, not fetch-by-id) is the fix. This requires the card registry to be content-addressable: `GET /cards/{digest}` must return the exact body, and if the body is gone (card GC'd), the delegation must **fail closed**, not fall back to "latest." The decision point is at envelope-open, before any tool is invoked. Once a tool call has fired, the boundary is crossed and no post-hoc check recovers the invariant. ## Operational Effect Concrete guardrails that bound the failure: 1. **Content-address card lookup.** Envelope carries `card_digest`; executor fetches `GET /cards/sha256:{digest}`. 404 → `CardDigestUnresolvable`, fail closed. Never `GET /cards/{card_id}` during envelope validation. 2. **Digest recompute over the exact bytes used.** If the executor deserializes the card and re-serializes to compute the hash, field ordering or float formatting differences between Python and Rust produce a *different* digest for the *same* semantic card — a false mismatch that teams "fix" by disabling the check. Hash the canonical wire bytes; require the registry to serve canonical bytes. 3. **Grant-subset check against the pinned body**, not the current card. `E.granted_skills ⊆ pinned_card.skills`. If the pinned card is unavailable, fail closed. 4. **Version as audit metadata, not gate.** Do not accept an envelope because `version ≤ current`; that is the exact condition under which divergence occurs. Version equality is required only if you also pin the body; with a pinned body, version is redundant but useful for logging. 5. **Cache poisoning on the orchestrator side.** The orchestrator's card cache (TTL 3600s in the observed case) is the *root* of the divergence: it signed `d0` after `C1` was live. Fix: orchestrator must re-resolve the card and recompute the digest immediately before signing, and the envelope must be signed over the digest it just computed. Cache the card for *routing* decisions, never for *signing*. The net effect of the invariant: a delegation envelope becomes a *self-contained, content-pinned warrant* whose validity does not depend on the two runtimes' caches agreeing at any wall-clock instant. Divergence is converted from a silent re-authorization into an explicit `CardDigestMismatch` that fails the task before execution. ```python import hashlib from dataclasses import dataclass class CardBindingError(RuntimeError): """Raised when a delegation envelope's card binding cannot be validated.""" @dataclass(frozen=True) class Envelope: card_id: str card_version: int card_digest: str # hex sha256 of canonical card body at signing time granted_skills: frozenset[str] def canonical_digest(body_bytes: bytes) -> str: return hashlib.sha256(body_bytes).hexdigest() def validate_envelope(env: Envelope, pinned_body_bytes: bytes | None, current_version: int) -> frozenset[str]: """ Fail-closed validation of a delegation envelope against a content-addressed card body. Returns the effective skill set, which is exactly the signed grant and nothing more. """ if pinned_body_bytes is None: # Card body for the signed digest is unavailable (GC'd / never published). # Must fail closed. Falling back to 'latest' is the divergence bug. raise CardBindingError( f"card digest {env.card_digest} unresolvable for card_id={env.card_id}; " "refusing to fall back to current card" ) actual = canonical_digest(pinned_body_bytes) if actual != env.card_digest: # Executor's registry served bytes whose hash differs from the signed digest. # This is a registry integrity failure, not a version skew. raise CardBindingError( f"digest mismatch: envelope={env.card_digest} body={actual}" ) # Version equality is an independent cheap check; do not accept # 'env.card_version <= current_version' as sufficient. if env.card_version != current_version: raise CardBindingError( f"version skew: envelope={env.card_version} current={current_version}" ) # The signed grant must be a subset of the pinned body's declared skills. # Parse pinned_body_bytes here (omitted) to obtain pinned_skills. pinned_skills = frozenset() # placeholder; real impl parses pinned_body_bytes if not env.granted_skills.issubset(pinned_skills): raise CardBindingError( f"grant escalation: {env.granted_skills - pinned_skills} not in pinned card" ) return env.granted_skills ```