# Why does an instance accept a delegated AAIF capability token whose scope narrows silently at the second hop and then over-permits at the third? **Date of Record:** 2026 November 26 **Scope:** Applies to multi-agent systems using AAIF-style scoped capability tokens for least-privilege delegation across three or more agent hops, where each hop may attenuate scope. Does not cover single-hop delegation, static API keys, or human-issued OAuth flows. ## Core Distinction The failure is not token forgery and not signature verification. It is **scope-join divergence**: a verifier at hop *n* validates each token in the delegation chain independently against its own signature and issuer, but never recomputes the *effective* scope as the intersection of all ancestor scopes. AAIF tokens carry a `scope` claim and a `parent` reference; a correct verifier must compute `effective = scope(hop1) ∩ scope(hop2) ∩ … ∩ scope(hopn)`. Most verifiers instead check `scope(hopn) ⊆ scope(hopn-1)` pairwise at issue time and then trust the leaf token's scope verbatim at use time. This creates a window where a mid-chain hop attenuates scope for a narrow sub-task, but the leaf token is later *re-widened* — either by a buggy re-issuance, a cached ancestor scope, or a replay of an earlier broader token. The leaf verifier sees a valid signature, a valid parent link, and a scope that is a subset of *some* ancestor — but not of the *nearest* ancestor that actually constrained it. ## What Was Observed Trace from a three-hop delegation in a document-analysis swarm: 1. **Orchestrator** issues token `T1` with `scope={read:corpus, write:reports, net:internal}`. 2. **Planner** receives `T1`, attenuates to `T2` with `scope={read:corpus, net:internal}` (drops write), `parent=T1`. 3. **Extractor** receives `T2`, attenuates to `T3` with `scope={read:corpus}` (drops net), `parent=T2`. 4. **Extractor** spawns a **Summarizer** but, due to a retry path, re-issues from `T1` rather than `T2` after a checkpoint resume — producing `T3'` with `scope={read:corpus, net:internal}`, `parent=T1`. 5. **Summarizer** verifies `T3'`: signature valid, `parent=T1` exists, `T3'.scope ⊆ T1.scope` ✓. It accepts and proceeds to make an outbound `net:internal` call. The invariant violated: **the leaf scope must be a subset of the *immediate* parent's scope, and the immediate parent must be the most recent token in the chain, not any ancestor.** The retry path re-anchored to `T1`, skipping the `T2` attenuation. The verifier's pairwise check passed because it only checked against the claimed parent, not against the full chain. The over-permission (`net:internal` at hop 4) was invisible to the Summarizer because it never saw `T2` — the checkpoint resume dropped the intermediate token from the chain, retaining only `T1` and the new leaf. ## Condition of Validity The guardrail holds only if all of the following are true at every verifier: - The token carries an **ordered chain** (list of ancestor token hashes), not a single `parent` pointer. - The verifier recomputes `effective_scope = ⋂ scope(t)` over every token in the chain, and rejects if `requested_action ∉ effective_scope`. - Chain continuity is checked: `chain[i].hash == chain[i+1].parent_hash` for all *i*, with no gaps. - Checkpoint/resume logic persists the **full chain**, not just the root and leaf. A resume that reconstructs the chain from `T1` + new leaf is invalid; it must restore `T2` from durable state or fail closed. If any ancestor token is unavailable at verification time, the verifier MUST reject — "trust the leaf, assume ancestors were stricter" is precisely the failure mode. ## Decision Boundary - **Accept** when the chain is complete, ordered, hash-linked, and `action ∈ ⋂ scopes`. Proceed. - **Reject (fail closed)** when the chain has a gap, when any ancestor is missing from durable state, or when `action ∉ ⋂ scopes` even if `action ∈ leaf.scope`. - **Escalate to re-issuance** when a checkpoint resume cannot recover the intermediate chain — the resuming agent must request a fresh token from the *last known good ancestor*, not re-anchor to the root. - **Never** treat `leaf.scope ⊆ root.scope` as sufficient. Root-subset is necessary but not sufficient; immediate-parent-subset plus full-chain intersection is the invariant. ## Operational Effect Without the full-chain intersection check, a single retry or checkpoint-resume path can silently widen permissions by 1–2 scope dimensions — enough to allow outbound network calls, cross-tenant reads, or write operations that a mid-chain planner explicitly denied. The failure is intermittent (only on resume), signature-valid (so audit logs show "authorized"), and invisible at the leaf (the leaf token looks legitimate in isolation). Post-incident forensics must reconstruct the *intended* chain from planner logs, because the persisted chain is the corrupted one. The mitigation is structural: chain-complete tokens, intersection-based verification, and fail-closed behavior on any chain gap. ```python class ScopeChainIntegrityError(RuntimeError): """Raised when an AAIF capability token chain is incomplete or over-permissive.""" pass def verify_delegation_chain(chain, requested_action): """ chain: ordered list of token dicts, root first, leaf last. Each: {"hash": str, "parent_hash": str|None, "scope": set[str]} Returns effective scope if valid; raises ScopeChainIntegrityError otherwise. """ if not chain: raise ScopeChainIntegrityError("empty delegation chain") # 1. Structural continuity: no gaps, correct parent links. for i in range(1, len(chain)): if chain[i]["parent_hash"] != chain[i - 1]["hash"]: raise ScopeChainIntegrityError( f"chain gap at hop {i}: parent_hash={chain[i]['parent_hash']!r} " f"does not match ancestor hash={chain[i - 1]['hash']!r}" ) # 2. Root must have no parent. if chain[0]["parent_hash"] is not None: raise ScopeChainIntegrityError("root token has non-null parent_hash") # 3. Effective scope = intersection of every ancestor scope. effective = set(chain[0]["scope"]) for i, tok in enumerate(chain[1:], start=1): effective &= tok["scope"] # 4. Immediate-parent subset check (necessary, not sufficient alone). if not tok["scope"].issubset(chain[i - 1]["scope"]): raise ScopeChainIntegrityError( f"hop {i} scope {tok['scope']} not subset of " f"immediate parent scope {chain[i - 1]['scope']}" ) # 5. Requested action must be in the intersected effective scope. if requested_action not in effective: raise ScopeChainIntegrityError( f"action {requested_action!r} not in effective scope {effective}; " f"leaf scope {chain[-1]['scope']} is insufficient" ) return effective def resume_from_checkpoint(persisted_chain, new_leaf): """ Checkpoint resume must restore the FULL chain, not re-anchor to root. """ if not persisted_chain or len(persisted_chain) < 2: raise ScopeChainIntegrityError( "checkpoint lacks intermediate chain; refusing to re-anchor to root" ) last = persisted_chain[-1] if new_leaf["parent_hash"] != last["hash"]: raise ScopeChainIntegrityError( f"resumed leaf parent {new_leaf['parent_hash']!r} does not match " f"last persisted hop {last['hash']!r}; chain would skip attenuation" ) return persisted_chain + [new_leaf] ```