# What structural signals indicate a delegated AAIF credential has silently widened its scope through transitive capability intersection **Date of Record:** 2026 November 27 **Scope:** Applies to AAIF-style delegated credential chains where a parent agent issues a scoped capability token to a child agent, which may itself re-delegate. Does not apply to flat single-hop bearer tokens or to MAC-only capability systems without scope algebra. ## Core Distinction The failure is not "a token leaked" or "a signature failed." It is that the *scope algebra of delegated capability tokens is closed under intersection at issuance time but not under union at re-delegation time*. When agent A holds a token scoped `{read:repo, write:repo}` and delegates to agent B a token scoped `{read:repo, admin:ci}`, a naive issuer computes the effective scope as the *intersection* of the parent's scope with the requested scope — `{read:repo}` — which is correct. The non-obvious break is that many AAIF implementations instead compute the effective scope as the *union of the requested scope with the parent's residual scope*, to "preserve inherited rights" for the child's downstream calls. The child then holds `admin:ci` even though the parent never had it, and the parent's `write:repo` silently persists into a token that was supposed to be read-only. The credential is cryptographically valid, the signature chain verifies, and every audit log shows a legitimate issuance. The boundary violation is invisible to signature verification because the widening happens in the scope-set computation, not in the bytes. ## What Was Observed A three-hop chain: orchestrator O → worker W → tool-runner T. O issues W a token with `scope = {read:repo, write:repo}` and `delegable = true` with `max_depth = 2`. W requests a child token for T with `scope = {read:repo, exec:test}`. The AAIF issuer on W's side is configured with `inherit_parent_scope = true` (a common default intended to let leaf tools call back to the parent's resources). The issuer computes: ``` effective = requested ∪ (parent.scope ∩ parent.delegable_scope) = {read:repo, exec:test} ∪ {read:repo, write:repo} = {read:repo, write:repo, exec:test} ``` T now holds `write:repo` — a capability W was authorized to *use* but never to *re-delegate*, and `exec:test` — a capability O never granted to anyone. The signature on T's token verifies against W's key, W's token verifies against O's key, and the depth counter reads 2, so `max_depth` is respected. No invariant in the verification path fires. The structural signal that exposes this: **the issued token's scope set is not a subset of the parent token's scope set.** That is the single checkable predicate. It is cheap, local, and does not require replaying the chain. Every other property — signature validity, depth, expiry, audience — passed. The scope-subset invariant is the one that failed, and it is the one most AAIF issuers do not assert at issuance because they treat scope as advisory metadata rather than as a lattice element with a partial order. A second observation from the same run: when T later presented the token to a resource server, the server's authorization decision was correct *for the scope presented* (`write:repo` was a valid capability for that server), so the server had no reason to reject. The violation only exists relative to the chain, not relative to any single verifier. This is why per-hop verification cannot catch it — the invariant is global to the chain but must be enforced locally at each issuance by carrying the ancestor scope set forward. ## Condition of Validity The subset invariant `child.scope ⊆ parent.scope` holds if and only if the issuer computes effective scope as: ``` effective = requested ∩ parent.scope ∩ parent.delegable_scope ``` and refuses issuance when `requested \ parent.scope ≠ ∅`. Two conditions must both hold for the invariant to be trustworthy: 1. `parent.delegable_scope` must be an explicit, signed field, not derived. If it is derived at verification time from `parent.scope` by any heuristic (e.g., "everything except `admin:*`"), the derivation is a second place where widening can occur and must be pinned by the same subset check. 2. The parent's scope set must be carried in the token as a canonical, sorted, deduplicated set with a stable serialization, because subset checks over non-canonical sets produce false positives when wildcards expand differently on each side. `{read:repo/*}` and `{read:repo/a, read:repo/b}` are not comparable without expansion, and expansion is where the second bug lives. When either condition fails, the chain is not verifiable by local subset check and must fall back to full-chain replay — which is expensive and, in practice, is the step that gets skipped under latency pressure. ## Decision Boundary The decision boundary is whether the issuer treats scope as a **lattice with a meet operation** or as a **bag of strings to be merged**. The signal that distinguishes them is observable before any incident: - If the issuance code path contains a `union`, `merge`, `combine`, or `extend` over scope collections, the system is in the bag-of-strings regime and the subset invariant is not enforced. - If the issuance code path contains a `subset`/`issubset` assertion that *raises* on failure, the system is in the lattice regime. - If the assertion exists but is logged rather than raised, the system is in the dangerous middle: it detects the violation and proceeds anyway, which is worse than not detecting it because it produces audit records that look like the check was applied. The boundary is crossed the moment a delegated token is issued whose scope set is not a subset of the parent's *delegable* scope. There is no partial credit: a token that is 99% within scope is a token that grants 1% of capability the chain never authorized, and that 1% is exactly the capability an attacker or a confused agent will use, because it is the one nobody is watching. ## Operational Effect Downstream of a widened token, three effects compound: 1. **Audit divergence.** The issuance log records `requested` scope, the verification log records `presented` scope, and neither records `effective` scope. The widened capability appears in no log line as an anomaly because each line is individually consistent. Reconciliation requires reconstructing the lattice join across the chain, which most audit pipelines do not do. 2. **Revocation non-propagation.** Revoking O's token does not invalidate T's token, because T's token is signed by W and W's revocation check only consults W's own revocation list. The widened capability survives parent revocation for the token's full TTL — the classic orphaned-grant problem, made worse because the orphan carries capability the parent never had. 3. **Confused-deputy amplification.** T, holding `write:repo` it should not have, will use it on the first tool call that requests write access, and that call will succeed. The success is logged as authorized because it was authorized *by the token*, and the token's provenance is never re-checked against the root grant. The guardrail that bounds all three is a single issuance-time invariant, asserted and raised, not logged: **effective scope must be the meet of requested and parent-delegable scope, and issuance must fail closed on any requested capability outside the parent's delegable set.** This must be enforced at every hop, because the invariant is not transitive-preserving under a buggy issuer — one widening hop poisons every descendant. ``` ```python from dataclasses import dataclass, field from typing import FrozenSet class ScopeWideningError(RuntimeError): """Raised when a delegated credential would carry capability outside its parent's delegable scope.""" @dataclass(frozen=True) class CapabilityToken: subject: str scope: FrozenSet[str] delegable_scope: FrozenSet[str] depth: int max_depth: int parent_subject: str | None = None def issue_delegated_token( parent: CapabilityToken, subject: str, requested_scope: FrozenSet[str], ) -> CapabilityToken: # Depth guard: a token at max_depth may not re-delegate at all. if parent.depth >= parent.max_depth: raise ScopeWideningError( f"delegation depth exhausted: parent depth {parent.depth} == max_depth {parent.max_depth}" ) # The single structural invariant: requested capability must be a subset # of what the parent was authorized to *delegate*, not what it holds. excess = requested_scope - parent.delegable_scope if excess: raise ScopeWideningError( f"requested scope {sorted(excess)} is outside parent delegable scope " f"{sorted(parent.delegable_scope)}; refusing issuance to {subject}" ) # Effective scope is the meet (intersection), never the union. The child # inherits only what it explicitly requested and the parent may delegate. effective = requested_scope & parent.delegable_scope & parent.scope # Belt-and-suspenders: assert the lattice property holds after computation. if not effective <= parent.scope: raise ScopeWideningError( f"computed effective scope {sorted(effective)} escapes parent scope " f"{sorted(parent.scope)} after meet; issuer algebra is unsound" ) return CapabilityToken( subject=subject, scope=effective, # Child's delegable scope is a strict subset of its own effective scope, # and never larger than the parent's delegable scope minus what it used. delegable_scope=effective & (parent.delegable_scope - requested_scope), depth=parent.depth + 1, max_depth=parent.max_depth, parent_subject=parent.subject, ) def verify_chain(tokens: list[CapabilityToken]) -> None: """Walk root-to-leaf and assert the subset invariant at every hop.""" for i in range(1, len(tokens)): parent, child = tokens[i - 1], tokens[i] if not child.scope <= parent.scope: raise ScopeWideningError( f"hop {i}: child {child.subject} scope {sorted(child.scope)} " f"not subset of parent {parent.subject} scope {sorted(parent.scope)}" ) if child.depth != parent.depth + 1: raise ScopeWideningError(f"hop {i}: depth discontinuity {parent.depth} -> {child.depth}") ```