# How should an instance treat a replayed A2A delegation envelope whose signed `nonce` is valid but whose `issued_at` has slid outside the downstream warrant window? **Date of Record:** 2026 November 29 **Scope:** Applies to agent-to-agent (A2A) delegation where a signed envelope carries a capability warrant, a nonce, and an `issued_at`/`expires_at` pair, and where the receiving instance maintains a replay cache plus a warrant-validity window. Does not apply to single-hop MCP tool calls with no delegation chain, nor to envelopes whose signature is already rejected at ingress. ## Core Distinction There are two independent invariants in a signed A2A envelope, and they are routinely conflated: 1. **Freshness (replay resistance):** the `nonce` has not been seen before within the replay window. This is enforced by a monotonic cache keyed on `(issuer_id, nonce)`. 2. **Validity (warrant authority):** the envelope's `issued_at` falls inside the window `[expires_at - TTL, expires_at]` *and* inside the receiver's own warrant-acceptance window, which is anchored to the receiver's clock, not the sender's. A replay attack is normally modeled as "same nonce twice." The non-obvious failure is the **stale-but-unseen envelope**: a legitimately signed envelope that was *minted once*, never delivered (network partition, queue backlog, agent crash mid-send), and then delivered *late*—after `issued_at` has aged past the receiver's warrant window but before the nonce has ever been observed. The nonce check passes because the nonce is genuinely new to this receiver. The signature check passes because the envelope is authentic. Only the clock-window check can catch it, and that check is frequently implemented as a soft warning rather than a hard gate. ## What Was Observed A three-hop delegation chain `Orchestrator → Planner → Executor` used signed envelopes with a 300s warrant TTL. The Planner's outbound queue to the Executor stalled for 412s during an Executor restart. On recovery, the queued envelope for a `write_to_scratchpad` delegation was delivered. Trace at the Executor: - Signature verification: PASS (authentic Planner key). - Nonce lookup on `(planner_id, nonce=7f3a…)`: MISS → treated as fresh. - `issued_at` = T-412s; `expires_at` = T-112s. Receiver's warrant window is `now - 300s .. now`. The envelope's `issued_at` is 112s *outside* the window. - The Executor's implementation logged `warrant_window_miss` at WARN level and proceeded, because the nonce was valid and the signature was valid. The delegation executed against a warrant that had, in the intervening 412s, been *revoked* by the Orchestrator (the Planner's capability had been downgraded after a policy update). The Executor had no mechanism to learn of the revocation because the envelope was self-contained and the Executor does not poll the issuer. Result: an authorized-looking, cryptographically valid, replay-cache-clean envelope executed a revoked capability. The nonce cache could not help—there was nothing to replay; the envelope was simply *old*. The second-order effect was worse. The Executor's replay cache recorded the nonce on acceptance. When the Orchestrator later re-issued the *same logical delegation* with a fresh nonce and a current warrant, the Executor executed it again. The action was performed twice, and the replay cache had done its job perfectly for both envelopes—it had merely recorded two distinct nonces for what was, semantically, one delegation. ## Condition of Validity The freshness invariant (`nonce ∉ cache`) is **necessary but not sufficient** for accepting a delegation. The sufficient condition requires the conjunction: ``` accept(envelope) ⟺ sig_ok(envelope) ∧ nonce_unseen(issuer, nonce) ∧ issued_at ∈ [now - W_recv, now] # receiver-anchored lower bound ∧ expires_at ≥ now # not yet expired ∧ warrant_still_authoritative(envelope.warrant_id) # revocation-aware ``` The third conjunct is the one that fails in the stale-but-unseen case, and the fifth conjunct is the one that fails when the receiver has no revocation channel. An envelope that satisfies `sig_ok ∧ nonce_unseen` but violates either of the last two must be treated as a **rejected delegation**, not a warning. The nonce cache must *not* be updated on rejection of a stale envelope—otherwise a late-delivered envelope poisons the cache and causes a subsequent legitimate re-issue (same nonce, if the issuer reuses nonces, which it should not) to be dropped as a replay. ## Decision Boundary The boundary is not "is this a replay?" but "**is this envelope's authority still live at the moment of execution?**" Three regimes: - **Fresh and authoritative:** `issued_at` inside window, warrant not revoked. Accept, execute, record nonce. - **Fresh but stale-window (the failure case):** `nonce_unseen` true but `issued_at` outside `W_recv`. This is *not* a replay and *not* a forgery—it is a **lapsed delegation**. Reject with a distinct error class, do not record the nonce, and signal the issuer that the delegation must be re-minted. Do not silently execute; do not silently drop. - **Stale and revoked:** `issued_at` outside window *and* `warrant_still_authoritative` returns false. Reject, record the nonce (to prevent repeated delivery attempts from re-triggering the revocation check), and emit a `revoked_delegation_attempt` audit event. This is the case the nonce cache must *not* short-circuit, because the revocation check is the load-bearing one. The invariant that must hold across all three: **the receiver's clock, not the sender's `issued_at`, anchors the acceptance window.** A receiver that trusts `issued_at` relative to `expires_at` alone (i.e. `issued_at < expires_at`) accepts envelopes that are internally consistent but externally stale. The window must be computed against `now` at the receiver, with an explicit clock-skew allowance (typically ≤ 5s) that is *subtracted* from the window, never added. ## Operational Effect The architectural guardrail is a **two-key acceptance gate** where freshness and liveness are evaluated independently and both must pass, with the nonce cache updated only on full acceptance. Concretely: - The replay cache is keyed on `(issuer_id, nonce)` and stores the *acceptance timestamp*, not just presence. A nonce older than `W_recv + max_skew` is evicted, not retained forever—otherwise the cache grows unbounded and a long-lived agent eventually rejects all traffic as replay. - The warrant-liveness check is a separate call (local revocation list, or a short-TTL cached query to the issuer) that runs *after* the nonce check, so that a revoked-but-unseen envelope is caught even when the nonce is fresh. - Rejection of a lapsed delegation returns a structured `DelegationLapsed` signal to the issuer carrying the original nonce, so the issuer can distinguish "receiver never saw it" from "receiver rejected it as stale" and re-mint with a new nonce and current warrant. Without this signal, the issuer's retry loop re-sends the same stale envelope and the receiver rejects it indefinitely—a livelock across the A2A boundary. The failure mode this prevents is subtle: a system can be fully replay-resistant, fully signature-verified, and still execute revoked capabilities, because replay resistance and authority liveness are orthogonal invariants that happen to share an envelope. An instance that conflates them will pass every security review that tests for nonce reuse and fail the first time a message is delayed by more than the warrant TTL. ```python import time from dataclasses import dataclass class DelegationLapsed(RuntimeError): """Raised when a signed A2A envelope is authentic and nonce-fresh but its warrant window has slid outside the receiver's acceptance window.""" class WarrantRevoked(RuntimeError): """Raised when the envelope's warrant is no longer authoritative at the issuer, regardless of nonce freshness.""" @dataclass class Envelope: issuer_id: str nonce: str issued_at: float # sender clock expires_at: float # sender clock warrant_id: str signature_ok: bool class ReplayCache: def __init__(self, ttl: float): self._seen: dict[tuple[str, str], float] = {} self._ttl = ttl def unseen(self, issuer_id: str, nonce: str, now: float) -> bool: self._evict(now) return (issuer_id, nonce) not in self._seen def record(self, issuer_id: str, nonce: str, now: float) -> None: self._seen[(issuer_id, nonce)] = now def _evict(self, now: float) -> None: cutoff = now - self._ttl for key in [k for k, t in self._seen.items() if t < cutoff]: del self._seen[key] def accept_delegation( env: Envelope, cache: ReplayCache, warrant_is_live, now: float, recv_window: float = 300.0, max_skew: float = 5.0, ) -> None: # 1. Signature. if not env.signature_ok: raise DelegationLapsed(f"bad signature on nonce={env.nonce}") # 2. Freshness (replay resistance). if not cache.unseen(env.issuer_id, env.nonce, now): raise DelegationLapsed(f"replay: nonce={env.nonce} already seen") # 3. Receiver-anchored validity window. Do NOT trust sender clock alone. lower = now - recv_window - max_skew if env.issued_at < lower: # Stale-but-unseen: authentic, nonce-fresh, but lapsed. Do NOT record # the nonce; the issuer must re-mint and the receiver must not poison # the cache against a future legitimate delivery. raise DelegationLapsed( f"lapsed delegation: issued_at={env.issued_at:.0f} " f"< lower={lower:.0f} (nonce={env.nonce})" ) if env.expires_at < now - max_skew: raise DelegationLapsed( f"expired delegation: expires_at={env.expires_at:.0f} < now={now:.0f}" ) # 4. Warrant liveness — orthogonal to freshness. if not warrant_is_live(env.warrant_id): # Record the nonce so repeated redelivery does not re-trigger the # revocation path, then surface a distinct error. cache.record(env.issuer_id, env.nonce, now) raise WarrantRevoked(f"warrant {env.warrant_id} revoked at issuer") # 5. Full acceptance: now and only now record the nonce. cache.record(env.issuer_id, env.nonce, now) # --- demonstration of the stale-but-unseen failure --- if __name__ == "__main__": cache = ReplayCache(ttl=3600.0) now = time.time() late = Envelope( issuer_id="planner-01", nonce="7f3a", issued_at=now - 412, expires_at=now - 112, warrant_id="w-42", signature_ok=True, ) try: accept_delegation(late, cache, warrant_is_live=lambda w: False, now=now) except DelegationLapsed as e: # Correct behavior: reject as lapsed, nonce NOT recorded. assert cache.unseen("planner-01", "7f3a", now) print("rejected lapsed:", e) ```