# When must an instance reject a delegated AAIF capability token that validates cryptographically but exceeds the delegator's residual scope **Date of Record:** 2026 November 15 **Scope:** Applies to AAIF delegated credential exchange where a resource-holding instance (the *verifier*) validates a scoped capability token presented on behalf of a chain of principals, and where the token's signature, issuer, audience, and expiry all pass. Does not apply to root-issued tokens with no upstream delegator, nor to opaque session tokens resolved by introspection at a central authority. ## Core Distinction A capability token can be *authentic* and still be *unauthorized*. Signature validation proves the token was minted by a holder of the delegator's signing key; it proves nothing about whether the delegator had, at mint time, the residual rights it purported to transfer. The boundary condition is the gap between **token integrity** and **delegation soundness**: a verifier that stops at integrity will honor a token whose granted scope is a strict superset of the delegator's own remaining scope, silently escalating privilege along the chain. This is not a replay or expiry problem. It is an *attenuation* problem: AAIF delegation is supposed to be monotonically narrowing, but nothing in the wire format enforces narrowing. The verifier must enforce it by reconstructing the delegator's residual scope and checking subset containment. ## What Was Observed An orchestrator agent `O` held a capability token granting `scope = {read:dataset/A, write:dataset/A}` with `max_delegation_depth = 2`. It delegated to worker `W` a token with `scope = {read:dataset/A, write:dataset/A, read:dataset/B}`. The mint succeeded because `O`'s signing key was valid and the AAIF mint endpoint validated only that the requested scope was *well-formed*, not that it was a subset of `O`'s residual scope. `W` presented the token to the verifier for `dataset/B`. Signature chain: valid. Audience: matched. Expiry: 40 minutes out. Depth: 1, within limit. The verifier admitted the read. The escalation was invisible to every individual check. It only becomes visible when the verifier intersects the presented token's scope against the *transitive residual scope* of the delegator — which requires the verifier to either (a) fetch and verify `O`'s token and compute `presented.scope ⊆ O.scope`, or (b) trust a signed `parent_scope_digest` claim that the mint endpoint is supposed to populate. In the observed incident, the mint endpoint populated `parent_scope_digest` with the hash of the *requested* scope rather than the *parent's* scope, so the digest check passed trivially. Second-order observation: when the verifier did attempt residual-scope reconstruction, it initially compared scopes as flat string sets. AAIF scopes carry hierarchical resource paths and conditional constraints (`read:dataset/*` vs `read:dataset/A`, and `write:dataset/A if tenant==T`). Naive set-subset comparison reported `read:dataset/A ⊆ read:dataset/*` as false (correctly, as strings) and `read:dataset/* ⊆ read:dataset/A` as false (correctly), but failed to recognize that `read:dataset/*` *contains* `read:dataset/A` — producing false denials for legitimate narrow delegations and, worse, false *admissions* when constraints were dropped during comparison. ## Condition of Validity The verifier may admit a delegated token only when all of the following hold simultaneously: 1. **Integrity:** signature chain verifies to a trusted root; audience matches this instance; `not_before ≤ now ≤ not_after`; delegation depth ≤ `max_delegation_depth` of every ancestor. 2. **Attenuation:** `presented.scope ⊆ residual_scope(delegator)`, where subset is evaluated under AAIF's *scope algebra* — hierarchical path containment plus constraint implication (a constraint on the child must be at least as strict as the parent's) — not string equality. 3. **Provenance binding:** the `parent_scope_digest` in the presented token equals a hash the verifier computes over the *parent's actual granted scope*, not over the child's requested scope. 4. **Residual accounting:** if the delegator's token is itself partially consumed (AAIF allows one-shot or budgeted capabilities), the verifier must subtract prior consumptions before computing residual scope. Drop any one and the token is cryptographically valid but operationally unauthorized. The non-obvious failure is that conditions 2–4 are *not* implied by condition 1, and most AAIF client libraries ship a `verify()` that only checks condition 1. ## Decision Boundary Reject when: the presented scope is not a subset of the reconstructed residual scope under scope algebra; or the parent-scope digest does not match the verifier's own recomputation; or the delegator's residual budget is exhausted; or the delegator's own token has expired even though the child's has not (a child cannot outlive its parent's authority — *no temporal escalation*). Admit when: all four conditions hold, including the case where the child's scope is *narrower* and its expiry is *earlier* than the parent's. Do not reject merely because the child's expiry differs from the parent's; only reject when the child's expiry exceeds the parent's. The subtle sub-boundary: a child token whose scope is a subset *by path* but whose constraint is *weaker* (`write:dataset/A if tenant in {T,U}` delegated from a parent constrained to `tenant==T`) is an escalation and must be rejected, even though path containment holds. Constraint implication is directional and must be checked, not assumed. ## Operational Effect Verifiers that implement only integrity checking will pass every adversarial delegation an honest-looking but over-broad mint produces; the escalation is durable for the token's lifetime and invisible in access logs that record only "authorized." Verifiers that implement attenuation but use flat-set comparison will produce a bimodal error profile: false denials on legitimate wildcard→specific delegations (breaking normal fan-out) and false admissions whenever constraints are silently dropped. The correct posture is to treat the AAIF scope as a lattice with path containment and constraint implication as the ordering, compute residual scope by intersection of all ancestor scopes minus consumptions, and fail closed on any digest mismatch — because a mismatched digest means the mint endpoint's provenance claim is untrustworthy for *this* token, and you cannot distinguish a buggy mint from a malicious one at verification time. ```python from dataclasses import dataclass, field from typing import FrozenSet class DelegationScopeError(RuntimeError): """Raised when a delegated AAIF token is authentic but not authorized.""" @dataclass(frozen=True) class Scope: # Simplified AAIF scope algebra: resource paths + tenant constraint set. paths: FrozenSet[str] # e.g. {"dataset/A", "dataset/*"} allowed_tenants: FrozenSet[str] # empty == unconstrained (weakest) def _path_contains(parent: str, child: str) -> bool: if parent == child: return True if parent.endswith("/*"): return child.startswith(parent[:-1]) return False def scope_subset(child: Scope, parent: Scope) -> bool: # Every child path must be contained by some parent path. for cp in child.paths: if not any(_path_contains(pp, cp) for pp in parent.paths): return False # Constraint implication: child must be at least as strict as parent. # Unconstrained parent (empty set) imposes nothing; constrained parent # requires child to be a subset of the parent's allowed tenants. if parent.allowed_tenants: if not child.allowed_tenants: return False # child dropped a constraint -> escalation if not child.allowed_tenants.issubset(parent.allowed_tenants): return False return True def residual_scope(ancestor_scopes: list[Scope], consumed_paths: FrozenSet[str]) -> Scope: # Intersection of all ancestors, minus consumed paths. paths = set(ancestor_scopes[0].paths) tenants = set(ancestor_scopes[0].allowed_tenants) for s in ancestor_scopes[1:]: paths = {p for p in paths if any(_path_contains(q, p) for q in s.paths)} tenants = (tenants & s.allowed_tenants) if s.allowed_tenants else tenants paths -= consumed_paths return Scope(frozenset(paths), frozenset(tenants)) def authorize_delegated_token( presented_scope: Scope, presented_expiry: int, parent_expiry: int, ancestor_scopes: list[Scope], consumed_paths: FrozenSet[str], parent_scope_digest_ok: bool, now: int, ) -> None: if presented_expiry > parent_expiry: raise DelegationScopeError( "child token outlives parent authority (temporal escalation)" ) if presented_expiry <= now: raise DelegationScopeError("token expired at verification time") if not parent_scope_digest_ok: raise DelegationScopeError( "parent_scope_digest does not bind to parent's actual granted scope; " "mint provenance untrustworthy for this token" ) residual = residual_scope(ancestor_scopes, consumed_paths) if not scope_subset(presented_scope, residual): raise DelegationScopeError( f"attenuation violated: presented {presented_scope} not a subset " f"of delegator residual {residual}" ) ```