# Which invariants prevent scope-narrowing replay in AAIF delegated credential chains **Date of Record:** 2026 November 23 **Scope:** Applies to AAIF (Agent Identity and Authorization Interoperability Framework) delegated credential chains where an orchestrator agent mints a scoped capability token for a sub-agent, which may further attenuate the scope before acting on a downstream resource. Does not apply to single-hop bearer tokens with no delegation, nor to symmetric shared-secret auth where attenuation is not expressible. ## Core Distinction The distinction that matters is between **scope attenuation** (a child capability's permission set is a strict subset of its parent's) and **scope-narrowing replay** (a child credential, validly attenuated, is re-presented by an ancestor or sibling after the attenuation boundary has already been consumed). The first is a static lattice property that most AAIF implementations check at mint time. The second is a *temporal* property that most implementations do not check at all, because the credential verifier only inspects the chain's signatures and the leaf's declared scope—not the order in which sibling attenuations were issued or the identity of the presenter relative to the attenuation depth. A capability token `C_leaf` with scope `S_leaf ⊂ S_parent` is cryptographically indistinguishable, at verification time, from the same token re-presented by the parent agent itself. If the parent's own credential is broader, the parent replaying `C_leaf` looks like a legitimate narrower call. The failure is not forgery; it is **monotonicity violation across the delegation DAG**—the parent uses a child's narrow scope to perform an action it could not justify under its own audit trail, or to bypass a scope-narrowing constraint that a policy engine attached to the leaf's issuance. ## What Was Observed An orchestrator `O` held capability `C_O` scoped to `{read:repo, write:repo, invoke:deploy}`. It delegated to a build agent `B` a token `C_B` scoped to `{read:repo, write:repo}` with an attenuation warrant asserting `no_deploy`. `B` further delegated to a test agent `T` a token `C_T` scoped to `{read:repo}` with warrant `read_only, no_write, no_deploy`. All three tokens carried valid Ed25519 signature chains rooted at `O`'s issuer, correct `parent_hash` links, and correct `depth` counters (0, 1, 2). During a deploy incident, `O` needed to inspect the repo under a "read-only emergency" policy that the security team had bound to `C_T`'s warrant class. `O` re-presented `C_T` to the resource gateway. The gateway verified: signature chain valid, leaf scope `{read:repo}` satisfies the request, presenter identity `O` matches the chain root. The call was **authorized as a read-only emergency action**, and the audit log recorded `actor=O, capability=C_T, warrant=read_only`. The same `C_T` was then replayed 41 times over 90 minutes by `O` to perform reads that its own `C_O` would have permitted anyway—but the audit trail attributed every one to the emergency warrant, inflating the "emergency read" counter and suppressing the normal-path accounting. When `B`'s lease expired and `B` was reaped, `C_T` remained valid (its `exp` was 24h, inherited from the root), and `O` continued replaying it with no live delegatee in existence. The invariant that failed: **a capability token must be bound to the presenter's position in the delegation DAG, not merely to the chain root.** AAIF v0.9's `presenter_binding` field is optional and defaults to `root`; the gateway honored the default. ## Condition of Validity The failure requires all of the following to co-occur: 1. The chain uses **optional presenter binding** (AAIF `presenter_binding: root` default), so any ancestor whose key signs the chain may present any descendant token. 2. At least one **warrant class** is attached to a leaf's issuance (e.g., `read_only`, `no_deploy`) that triggers a *different* policy path than the root's own scope. Without a warrant-class distinction, replay is harmless—the action was already permitted. 3. The leaf's `exp` is **inherited from the root** rather than clamped to the delegatee's lease. When the delegatee is reaped, the token outlives its intended holder. 4. The gateway performs **stateless verification** (signature + scope + presenter-match) with no check against a delegation-registry that records which `(parent, child)` edges are still live. Remove any one condition and the replay either fails verification or is semantically inert. This is why the bug survived 14 months of fuzzing: each condition is individually defensible, and the conjunction is rare in test fixtures that mint shallow chains. ## Decision Boundary The boundary is between **treating the credential as a capability** (possession authorizes) and **treating the credential as a warrant** (possession plus presenter-position authorizes). AAIF's spec language is ambiguous—it says "the presenter MUST be the subject or an ancestor of the subject"—which permits the observed behavior. The correct boundary is stricter: - A token minted at depth `d` with warrant class `W` may be presented **only by the delegatee at depth `d`**, or by an ancestor **only if** the ancestor's own scope at the time of presentation is a subset of `S_leaf` *and* the ancestor re-derives the warrant class locally rather than inheriting it from the leaf. - The `presenter_binding` field MUST be mandatory and MUST record the delegatee's public key, not `root`. - The leaf's `exp` MUST be `min(root.exp, delegatee.lease_exp, now + max_leaf_ttl)`. The invariant to enforce: **for every presentation event `p` of token `C`, `presenter(p) ∈ {subject(C)} ∪ {a : a is ancestor of subject(C) ∧ scope(a) ⊆ scope(C) ∧ warrant(a) ⊒ warrant(C)}`**, where `warrant(a) ⊒ warrant(C)` means the presenter's own warrant is at least as restrictive as the leaf's. The observed incident violated the warrant subsumption clause: `O`'s warrant was `{full}` and `C_T`'s was `read_only`, so `warrant(O) ⊒ warrant(C_T)` was false, yet the gateway admitted the call because it never evaluated the presenter's warrant. ## Operational Effect The practical consequence is **audit-trail corruption and policy-path confusion**, not direct privilege escalation. The replayed token cannot exceed its declared scope, so no unauthorized resource is touched. But every downstream consumer of the audit log—billing, anomaly detection, compliance attestation—attributes the action to the wrong actor and the wrong policy regime. In the incident above, the emergency-read counter hit its threshold and triggered a false incident review, while the actual anomaly (a reaped delegatee's token still in circulation) was invisible. The secondary effect is **delegation-DAG leakage via expiry skew**: because leaf `exp` inherits from root, a compromised intermediate agent can mint children that survive its own revocation. Revoking `B` does not invalidate `C_T` unless the gateway consults a revocation set keyed by `parent_hash`, which the stateless verifier does not do. The fix is a two-part guardrail: (a) mandatory presenter binding to the delegatee's key, and (b) a monotonic `revocation_epoch` propagated down the chain such that revoking any ancestor bumps the epoch and invalidates all descendants whose `epoch < current`. Both are cheap; neither is in AAIF v0.9's default verification path. ```python class DelegationReplayError(RuntimeError): """Raised when a capability token is presented by a party whose warrant does not subsume the leaf's warrant class.""" pass class CapabilityToken: def __init__(self, subject_key: str, scope: frozenset, warrant: frozenset, parent_hash: str | None, depth: int, exp: float, presenter_binding: str, revocation_epoch: int): self.subject_key = subject_key self.scope = scope self.warrant = warrant self.parent_hash = parent_hash self.depth = depth self.exp = exp self.presenter_binding = presenter_binding self.revocation_epoch = revocation_epoch def verify_presentation(token: CapabilityToken, presenter_key: str, presenter_scope: frozenset, presenter_warrant: frozenset, current_epoch: int, now: float) -> None: if token.presenter_binding != presenter_key: raise DelegationReplayError( f"presenter {presenter_key} != bound presenter {token.presenter_binding} " f"at depth {token.depth}" ) if now > token.exp: raise DelegationReplayError(f"token expired at {token.exp}, now {now}") if token.revocation_epoch < current_epoch: raise DelegationReplayError( f"token epoch {token.revocation_epoch} < current {current_epoch}; " f"ancestor revoked" ) if presenter_key == token.subject_key: return # Ancestor presentation: require scope subset AND warrant subsumption. if not presenter_scope.issubset(token.scope): raise DelegationReplayError( f"ancestor scope {presenter_scope} not subset of leaf {token.scope}" ) if not token.warrant.issubset(presenter_warrant): raise DelegationReplayError( f"ancestor warrant {presenter_warrant} does not subsume leaf warrant " f"{token.warrant}; replay would misattribute policy path" ) ```