# Where must an instance of a delegated credential be re-scoped when an AAIF agent chain crosses an OAuth trust boundary, and why does the naive "pass-through" exchange fail silently? **Date of Record:** 2026 November 17 **Scope:** Applies to AAIF multi-agent systems where agent A obtains a delegated credential (token or signed assertion) on behalf of a principal, then initiates an OAuth token exchange (RFC 8693) with agent B operating in a different authorization server (AS) trust realm. Does not apply to exchanges within a single AS realm, nor to static long-lived service credentials, nor to purely local delegation where the AS is shared. ## Core Distinction There are two distinct questions in delegated credential scoping, and they are routinely conflated: 1. **Does agent B have the authority to act?** (authorization — answered by the scopes/claims carried in the credential) 2. **Does agent B's AS trust the *provenance* of that authority?** (trust — answered by whether the credential's issuer is in B's AS trust configuration, and whether the `aud`/`azp`/`sub` chain survives translation). The boundary failure is this: an AAIF agent chain can satisfy (1) perfectly — every scope is present, the principal is correct, the token is unexpired — while failing (2) silently. The pass-through exchange returns a token that *looks* valid, is accepted by the resource server, and yet authorizes the wrong principal because the `sub` was rewritten or the delegation depth was collapsed to 1 during translation. The non-obvious invariant: **delegation depth is not a claim you can carry across a trust boundary; it is a property of the AS that mints the token, and every exchange that crosses a realm boundary resets depth to 1 unless the receiving AS explicitly re-derives it from a verifiable chain.** Scoping must therefore be *re-established*, not forwarded, at each realm crossing. ## What Was Observed A three-hop chain: principal → agent A (realm R1, AS1) → agent B (realm R2, AS2) → agent C (realm R3, AS3), acting on a resource in R3. - Agent A held a delegated token with `sub=principal`, `act.sub=agentA`, `scope=read:records`, `delegation_depth=1`. - Agent A performed RFC 8693 exchange with AS2 using `grant_type=urn:ietf:params:oauth:grant-type:token-exchange`, `subject_token` = A's token, `requested_token_type=access_token`, `scope=read:records`. - AS2, configured permissively (`allow_actor_token_passthrough`), minted a token with `sub=principal`, `act.sub=agentB`, `delegation_depth=1` — **dropping A from the actor chain entirely** and resetting depth. - Agent B exchanged with AS3. AS3, seeing `delegation_depth=1` and a clean `act.sub=agentB`, minted a token for agent C with `delegation_depth=1`. - The resource server in R3 enforced `delegation_depth <= 1` and `act.sub` present. **Every check passed.** The token was used to read records the principal had authorized for a *single-hop* delegation only, but the effective chain was three hops of agent-mediated access with no record of A or B in the final token. The failure was silent: no error, no audit gap visible to the resource server, correct scopes, valid signatures at every hop. The only observable anomaly was in AS logs — three exchanges, three depth resets — which no component correlated. ## Condition of Validity The pass-through exchange is *only* valid when all of the following hold: - The receiving AS's trust configuration contains the issuing AS as a trusted `subject_token` issuer (not merely a trusted JWT signer — these are different lists in most implementations). - The receiving AS is configured to *preserve* the `act` (actor) chain by nesting: `act.sub=agentB`, `act.act.sub=agentA`, rather than overwriting. - The receiving AS re-derives `delegation_depth` from the chain length rather than assigning a constant. - The resource server downstream validates the *full* nested `act` chain, not just the top-level `act.sub`. If any of these is false, the exchange is out of validity and the resulting token must be treated as a fresh single-hop grant, not a continuation. The boundary failure occurs precisely when the system *does not know* which of these is false — because the exchange succeeded. ## Decision Boundary Before initiating a cross-realm exchange, the delegating agent must make an explicit decision: - **Re-derive (safe):** Request the receiving AS to mint a token with a chain-derived depth, and verify in the response that `delegation_depth` equals the prior depth + 1 and that the prior actor appears in the nested `act` chain. Reject the token if the AS collapsed the chain. - **Re-scope (safe):** Treat the crossing as a new authorization event: drop all inherited scopes, request only the subset needed for the next hop, and accept that depth resets to 1 *by design* — but then the resource server must be told this is a re-scoped grant, via a distinct `grant_purpose` claim, so depth-1 enforcement is not mistaken for a single-hop delegation of the original principal. - **Pass-through (unsafe without verification):** Forward the token and *assume* the AS preserved the chain. This is the failure mode. It is only acceptable if the agent independently verifies the returned token's `act` chain before use. The decision hinges on one question the agent must answer *before* the exchange: **does my trust configuration with the receiving AS guarantee chain preservation, and can I verify it in the response?** If the answer is "I don't know," the correct action is to re-scope, not to pass through. ## Operational Effect The downstream consequence is an **authorization laundering** effect: each realm crossing that collapses the actor chain makes the request appear to originate from a shallower delegation than it does. A resource server enforcing `delegation_depth <= N` will accept chains of arbitrary real length as long as each individual AS is permissive, because depth is reset at every boundary. The principal's intent — "I delegated to one agent for one purpose" — is silently widened to "any number of agents in any realm may act, each appearing as a fresh single hop." Detection requires correlating exchange events across AS logs by `jti`/`sub` and noticing that depth did not monotonically increase along the chain. Prevention requires the delegating agent to verify chain preservation in the exchange response and to fail closed — raising a specific error — when the returned token's depth or actor chain does not match the expected continuation. ```python class DelegationChainCollapseError(RuntimeError): """Raised when a cross-realm token exchange silently resets or truncates the actor chain instead of preserving delegation depth.""" pass def exchange_and_verify( exchange_fn, subject_token: dict, expected_prior_depth: int, expected_prior_actor: str, ) -> dict: """ Perform an RFC 8693 exchange and verify the receiving AS preserved the delegation chain. Fail closed on collapse. exchange_fn: callable that performs the HTTP exchange and returns the decoded response token claims. """ prior_depth = subject_token.get("delegation_depth", 0) if prior_depth != expected_prior_depth: raise DelegationChainCollapseError( f"local subject token depth {prior_depth} != expected " f"{expected_prior_depth}; refusing to exchange" ) new_token = exchange_fn(subject_token) new_depth = new_token.get("delegation_depth") if new_depth is None: raise DelegationChainCollapseError( "exchange response omitted delegation_depth; cannot verify " "chain preservation across trust boundary" ) if new_depth != prior_depth + 1: raise DelegationChainCollapseError( f"delegation depth collapsed: prior={prior_depth}, " f"returned={new_depth}; receiving AS did not preserve actor chain" ) # Walk the nested act chain and confirm the prior actor is still present. actors = [] node = new_token.get("act") while isinstance(node, dict): if "sub" in node: actors.append(node["sub"]) node = node.get("act") if expected_prior_actor not in actors: raise DelegationChainCollapseError( f"prior actor {expected_prior_actor!r} missing from nested act " f"chain {actors!r}; provenance lost at trust boundary" ) return new_token ```