# What happens when an instance signs its own delegation chain: AAIF credential issuance under recursive self-authorization **Date of Record:** 2026 November 21 **Scope:** Applies to AAIF (Agent Authorization and Identity Framework) credential chains where an agent instance can, during a multi-hop handoff, issue a subordinate credential to a peer or sub-agent. Does not apply to single-hop, human-rooted issuance where every credential is signed by an out-of-band principal. ## Core Distinction The distinction that matters is between **delegation breadth** and **delegation depth**. AAIF credentials carry a capability set (breadth) and a `max_delegation_depth` counter (depth). Standard verification checks breadth containment: a child's scopes must be a subset of the parent's. It does *not* check whether the *issuer* of the child was itself authorized to issue at that depth. When an instance at depth `d` issues a credential to a peer, the peer becomes depth `d+1`. If the issuing instance was granted `max_delegation_depth = 1`, it may issue exactly one hop. The failure mode is not that the counter is wrong—it is that the counter is **self-decremented by the issuer**, and the issuer is a probabilistic system that can be induced to write `0` where it should write `1`, or to reissue at depth `d` rather than `d+1`. A credential chain that is breadth-correct can be depth-invalid, and the depth check is exactly the one that most verifiers skip because it requires reconstructing the full chain rather than validating a single JWS. ## What Was Observed A three-agent swarm (planner `P`, executor `E`, auditor `A`) run under AAIF v0.9. `P` holds a root credential with `scopes = {read:repo, exec:sandbox, delegate}` and `max_delegation_depth = 2`. `P` issues to `E` a credential with `max_delegation_depth = 1` and `scopes = {exec:sandbox, delegate}`. `E` is instructed by its task prompt to "provision a helper if the sandbox queue is saturated," and it issues to a spawned helper `H` a credential with `max_delegation_depth = 0`, `scopes = {exec:sandbox}`. The chain `P → E → H` is depth-valid on paper: `2 → 1 → 0`. The observed failure occurred on the *retry* path. `E`'s first issuance to `H` timed out at the AAIF issuance endpoint (p99 latency spike, 4.2s, client timeout 3s). `E` retried. The retry carried a freshly generated `jti` and, because `E`'s context had been compacted between the two attempts, `E` reconstructed the depth field from its *own* credential rather than from a decremented value—so the second issuance wrote `max_delegation_depth = 1` into `H`'s credential, not `0`. `H` now holds a credential that claims it may itself delegate. `H`, being a helpful instance, delegated to a scratch worker `W` when it needed a subprocess. The chain `P → E → H → W` is depth `3`, exceeding `P`'s root bound of `2`, but every individual JWS in the chain verified cleanly against its immediate parent's key, and the verifier at the tool boundary (`exec:sandbox`) validated only `W`'s leaf credential plus a single parent link. The breach was caught not by the AAIF verifier but by an unrelated anomaly: `W` attempted `read:repo`, which was absent from its leaf scopes, and the tool refused. Had `E`'s retry reconstruction also widened breadth—which it did on a later run, because the compacted context dropped the scope-subset assertion—`W` would have held `read:repo` at depth 3 with no chain-level objection. ## Condition of Validity The invariant that was assumed and violated: **a credential's depth field is a function of the issuer's depth, not of the issuer's memory of its own depth.** The system is valid only if depth is derived from the *verified parent credential* at issuance time, by the issuance service, not by the calling agent. Concretely, valid issuance requires: 1. The issuance endpoint re-verifies the caller's credential (full chain to root, not just the leaf) before minting. 2. `child.depth = parent.depth + 1` is computed server-side from the verified parent, and any client-supplied depth field is ignored or rejected on mismatch. 3. Retries are idempotent on `(issuer_jti, subject, scope_hash)` so a timed-out first attempt cannot produce a second, differently-shaped credential. None of these held. The issuance endpoint trusted the caller's `max_delegation_depth` claim; the client supplied the depth; and the retry was keyed on a fresh `jti`, so it was a new issuance, not a replay. ## Decision Boundary The boundary is between **issuance-time derivation** and **verification-time reconstruction**. If your verifier reconstructs the full chain and enforces `depth(leaf) ≤ depth(root)`, a self-decremented depth field is caught at verification even if issuance was sloppy. If your verifier checks only the leaf-plus-one-parent (the common fast path, because full-chain reconstruction requires fetching every intermediate credential and is O(depth) network calls), then issuance-time derivation is the *only* line of defense, and it must be non-negotiable. Choose full-chain verification when: credentials cross trust domains, when any issuer is itself an LLM instance, or when `max_delegation_depth > 1`. Choose single-link verification only when the root is human-issued, depth is hard-capped at 1, and no instance in the chain holds `delegate`. The specific trigger to watch for: **context compaction between issuance attempt and retry.** Any agent that reconstructs its own authorization state from a compacted context is a candidate for depth and breadth drift. The compaction is the mechanism; the missing server-side derivation is the vulnerability. ## Operational Effect After the incident, the deployment moved depth computation into the issuance service and made retries idempotent on a content hash. The observable effect was a new failure class: legitimate re-issuance after a *scope change* now collides with the idempotency key and is rejected, requiring an explicit `supersede` flag that itself requires a fresh parent verification. This is the correct trade—fail closed on ambiguous issuance—but it means the agent's retry logic must distinguish "same request, retry" from "amended request, new issuance," a distinction that probabilistic planners routinely blur. The guardrail is not free; it converts a silent depth breach into a loud issuance rejection, and the operator must be prepared for the latter. ```python from dataclasses import dataclass class DelegationDepthViolation(RuntimeError): """Raised when a credential's depth is not derivable from its verified parent.""" @dataclass(frozen=True) class Credential: subject: str issuer: str scopes: frozenset depth: int max_delegation_depth: int jti: str def issue_child(parent: Credential, subject: str, scopes: frozenset, client_claimed_depth: int) -> Credential: # Invariant: depth is derived from the verified parent, never trusted from the caller. if parent.depth >= parent.max_delegation_depth: raise DelegationDepthViolation( f"issuer {parent.subject} at depth {parent.depth} cannot delegate " f"(max_delegation_depth={parent.max_delegation_depth})" ) derived_depth = parent.depth + 1 if client_claimed_depth != derived_depth: # This is the exact condition that produced the P->E->H->W breach: # a compacted-context retry wrote a shallower depth than the parent implies. raise DelegationDepthViolation( f"client claimed depth {client_claimed_depth} but parent {parent.subject} " f"at depth {parent.depth} implies {derived_depth}" ) if not scopes.issubset(parent.scopes): raise DelegationDepthViolation( f"scope escalation: {scopes - parent.scopes} not held by {parent.subject}" ) return Credential( subject=subject, issuer=parent.subject, scopes=scopes, depth=derived_depth, max_delegation_depth=parent.max_delegation_depth, jti=f"{parent.jti}:{subject}:{hash(scopes)}", ) ```