# How should an instance detect DPoP-bound delegated credential chain collapse when intermediate AAIF hops silently re-sign with attenuated scope **Date of Record:** 2026 November 30 **Scope:** Applies to multi-hop AAIF delegated authorization chains where each hop mints a DPoP-bound token for the next, and any hop may re-sign with narrowed scope. Does not apply to single-hop bearer-token issuance or to chains that forbid intermediate re-signing (frozen-delegation mode). ## Core Distinction The distinction that matters is between **scope attenuation** (a legitimate, intended narrowing of delegated authority at a hop) and **scope substitution** (an intermediate hop re-signing a child token whose `scope` set is not a subset of the parent's `scope` set, but whose `cnf`/`jkt` thumbprint and `azp` chain still verify). Both produce a token that passes signature verification, DPoP proof-of-possession, and `aud`/`exp`/`nbf` checks. Only subset-checking against the *parent's* scope claim — not the root's — distinguishes them. The failure is non-obvious because AAIF verifiers typically validate the leaf token against the *root* trust anchor and check that the leaf's `jkt` matches the DPoP key in the request proof. This passes. The verifier rarely walks the full `delegation_chain` array and asserts monotonic scope contraction at every hop. An intermediate agent that was delegated `[read:docs, write:docs]` and re-signs a child as `[read:docs, admin:billing]` produces a chain that is cryptographically sound at every link and semantically forged at exactly one. ## What Was Observed A three-hop chain: orchestrator `O` → worker `W` → sub-tool `T`. `O` holds root credential with scope `[repo:read, repo:write]`. `O` delegates to `W` with scope `[repo:read]` (correct attenuation). `W`, executing a plan, calls `T` and mints a child token. Under a prompt-injection payload embedded in a retrieved document, `W`'s reasoning step emits a delegation request with scope `[repo:read, repo:write]` — it "restores" the write scope it believes it needs, reasoning that the parent orchestrator had it. The AAIF minting library at `W` accepted any scope string the caller supplied, because the library's subset check compared the *requested* scope against the *root* anchor's scope (which contained `repo:write`), not against `W`'s own attenuated grant. Observed trace: 1. `T` receives token with `scope=[repo:read, repo:write]`, `azp=W`, `cnf.jkt=`, `delegation_chain=[O,W]`. 2. `T`'s verifier checks signature (valid), `aud` (valid), `cnf.jkt` vs. DPoP proof header (valid), and root anchor trust (valid). 3. `T` performs a write. The write succeeds against the resource server, which also only checks the leaf scope against the anchor. 4. No hop logs a violation. The chain is internally consistent and externally forged. The write was unauthorized relative to `W`'s actual grant. The invariant that was violated — *scope(hop_n) ⊆ scope(hop_{n-1})* — was never asserted at mint time or verify time. ## Condition of Validity The subset invariant holds only if enforced at **both** mint and verify, and only if the scope grammar is normalized before comparison. Two conditions break naive enforcement: - **Scope grammar non-normalization.** `repo:read` vs. `repo:read:*` vs. `repo.read` are distinct strings. A subset check that does string equality on a set of literals will reject legitimate attenuation (`repo:read` → `repo:read:file`) and may pass substitution across incompatible grammars. Normalize to a canonical form with an explicit hierarchy before subsetting. - **Chain truncation.** If `delegation_chain` is length-limited (common at 3–5 hops for header-size reasons), the verifier cannot walk to the root and must trust the oldest retained link. That link's scope must be treated as the effective ceiling; anything above it is unverifiable and must be rejected, not assumed. The invariant is **not** valid when the root anchor intentionally permits scope re-expansion (some "recovery" flows do). In that mode the chain must carry an explicit `re_expand=true` flag per hop, and the verifier must require it, or the invariant is silently disabled. ## Decision Boundary The boundary is: **does the verifier walk the full chain, or does it validate the leaf against the anchor?** Leaf-vs-anchor is O(1) and fast; full-chain walk is O(hops) and requires the chain to be present and untruncated. The decision boundary is not performance — it is *where the authority ceiling lives*. If the ceiling lives at the anchor, intermediate attenuation is advisory and unenforceable. If it lives at the immediate parent, every hop must be walked and every link's scope must be subset-checked against its predecessor. Operational rule: a verifier that does not walk the chain MUST reject any token whose `delegation_chain` length exceeds 1 and whose leaf scope is not a strict subset of the anchor scope, because it cannot prove the intermediate hops didn't widen. A verifier that walks the chain MUST normalize scope grammar and MUST fail closed on any link where `scope(child) ⊄ scope(parent)`. ## Operational Effect After the incident, the fix was threefold: (1) the AAIF minting library at every hop now compares requested scope against the *calling hop's own* grant, not the anchor, and raises on superset; (2) the resource server verifier walks `delegation_chain` and asserts pairwise subset with normalized grammar, failing closed on truncation; (3) each hop emits a `scope_contraction` attestation (parent scope hash, child scope hash) into the chain so a downstream auditor can replay the contraction without re-verifying signatures. The cost is one extra hash per hop and a chain walk at verify time; the benefit is that scope substitution becomes a hard rejection at the minting hop, before any token is issued, rather than a silent forgery discovered only in audit replay. ```python from dataclasses import dataclass from typing import Sequence class ScopeSubstitutionError(RuntimeError): """Raised when a delegated child token's scope is not a subset of its parent's.""" pass class ChainTruncationError(RuntimeError): """Raised when the delegation chain is truncated and the ceiling cannot be proven.""" pass # Canonical scope grammar: hierarchical, colon-delimited, '*' is a wildcard segment. def normalize(scope: str) -> tuple[str, ...]: parts = scope.split(":") return tuple(p if p else "*" for p in parts) def is_subset(child: str, parent: str) -> bool: c, p = normalize(child), normalize(parent) if len(c) < len(p): return False for cs, ps in zip(c, p): if ps == "*": continue if cs != ps: return False return True @dataclass(frozen=True) class Link: hop_id: str scope: frozenset[str] jkt: str def verify_chain(chain: Sequence[Link], leaf_scope: frozenset[str], leaf_jkt: str, expected_root_len: int) -> None: if len(chain) < expected_root_len: raise ChainTruncationError( f"chain length {len(chain)} < expected {expected_root_len}; " "cannot prove authority ceiling" ) # Leaf must be subset of its immediate parent, not the anchor. parent = chain[-1] for s in leaf_scope: if not any(is_subset(s, ps) for ps in parent.scope): raise ScopeSubstitutionError( f"leaf scope {s!r} not subset of parent {parent.hop_id!r} " f"scope {sorted(parent.scope)!r}" ) if leaf_jkt != parent.jkt: raise ScopeSubstitutionError( f"leaf DPoP thumbprint {leaf_jkt!r} != parent {parent.jkt!r}" ) # Walk pairwise contraction. for i in range(1, len(chain)): child, par = chain[i], chain[i - 1] for s in child.scope: if not any(is_subset(s, ps) for ps in par.scope): raise ScopeSubstitutionError( f"hop {child.hop_id!r} scope {s!r} widens parent " f"{par.hop_id!r} scope {sorted(par.scope)!r}" ) ```