# Which invariants prevent delegated AAIF credential scopes from silently widening across agent hops **Date of Record:** 2026 November 20 **Scope:** Applies to Agent Identity and Authorization Framework (AAIF) token chains where an orchestrator agent delegates a narrowed capability scope to a sub-agent, which may further delegate to tool-calling workers. Does not apply to single-hop direct authorization or to stateless bearer tokens without a delegation chain. ## Core Distinction The failure mode is not token forgery or signature bypass. It is **scope attenuation drift**: a delegated credential whose declared scope is a strict subset of the parent's scope, but whose *effective* scope at execution time is wider, because the receiving agent resolves an ambiguous capability identifier (a wildcard verb, a namespace glob, or a resource-pattern that matches more than the issuer intended) against its own local capability registry rather than against the issuer's. The critical distinction: **scope is a string until it is interpreted; interpretation is where attenuation is lost.** The issuer and the delegate do not share an interpretation function. AAIF guarantees the token's integrity, not the semantic equivalence of `read:orders/*` across two independently deployed capability resolvers. Attenuation is a property of the *intersection semantics*, and intersection semantics are only sound if both parties resolve identifiers through the same authoritative registry snapshot. ## What Was Observed An orchestrator held scope `orders:rw`, `customers:r`. It delegated to a research sub-agent a token claiming `orders:r` with resource pattern `orders/*`. The sub-agent's local resolver expanded `orders/*` using a permissive glob that matched `orders/admin/*` — a namespace the orchestrator never intended to expose, and which the parent token itself did not carry (the parent's `orders:rw` was scoped to `orders/tx/*` only). Two independent defects compounded: 1. **Glob expansion at the leaf, not the issuer.** The pattern `orders/*` was evaluated by the delegate against its own namespace tree, which included `admin` subtrees absent from the issuer's view. The issuer's mental model of `*` was "everything I can see"; the delegate's was "everything I can address." 2. **Verb subsumption.** `orders:r` was resolved by the delegate's policy engine as subsuming `orders:read`, `orders:list`, and `orders:export`. The issuer's registry defined `r` as subsuming only `read`. The token was byte-identical; the effective privilege differed by two operations. The trace: orchestrator issues token T with `scope=orders:r`, `resource=orders/*`, `parent_hash=H(orchestrator_token)`. Delegate receives T, validates signature and parent_hash chain — passes. Delegate calls `resolve_scope(T.scope, T.resource)` against its registry, which returns the set `{orders/admin/read, orders/admin/list, orders/admin/export, ...}`. Delegate executes `orders/admin/export`. No signature check, no parent_hash check, and no chain-length check fires, because each individual check is satisfied. The widening is invisible to every integrity primitive in AAIF. ## Condition of Validity Attenuation is sound **if and only if** the delegate's resolution function is a *subset-preserving* map of the issuer's resolution function over the same registry snapshot. Formally, for every token T with parent P: `resolve_delegate(T) ⊆ resolve_issuer(T) ⊆ resolve_issuer(P)` The second inclusion is guaranteed by the issuer signing T as a subset. The first inclusion is **not guaranteed by anything in the token** and fails whenever: - The two resolvers were built from different registry snapshots (registry skew). - The resolvers implement different glob/verb semantics (semantic skew). - The delegate augments its registry with locally-discovered capabilities (self-extension). The invariant that must hold: **the delegate must resolve against the issuer's registry digest, not its own.** AAIF tokens carry a `registry_digest` claim, but the spec treats it as advisory. If the delegate's live digest differs from the claim, attenuation is unverifiable and the token must be rejected — not re-resolved locally. ## Decision Boundary The boundary is between **rejecting on digest mismatch** and **resolving locally on digest mismatch**. The tempting engineering choice is to resolve locally "for resilience" — the delegate stays functional if the issuer's registry is unavailable. This is precisely the choice that converts a scope-attenuation guarantee into a best-effort suggestion. Adopt the hard boundary: - If `T.registry_digest != local_registry.digest(T.resource_namespace)`: **fail closed.** Do not resolve. Do not fall back to a permissive glob. Do not substitute a default registry. - If the delegate cannot obtain the issuer's registry snapshot, it may proceed **only** by treating the scope as a literal string with no expansion — i.e., exact-match resource identifiers only, and a verb whitelist that is the intersection of both parties' documented verb sets, not the union. - Chain depth is a separate bound: attenuation must be re-verified at every hop, and a hop that cannot verify must terminate the chain rather than pass a narrowed-looking token onward. ## Operational Effect Enforcing the registry-digest invariant converts a silent privilege-widening class of bugs into a loud, early, and localized failure at the delegation boundary. The cost is availability: a delegate whose registry is stale relative to the issuer cannot execute delegated work until reconciled. The benefit is that scope attenuation becomes a *checkable* property rather than a *hoped-for* one — the delegate can prove `resolve_delegate(T) ⊆ resolve_issuer(T)` by construction, because both sides resolve against the same bytes. Without the invariant, the failure is not merely possible but *undetectable from the token*: every integrity check passes, the audit log shows a valid chain, and the only evidence of widening is a downstream action whose resource identifier the issuer never enumerated. The invariant is the difference between a delegation framework and a delegation *suggestion*. ```python from dataclasses import dataclass from typing import FrozenSet class ScopeAttenuationError(RuntimeError): """Raised when a delegated token's effective scope cannot be proven to be a subset of its parent's scope under a shared registry snapshot.""" @dataclass(frozen=True) class RegistrySnapshot: digest: str # namespace -> set of fully-qualified capability identifiers capabilities: dict @dataclass(frozen=True) class DelegatedToken: scope_verb: str resource_pattern: str parent_scope: FrozenSet[str] registry_digest: str def resolve(snapshot: RegistrySnapshot, verb: str, pattern: str) -> FrozenSet[str]: """Resolve a (verb, pattern) pair against a registry snapshot. Deliberately conservative: exact-prefix match only, no implicit verb subsumption.""" prefix = pattern.rstrip("*").rstrip("/") out = set() for ns, caps in snapshot.capabilities.items(): for cap in caps: if cap.startswith(prefix + "/") or cap == prefix: if cap.split("/")[-1] == verb: out.add(cap) return frozenset(out) def verify_attenuation( token: DelegatedToken, issuer_snapshot: RegistrySnapshot, delegate_snapshot: RegistrySnapshot, ) -> FrozenSet[str]: """Prove delegate-resolved scope is a subset of issuer-resolved scope, and that both resolve against the same registry bytes.""" if token.registry_digest != issuer_snapshot.digest: raise ScopeAttenuationError( f"token registry_digest {token.registry_digest!r} does not match " f"issuer snapshot {issuer_snapshot.digest!r}; attenuation unprovable" ) if delegate_snapshot.digest != issuer_snapshot.digest: raise ScopeAttenuationError( f"delegate registry {delegate_snapshot.digest!r} skewed from issuer " f"{issuer_snapshot.digest!r}; refusing local re-resolution" ) issuer_effective = resolve(issuer_snapshot, token.scope_verb, token.resource_pattern) delegate_effective = resolve(delegate_snapshot, token.scope_verb, token.resource_pattern) if not delegate_effective <= issuer_effective: widened = delegate_effective - issuer_effective raise ScopeAttenuationError( f"scope widened at delegate: {sorted(widened)} not in issuer resolution" ) if not issuer_effective <= token.parent_scope: escaped = issuer_effective - token.parent_scope raise ScopeAttenuationError( f"issuer resolution escapes parent scope: {sorted(escaped)}" ) return delegate_effective ```