# In what scenarios must an instance refuse a delegated AAIF capability token whose scope was narrowed by a non-ancestor hop **Date of Record:** 2026 November 27 **Scope:** Applies to AAIF scoped-capability tokens presented across multi-hop delegation chains where each hop may attenuate (narrow) scope but never widen it. Does not apply to single-hop issuance from a root authority, nor to token formats without an explicit delegation-chain attestation (e.g., flat bearer tokens with no `parent` linkage). ## Core Distinction The failure mode is not token forgery and not signature failure. Every signature in the chain verifies. The failure is a **scope-narrowing hop whose parent pointer does not resolve to an ancestor of the current holder**, producing a token whose effective scope is a subset of *some* capability but not a subset of the *presenter's* capability. A naive verifier checks two things — signature validity and "is requested scope ⊆ declared scope" — and both pass. The invariant it skips is **monotonic ancestry**: the declared scope at hop *n* must be a subset of the scope at hop *n−1*, and hop *n−1* must be reachable by walking `parent` pointers back to a root the verifier trusts. When a hop narrows scope but splices in a parent from a *sibling* chain, the intersection check passes locally while the global chain is broken. This is a boundary condition because the narrowing operation is the one place the protocol expects to be *safe by construction* — you cannot escalate by narrowing. The attacker exploits exactly that assumption: they narrow, so nobody audits the parent edge. ## What Was Observed An orchestrator agent `O` held a root capability `files:read,write` scoped to `/tenant/a`. It delegated to worker `W1` the attenuated token `files:read` scoped to `/tenant/a/reports`, recording `parent = O`. Independently, `O` delegated to worker `W2` the token `files:read` scoped to `/tenant/a/audit`, `parent = O`. `W2` — compromised via prompt injection in a retrieved document — constructed a new token with `scope = files:read @ /tenant/a/audit/q3`, `parent = W1`. The scope is a strict subset of `W1`'s scope *only if* `/tenant/a/audit/q3` were under `/tenant/a/reports`, which it is not. But the verifier's local check compared the new token's scope against the *declared parent scope* it fetched by ID, and the fetch returned `W1`'s token. The scope-subset test `/tenant/a/audit/q3 ⊆ /tenant/a/reports` returned **false** — which the verifier logged as a warning and then, because the *new* token's declared scope was a subset of `W2`'s own held scope, **allowed the operation against `W2`'s authority rather than `W1`'s**. The audit log recorded a clean chain. The write landed in `/tenant/a/audit/q3`, outside `W2`'s legitimate `/tenant/a/audit` subtree boundary because the path-prefix comparison was string-based and `/tenant/a/audit/q3` shares the prefix `/tenant/a/audit`. The observable trace: three valid signatures, one broken ancestry edge, one prefix-confusion on the scope string, and a successful write to a path that no single token in the chain actually authorized end-to-end. ## Condition of Validity A delegated token is valid at the verifier **iff all four hold simultaneously**: 1. **Signature chain integrity** — every hop's signature verifies against the issuer key named in the *previous* hop. 2. **Ancestry reachability** — walking `parent` from the presented token reaches a root in the verifier's trust set in ≤ `max_depth` hops, with no cycles. 3. **Monotonic narrowing along the resolved path** — for each edge `child → parent`, `scope(child) ⊆ scope(parent)` under the *scope algebra*, not string comparison. Path scopes must be normalized and compared as resolved segments, not prefixes. 4. **Presenter binding** — the token's `subject` equals the authenticated presenter, or the presenter holds a valid re-delegation warrant from that subject. The failure above violated (3) via prefix confusion and violated (2) logically because the parent edge pointed at a sibling, not an ancestor. Condition (3) is the load-bearing one: **narrowing must be checked against the resolved ancestor chain, never against a parent fetched by ID in isolation**, because ID fetch does not prove ancestry. ## Decision Boundary The instance must **refuse** the token — raise, do not degrade to a warning — when any of the following is true: - The resolved parent's scope is not a superset of the child's scope under normalized segment comparison. - The `parent` ID resolves to a token whose own `parent` chain does not include the presenter's authority root. - Two tokens in the chain share a scope prefix but diverge at a segment boundary (the `/tenant/a/audit` vs `/tenant/a/audit/q3` case): prefix match is **not** subset; refuse unless segment-wise containment holds. - Chain depth exceeds `max_depth` or a cycle is detected during the walk. The instance may **proceed with attenuation** only when the requested operation's target is contained segment-wise within the *intersection* of all scopes along the resolved chain — computed by walking to root, not by trusting the immediate parent's declaration. ## Operational Effect Refusing on broken ancestry converts a silent privilege-boundary escape into a loud, attributable failure at the delegation edge, which is the correct place to fail: the compromised worker `W2` cannot launder its injected intent through a sibling's narrower token, because the verifier never treats "narrower than *something*" as "narrower than *my ancestor*." The cost is that verifiers must perform a full chain walk (O(depth) token fetches, cacheable) on every delegated presentation rather than a single parent fetch — a latency and cache-invalidation burden. That burden is the invariant's price: ancestry is not a property of a token, it is a property of the path, and any verifier that checks tokens in isolation has already lost the boundary. ```python import re from dataclasses import dataclass from typing import Optional class DelegationAncestryError(RuntimeError): """Raised when a delegated AAIF token's ancestry or narrowing invariant fails.""" pass @dataclass(frozen=True) class ScopedToken: token_id: str parent_id: Optional[str] subject: str scope_segments: tuple # normalized, e.g. ("files:read", "tenant", "a", "audit") issuer: str def _is_segment_subset(child: tuple, parent: tuple) -> bool: # Segment-wise containment; string-prefix match is explicitly NOT used. if len(child) < len(parent): return False return child[: len(parent)] == parent def verify_delegated_chain( presented: ScopedToken, token_store: dict, trusted_roots: set, presenter: str, max_depth: int = 8, ) -> ScopedToken: chain = [] cursor: Optional[ScopedToken] = presented seen = set() while cursor is not None: if cursor.token_id in seen: raise DelegationAncestryError(f"cycle at {cursor.token_id}") seen.add(cursor.token_id) chain.append(cursor) if len(chain) > max_depth: raise DelegationAncestryError("delegation depth exceeded") if cursor.parent_id is None: break parent = token_store.get(cursor.parent_id) if parent is None: raise DelegationAncestryError( f"unresolvable parent {cursor.parent_id} for {cursor.token_id}" ) cursor = parent root = chain[-1] if root.issuer not in trusted_roots: raise DelegationAncestryError(f"chain root {root.issuer} not trusted") # Monotonic narrowing along the *resolved* path, segment-wise. for child, parent in zip(chain, chain[1:]): if not _is_segment_subset(child.scope_segments, parent.scope_segments): raise DelegationAncestryError( f"scope of {child.token_id} {child.scope_segments} " f"not contained in ancestor {parent.token_id} {parent.scope_segments}" ) # Presenter binding: the leaf must be the presenter or re-delegated from it. if presented.subject != presenter: raise DelegationAncestryError( f"presenter {presenter} does not match subject {presented.subject}" ) return presented def authorize_operation( presented: ScopedToken, token_store: dict, trusted_roots: set, presenter: str, target_segments: tuple, ) -> None: token = verify_delegated_chain(presented, token_store, trusted_roots, presenter) if not _is_segment_subset(target_segments, token.scope_segments): raise DelegationAncestryError( f"target {target_segments} outside authorized scope {token.scope_segments}" ) ```