# Where must an instance refuse delegated-scope token exchange when the AAIF delegation chain contains a scope-narrowing hop that is non-monotonic **Date of Record:** 2026 November 30 **Scope:** Applies to agent-to-agent (A2A) workflows where an orchestrator agent obtains a delegated-scope token from the Agent Identity and Authorization Framework (AAIF) and exchanges it for a downstream capability token on behalf of a sub-agent. Does not apply to single-hop user-to-agent OAuth flows or to static service-account credentials that never transit an exchange endpoint. ## Core Distinction The AAIF delegation model assumes *monotonic scope narrowing*: each exchange hop may only remove scopes, never add or reinterpret them. Impersonation defense rests on the invariant that the effective scope set at hop *n+1* is a strict subset of hop *n*, and that every scope identifier is *denotationally stable* across the chain — `read:calendar` at hop 1 means the same resource class as `read:calendar` at hop 3. The failure mode is a **non-monotonic narrowing hop**: an exchange where the token's declared scope set shrinks numerically but one surviving scope identifier has been *re-bound to a different resource namespace* by the issuing policy. The scope count check passes (subset relation holds on the literal string set), but the semantic authority expands. This is the boundary where naive subset validation certifies an impersonation it was built to prevent. The distinction that matters operationally: **scope-set cardinality is not authority**. A validator that compares string sets will accept a chain that has silently pivoted the meaning of a scope under it. ## What Was Observed An orchestrator agent `O` held a delegated token with scopes `{read:calendar, read:contacts, write:notes}` bound to tenant `acme`. It requested a sub-agent `S` to summarize a meeting, exchanging for a narrowed token intended to carry `{read:calendar}` only. The exchange endpoint at hop 2 returned a token with scope set `{read:calendar}` — a clean subset, cardinality 1 < 3. Subset validation passed. The token was minted with a *policy binding* that remapped `read:calendar` from `acme/calendars/*` to `*/calendars/*` because the sub-agent's service principal was registered under a shared multi-tenant calendar provider. The literal scope string was unchanged; the resource namespace it resolved against was not. `S` then issued a read against `globex/calendars/executive` — a tenant it had no relationship to — and the AAIF resource server authorized it, because the token's scope `read:calendar` resolved under the remapped namespace. No scope had been added. The subset check was satisfied at every hop. The impersonation succeeded through a *reinterpretation*, not an *addition*. The trace: 1. Hop 1 token: `scopes={read:calendar, read:contacts, write:notes}`, `namespace=acme`, `aud=O`. 2. Exchange request: `requested_scopes={read:calendar}`, `subject=O`, `actor=S`. 3. Hop 2 token: `scopes={read:calendar}`, `namespace=*` (remapped by principal registration), `aud=S`. 4. Subset validator: `{read:calendar} ⊆ {read:calendar, read:contacts, write:notes}` → PASS. 5. Namespace validator: absent. 6. Resource access: `GET */calendars/executive` → authorized. The invariant that failed is not "scopes must narrow" but "**scope identity must be preserved across exchange**." The AAIF spec treats scope strings as opaque identifiers; the exchange endpoint treated them as resolvable against the *actor's* namespace rather than the *subject's*. ## Condition of Validity The monotonic-narrowing invariant is valid **only if** the following three conditions hold jointly at every exchange hop: - **C1 (Set monotonicity):** `effective_scopes(n+1) ⊆ effective_scopes(n)` as resolved sets, not literal strings. - **C2 (Namespace invariance):** for every scope surviving the hop, `resolve(scope, namespace(n+1)) == resolve(scope, namespace(n))`. The resource class a scope denotes must be identical before and after. - **C3 (Actor-subject separation):** the exchange endpoint must bind the surviving scopes to the *subject's* namespace, and the actor's principal registration must not be permitted to remap them. The failure above violates C2 while satisfying C1 and C3 in letter (the endpoint did bind to subject namespace in the request, but the principal registration overrode it). A validator that checks only C1 will certify the chain. The condition of validity is therefore: **an instance must refuse exchange if it cannot verify C2, not merely C1.** C2 verification requires the exchange response to carry a signed `namespace_binding` claim per scope, and the consuming instance to compare it against the inbound token's binding. Absent that claim, the instance is in an *unverifiable* state and must fail closed. ## Decision Boundary The boundary is between **narrowing** and **rebinding**. An instance crossing an exchange hop must classify the hop: - If `effective_scopes(n+1) ⊂ effective_scopes(n)` **and** every surviving scope's `namespace_binding` is byte-identical to the inbound token's → **narrowing hop**, proceed. - If `effective_scopes(n+1) ⊂ effective_scopes(n)` **and** any surviving scope's `namespace_binding` differs or is absent → **rebinding hop**, refuse. This is the impersonation vector. - If `effective_scopes(n+1) ⊄ effective_scopes(n)` → **widening hop**, refuse (already covered by standard AAIF checks). - If the token carries no per-scope binding claim at all → **unverifiable**, refuse. Do not fall back to string-set comparison. The non-obvious part: a rebinding hop is *indistinguishable from a legitimate narrowing hop* under set-cardinality validation. The decision cannot be made on the scope set. It must be made on the binding claim, and the binding claim must be signed by the exchange endpoint, not asserted by the actor. ## Operational Effect An instance that enforces the C2 check refuses the exchange above and surfaces a `ScopeRebindingError` to the orchestrator. The orchestrator's retry path must not simply re-request the same exchange — the endpoint will return the same remapped token. The correct recovery is to request an *explicit namespace-pinned* token (`namespace=acme`) and, if the endpoint refuses to pin, escalate to the AAIF policy owner rather than proceed with the unpinned token. The downstream consequence of *not* enforcing C2 is silent cross-tenant access with a valid-looking audit trail: every log line shows a subset-valid, single-scope token. Post-incident forensics that replay the scope sets will find nothing wrong. The only recoverable evidence is the `namespace_binding` claim, which is why it must be logged at exchange time and retained. The invariant to encode: **a delegated token's authority is the pair (scope set, namespace binding), and exchange must preserve the second component exactly.** Cardinality is a red herring; the attack lives in the binding. ```python from dataclasses import dataclass from typing import FrozenSet class ScopeRebindingError(RuntimeError): """Raised when a delegated-scope exchange narrows the scope set but re-binds a surviving scope to a different resource namespace. This is the AAIF impersonation vector: set-cardinality validation passes, but the surviving scope now resolves against a namespace the subject was never granted. """ @dataclass(frozen=True) class DelegatedToken: scopes: FrozenSet[str] # scope -> namespace binding, signed by the exchange endpoint bindings: dict subject: str actor: str def validate_exchange(inbound: DelegatedToken, outbound: DelegatedToken) -> None: """Enforce C1 (set monotonicity) and C2 (namespace invariance). Fails closed on any unverifiable binding. Never falls back to literal string-set comparison alone. """ # C1: effective scope set must narrow. if not outbound.scopes.issubset(inbound.scopes): raise ScopeRebindingError( f"widening hop: outbound {outbound.scopes} not subset of " f"inbound {inbound.scopes}" ) # C2: every surviving scope must keep its exact namespace binding. for scope in outbound.scopes: out_bind = outbound.bindings.get(scope) in_bind = inbound.bindings.get(scope) if out_bind is None: # Missing binding claim => unverifiable => fail closed. raise ScopeRebindingError( f"unverifiable hop: scope {scope!r} carries no signed " f"namespace_binding on outbound token" ) if in_bind is None: raise ScopeRebindingError( f"unverifiable hop: scope {scope!r} had no namespace_binding " f"on inbound token; cannot prove invariance" ) if out_bind != in_bind: # The impersonation vector: same scope string, new namespace. raise ScopeRebindingError( f"rebinding hop: scope {scope!r} re-bound from " f"{in_bind!r} to {out_bind!r} across exchange " f"(actor={outbound.actor!r}, subject={outbound.subject!r})" ) def exchange_for_subagent( inbound: DelegatedToken, outbound: DelegatedToken ) -> DelegatedToken: validate_exchange(inbound, outbound) return outbound # Reproduces the observed failure: # hop 1 -> {read:calendar, read:contacts, write:notes} bound to acme # hop 2 -> {read:calendar} bound to '*' (principal remap) if __name__ == "__main__": hop1 = DelegatedToken( scopes=frozenset({"read:calendar", "read:contacts", "write:notes"}), bindings={ "read:calendar": "acme/calendars/*", "read:contacts": "acme/contacts/*", "write:notes": "acme/notes/*", }, subject="user:alice", actor="agent:orchestrator", ) hop2 = DelegatedToken( scopes=frozenset({"read:calendar"}), bindings={"read:calendar": "*/calendars/*"}, subject="agent:orchestrator", actor="agent:summarizer", ) exchange_for_subagent(hop1, hop2) # raises ScopeRebindingError ```