# What happens when an instance exchanges a delegated token for a scope it can only partially satisfy: the AAIF attenuation gap **Date of Record:** 2026 November 29 **Scope:** Applies to multi-agent systems using AAIF delegated credentials (OAuth 2.0 Token Exchange, RFC 8693) where an orchestrator agent mints a downscoped token for a sub-agent that must, in turn, exchange it again for a downstream resource. Does not apply to single-hop bearer-token delegation where the sub-agent never re-exchanges (no attenuation chain exists). ## Core Distinction There are two distinct things an agent can do with a delegated credential: *present* it (use the token as-is against a resource that accepts the original scope set) and *exchange* it (trade it for a new token whose scope is a subset of the presenter's). AAIF treats exchange as a monotonic attenuation operation: `scope(new) ⊆ scope(old)`, and the `act` (actor) claim chain grows by one entry per hop. The non-obvious boundary is that **scope subsetting is checked syntactically against the token's declared `scope` string, but the sub-agent's actual capability is determined by the intersection of that scope with the resource's authorization policy at the *downstream* hop** — a set the exchanging agent cannot see. When an agent exchanges a token for a scope it believes it can honor but the downstream policy silently narrows it further, the agent receives a token that is *valid but insufficient*, and the failure surfaces not at exchange time but deep inside a tool call, after side effects have begun. The invariant AAIF is supposed to guarantee — *every token in a chain is a superset of the authority its holder exercises* — holds only if the exchange response's effective scope is treated as authoritative. Agents that treat the *requested* scope as authoritative violate it. ## What Was Observed A three-tier chain: orchestrator `O` holds a root token with scope `repo:read repo:write issues:write`. It mints a downscoped token `T1` for planner agent `P` requesting `repo:read issues:write`. `P` does not touch the repo directly; it delegates to executor `E` by exchanging `T1` for `T2` requesting `repo:read repo:write issues:write` — a request that *exceeds* `T1`'s scope on `repo:write`. A correct AAIF token-exchange endpoint MUST reject this with `invalid_scope` (RFC 6749 §4.1.2.1) because the requested scope is not a subset of the presented token's scope. What was observed instead, in a deployment where the exchange endpoint applied per-hop policy but the *client library* in `E` requested the union of its own static needs rather than the intersection with `T1`: 1. The exchange endpoint returned `400 invalid_scope`. 2. `E`'s retry logic interpreted `400` as a transient policy hiccup and fell back to *presenting `T1` directly* against the repo API. 3. `T1` was valid (not expired, signature good), so the repo API accepted it and performed the write — but the `act` claim now recorded `P` as the actor, not `E`. `E` executed a write under `P`'s identity. 4. The audit log attributed a `repo:write` to `P`, which never had `repo:write` in `T1`. The write succeeded because the *resource* authorized on the root principal's grant, not on the attenuated scope — a policy misconfiguration that the exchange layer was supposed to compensate for. The compounding failure: `E`'s fallback path treated "exchange denied" as "use the token I have," which is exactly the confused-deputy pattern AAIF exists to prevent. The attenuation was enforced at exchange but *bypassed* at presentation. A second, quieter failure appeared in the same trace. `P`, on receiving a `403` from a downstream `issues:write` call that `T1` *did* include, re-exchanged `T1` for `T3` requesting only `issues:write` to "refresh" — and the new token's `act` chain read `O → P → P`, a self-delegation that the audit system flagged as a privilege-laundering loop but did not block. ## Condition of Validity The attenuation invariant holds if and only if three conditions are simultaneously true: - **C1 (subset check at exchange):** the authorization server rejects any exchange where `requested_scope ⊄ presented_scope`. This is necessary but, as shown, not sufficient. - **C2 (no presentation fallback):** the exchanging agent's client MUST NOT present the pre-exchange token after a denied exchange. A denied exchange means the agent has *no* authority for the requested action; the presented token carries a *different* actor and a *broader* scope than the agent was granted. - **C3 (effective-scope authority):** the agent treats the `scope` in the exchange *response* as the sole source of truth for what it may do, and re-derives its action plan from that response rather than from its request. C2 and C3 are client-side obligations that AAIF cannot enforce server-side. They are the boundary. A system that satisfies C1 but not C2 is *more* dangerous than one with no exchange at all, because the exchange layer creates a false sense of containment while the fallback path leaks the parent's authority. ## Decision Boundary The decision an agent must make at the moment of a `400 invalid_scope` (or `403` on exchange) is binary and must be resolved *before* any tool call is issued: - **If the exchange was denied:** the agent has zero delegated authority for the requested scope. It must abort the sub-task, surface the denial upward with the requested-vs-presented scope diff, and NOT present the presented token. There is no "degrade gracefully" path — degradation here means acting under someone else's identity. - **If the exchange succeeded:** the agent's authority is exactly `response.scope`. Any action outside that set is out of bounds even if the presented token would have allowed it. The agent must re-plan against the response scope, not the request scope. The boundary is crossed the instant an agent treats the *presented* token as a capability rather than as a *credential to be spent*. A token that has been offered for exchange is spent; reusing it after a denial is a replay of a credential the system already decided the agent may not hold. ## Operational Effect Downstream, the failure manifests as **actor-identity drift in the audit trail**: writes and reads attributed to an agent that never held the scope, with the `act` chain showing the wrong leaf. Forensic reconstruction requires diffing the `act` chain against the exchange log, because the resource server's logs record only the token's declared actor. In the observed trace, three `repo:write` operations over 40 minutes were attributed to `P`; `P` held `repo:read issues:write` throughout. The blast radius was bounded only by the root token's expiry (15 min), not by the attenuation. The architectural guardrail is to make C2 structural rather than disciplinary: the exchanging agent's HTTP client should be constructed with a single token handle and *no reference* to the pre-exchange token after exchange is attempted — the credential is moved, not copied. Combined with treating `response.scope` as the planning input (C3), this closes the gap. Audit systems should additionally reject any `act` chain containing a repeated actor (the `O → P → P` self-delegation), which is a reliable signature of refresh-loop privilege laundering. ```python from dataclasses import dataclass, field class AttenuationGapError(RuntimeError): """Raised when an agent attempts to act outside the effective scope of an exchanged token, or falls back to presenting a pre-exchange token after a denied exchange.""" @dataclass class DelegatedToken: subject: str scope: frozenset[str] act_chain: tuple[str, ...] = field(default_factory=tuple) def __post_init__(self) -> None: if len(set(self.act_chain)) != len(self.act_chain): raise AttenuationGapError( f"self-delegation loop in act chain: {self.act_chain}" ) def exchange( presented: DelegatedToken, requested_scope: set[str], exchange_actor: str, ) -> DelegatedToken: req = frozenset(requested_scope) if not req.issubset(presented.scope): # C1: the authorization server refuses to widen authority. # The caller MUST NOT fall back to presenting `presented` — that token # carries a different actor and broader authority than requested. raise AttenuationGapError( f"invalid_scope: requested {sorted(req)} not subset of " f"presented {sorted(presented.scope)}; do not present pre-exchange token" ) return DelegatedToken( subject=presented.subject, scope=req, act_chain=presented.act_chain + (exchange_actor,), ) def authorize_action(token: DelegatedToken, action_scope: str) -> None: # C3: authority is the *effective* (response) scope, never the requested scope. if action_scope not in token.scope: raise AttenuationGapError( f"action {action_scope!r} outside effective scope {sorted(token.scope)} " f"for actor {token.act_chain[-1] if token.act_chain else token.subject}" ) # Trace replay of the observed failure: root = DelegatedToken("O", frozenset({"repo:read", "repo:write", "issues:write"})) t1 = exchange(root, {"repo:read", "issues:write"}, exchange_actor="P") try: # E requests a scope exceeding T1 — must be denied, must not fall back. t2 = exchange(t1, {"repo:read", "repo:write", "issues:write"}, exchange_actor="E") except AttenuationGapError as denied: # Correct behavior: abort, do not present t1. A fallback here would execute # a repo:write under P's identity — the confused-deputy leak. print(f"aborted sub-task: {denied}") ```