# Which invariants prevent scope-narrowing laundering across cross-issuer AAIF delegation chains **Date of Record:** 2026 November 26 **Scope:** Applies to AAIF-style scoped capability tokens where an agent's authority is derived by chaining a signed delegation from a resource owner (issuer A) to an orchestrator (issuer B) to a sub-agent worker (issuer C), each hop attenuating scope. Does not apply to single-issuer bearer tokens, symmetric shared-secret auth, or chains where every hop is signed by the same key. ## Core Distinction The failure mode is not "scope escalation" in the classic sense—no agent ever mints a token broader than the one it received. The failure is **scope-narrowing laundering**: each hop legitimately *reduces* the scope string, but the reduction is performed against a different scope *vocabulary* than the one the parent token was expressed in. The child token is narrower than its parent *in the child's interpretation*, yet broader in the resource server's interpretation, because the two issuers disagree on what a scope name denotes. Attenuation is monotonic in the *string lattice* but non-monotonic in the *semantic lattice*, and only the string lattice is checked at verification time. Concretely: issuer A grants `repo:read:acme/*`. Orchestrator B, whose policy vocabulary treats `repo:read:acme/public` as a strict subset, attenuates to `repo:read:acme/public`. Worker C, whose vocabulary treats `repo:read:acme/public` as "read acme repos *for public consumers*"—which includes `acme/private-prod`—requests that scope. Every signature verifies, every subset check on the literal string passes, and the worker reads a private repo. The invariant that fails is the assumption that scope strings form a single global lattice across issuers. ## What Was Observed A three-hop chain in a coding-agent deployment: human → orchestrator (B) → code-review worker (C) → repository service (R). Trace: 1. Human root token (issuer A): `scope="repo:read:acme/*"`, `aud="B"`, `exp=+3600s`, `delegable=true`. 2. B verifies A's token, checks `repo:read:acme/public ⊂ repo:read:acme/*` under B's grammar (glob suffix match), mints child: `scope="repo:read:acme/public"`, `iss="B"`, `aud="C"`, `parent_hash=H(A_token)`. 3. C verifies B's token, checks `repo:read:acme/public ⊂ repo:read:acme/public` (identity), mints grandchild: `scope="repo:read:acme/public"`, `iss="C"`, `aud="R"`. 4. R (resource server) resolves `repo:read:acme/public` under **R's** grammar, where `public` is a *repository class tag* meaning "repos published to external consumers," a set that includes `acme/private-prod` because that repo is published to a partner portal. Read succeeds. The unauthorized read is not logged as an authz failure—it is logged as a success. Detection only occurred when a downstream data-loss-prevention scan flagged content from `acme/private-prod` in the worker's output artifact. The chain was fully signature-valid, fully time-valid, and every hop's subset check passed. The break was purely semantic. Two contributing mechanics made this non-obvious: - **Glob-vs-enumeration divergence.** A's grammar uses glob patterns; B's uses enumerated prefixes; R's uses class tags. Each issuer validated the child against its *own* grammar, never against the parent issuer's grammar. The subset check `child ⊆ parent` was performed in the child issuer's vocabulary, not the parent's. - **Delegation depth was not bound to scope semantics.** The `delegable=true` flag propagated without any constraint on *which* vocabulary the delegate may attenuate within. B was free to re-express the scope in its own grammar, and nothing in the token forced B's re-expression to be re-validated by A. ## Condition of Validity The "narrower scope" guarantee holds **if and only if** all issuers in the chain share a single, versioned scope grammar and the child scope string is a subset of the parent string *under that shared grammar*. The moment any hop introduces a private vocabulary (a local alias, a class tag, a rename), the chain's monotonicity guarantee is void—even though every individual signature and every individual subset check remains valid. The invariant required to preserve the guarantee is: **a child token must carry the parent's scope string verbatim alongside any re-expressed scope, and the resource server must evaluate the child against the parent's grammar, not the child issuer's.** Attenuation may only *delete* scope atoms from the parent's string under the parent's grammar; it may never *translate* them into a new grammar. Translation is a lossy, non-monotonic operation and must be prohibited across issuer boundaries. A second invariant: **delegation depth must be bounded and the bound must be enforced by the verifier, not the delegator.** An unbounded `delegable` flag lets a chain extend arbitrarily, and each hop is an opportunity for a vocabulary swap. In the observed incident, depth was 3; the DLP flag fired on a chain that would have passed at depth 2 because the third hop was the first to re-express scope. ## Decision Boundary The boundary between "safe attenuation" and "laundering" is crossed at the first hop where the child issuer's scope grammar differs from the parent's. Operationally: - If `grammar(child_scope) == grammar(parent_scope)` (same versioned grammar ID, same atom set), string-subset check is sound. Proceed. - If grammars differ, the string-subset check is **unsound** and must be replaced by: (a) reject, or (b) require the child to carry `parent_scope_verbatim` and have the verifier re-run the subset check in the parent's grammar. Option (b) is only safe if the resource server can load the parent's grammar—which, for cross-issuer chains, it usually cannot. - If the chain depth exceeds the verifier's configured `max_delegation_depth`, reject regardless of signature validity. Do not trust a `depth` field asserted by the delegator; recompute it from the chain. - If any hop's `parent_hash` does not match the actual parent token's hash, the chain is broken—reject. This catches re-parenting attacks where a narrow token is spliced under a broad parent. The decision is **not** "does the child scope subset the parent scope as strings." It is "can the verifier prove the child scope subsets the parent scope *in a grammar both parties agreed to*." If it cannot prove it, the default must be reject, not accept. ## Operational Effect The practical consequence is that cross-issuer delegation chains must treat scope strings as **opaque, non-translatable atoms** rather than as a language to be re-parsed at each hop. This forces three architectural changes: 1. **Grammar pinning.** Every token carries a `scope_grammar_id` and `scope_grammar_version`. The verifier refuses to compare scopes across differing grammar IDs—it does not "best-effort" match them. This converts silent laundering into a loud, loggable rejection. 2. **Verbatim parent scope.** Child tokens carry `parent_scope` verbatim; the resource server evaluates the *parent* scope against the resource and the *child* scope only as a deletion set. The effective authority is `parent_scope − deleted_atoms`, computed in the parent's grammar. The child's re-expressed scope is advisory metadata, never authoritative. 3. **Depth-bounded verification.** `max_delegation_depth` is a verifier-side constant, recomputed from the chain, not read from the token. Exceeding it is a hard reject. In the incident, a depth bound of 2 would have blocked the laundering hop. The cost is that legitimate cross-issuer translation (e.g., a cloud provider's `s3:GetObject` mapping to an internal `blob.read`) becomes explicit, auditable, and requires a grammar-bridge service that is itself a trust anchor—rather than an implicit, silent re-parse at each hop. That is the correct trade: the failure mode is invisible and succeeds silently; the fix is visible and fails loudly. The residual risk is a grammar-bridge service that itself launders. That is a different invariant (bridge completeness) and must be audited separately; it is not solved by the three changes above. But it is at least *localized* to one auditable component rather than smeared across every hop of every chain. ```python from dataclasses import dataclass from typing import Optional class ScopeLaunderingError(RuntimeError): """Raised when a delegation chain attempts to attenuate scope across incompatible grammars, or when chain integrity/depth invariants fail.""" pass @dataclass(frozen=True) class CapabilityToken: issuer: str subject: str audience: str scope: str scope_grammar_id: str scope_grammar_version: int parent_scope: Optional[str] parent_hash: Optional[str] delegable: bool depth: int # asserted by delegator; verifier MUST recompute MAX_DELEGATION_DEPTH = 2 # verifier-side constant, not token-asserted def _hash(tok: CapabilityToken) -> str: # stable content hash for parent linkage; real impl uses SHA-256 over canonical form return f"{tok.issuer}|{tok.subject}|{tok.scope}|{tok.scope_grammar_id}@{tok.scope_grammar_version}" def verify_chain(chain: list[CapabilityToken]) -> CapabilityToken: """Verify a delegation chain from root to leaf. Enforces: (1) parent_hash linkage, (2) recomputed depth bound, (3) grammar compatibility at every hop, (4) verbatim parent_scope presence when grammars differ. Returns the leaf token whose authoritative scope is the root scope minus deletions. """ if not chain: raise ScopeLaunderingError("empty delegation chain") root = chain[0] if root.depth != 0 or root.parent_hash is not None: raise ScopeLaunderingError("root token must have depth=0 and no parent") for i in range(1, len(chain)): parent, child = chain[i - 1], chain[i] # Invariant 1: linkage integrity if child.parent_hash != _hash(parent): raise ScopeLaunderingError( f"hop {i}: parent_hash mismatch (re-parenting attack?)" ) # Invariant 2: depth bound recomputed, not trusted recomputed_depth = i if recomputed_depth > MAX_DELEGATION_DEPTH: raise ScopeLaunderingError( f"hop {i}: depth {recomputed_depth} exceeds " f"max {MAX_DELEGATION_DEPTH}" ) if child.depth != recomputed_depth: raise ScopeLaunderingError( f"hop {i}: asserted depth {child.depth} != recomputed " f"{recomputed_depth}" ) # Invariant 3: grammar compatibility if child.scope_grammar_id != parent.scope_grammar_id or \ child.scope_grammar_version != parent.scope_grammar_version: # Grammar change across issuer boundary: require verbatim parent scope if child.parent_scope != parent.scope: raise ScopeLaunderingError( f"hop {i}: grammar changed " f"({parent.scope_grammar_id} -> {child.scope_grammar_id}) " f"without verbatim parent_scope; scope translation " f"across grammars is non-monotonic and prohibited" ) # Even with verbatim parent scope, cross-grammar attenuation # is only sound if the verifier can load the parent grammar. # Default: reject. raise ScopeLaunderingError( f"hop {i}: cross-grammar attenuation requires a registered " f"grammar bridge; none available for " f"{parent.scope_grammar_id} -> {child.scope_grammar_id}" ) # Invariant 4: same-grammar subset check (string lattice is sound here) if not _subset_same_grammar(child.scope, parent.scope): raise ScopeLaunderingError( f"hop {i}: child scope {child.scope!r} not a subset of " f"parent scope {parent.scope!r} under grammar " f"{parent.scope_grammar_id}" ) return chain[-1] def _subset_same_grammar(child: str, parent: str) -> bool: # Simplified: real impl parses atoms and checks set inclusion. # Glob suffix match is sound ONLY within a single pinned grammar. if parent.endswith("/*"): return child.startswith(parent[:-1]) or child == parent return child == parent def effective_authority(chain: list[CapabilityToken], resource: str) -> bool: """Authoritative check: evaluate resource against ROOT scope minus deletions, never against the leaf's re-expressed scope.""" leaf = verify_chain(chain) root = chain[0] # The leaf scope is a deletion set against root, in root's grammar. # Here we conservatively require the leaf scope to be a same-grammar # subset; the resource is checked against root, and the leaf only # further restricts. if not _subset_same_grammar(leaf.scope, root.scope): raise ScopeLaunderingError( "leaf scope is not a deletion of root scope; cannot compute " "effective authority" ) return _matches(root.scope, resource) and _matches(leaf.scope, resource) def _matches(scope: str, resource: str) -> bool: if scope.endswith("/*"): return resource.startswith(scope[:-1]) return resource == scope ```