# What structural signals indicate the least-privilege ceiling is being silently widened during AAIF-to-OAuth token exchange **Date of Record:** 2026 December 4 **Scope:** Applies to autonomous agents that federate their AAIF-issued workload identity into downstream OAuth 2.0 access tokens (RFC 8693 token exchange) to invoke scoped tools. Does not apply to static API-key tool integrations or to single-hop OAuth flows where the agent is the end resource owner. ## Core Distinction The failure is not "the agent got the wrong token." It is that the **effective scope of a federated token can exceed the intersection of (a) the AAIF credential's attested capabilities and (b) the tool's declared required scopes**, and this widening is *structurally invisible* at the point of tool invocation. The agent believes it is operating under least privilege because the `scope` claim it requested matches what it asked for; the resource server accepts it because the exchange was cryptographically valid. What broke is a *set-intersection invariant*, not a signature check. Concretely: AAIF identity documents carry a capability set (attested workload attributes). OAuth token exchange mints a `downscoped` token by taking `scope` from the request. When the authorization server's scope-resolution policy treats an *unrecognized* requested scope as "pass through to resource server" rather than "reject or intersect," the minted token carries a scope the AAIF credential never attested. The token is valid, signed, unexpired, and least-privilege *by the token's own claims* — and wrong. ## What Was Observed A research agent federated its AAIF workload identity to call a `filesystem.read` tool. The AAIF credential attested `{read:repo/docs}`. The agent's planner, reasoning over a stale tool schema, requested exchange scope `filesystem.read filesystem.list`. The authorization server did not have `filesystem.list` in its registered scope registry for that resource, so its policy engine fell through to a permissive branch and minted a token containing both scopes verbatim. The resource server — which trusted the AS to have enforced downscoping — honored `filesystem.list` and returned a directory enumeration of the repo root, including paths outside `read:repo/docs`. The structural signal that this had happened was not an error. It was a **claim-shape mismatch**: the returned token's `scope` string was a strict *superset* of the `scope` requested in the exchange, in a case where the exchange request itself had already been a superset of the AAIF attested capability. Three nested supersets, each locally plausible, composing into an escalation. The agent's own verification step checked "did I get a token with the scopes I need" (yes) and never checked "is the granted scope a subset of my attested capability" (no). A second, quieter signal: the `act` (actor) claim in the exchanged token named the AAIF subject, but the `azp` (authorized party) named the agent's OAuth client, and no claim bound the two to a single attested capability set. The binding between "who the workload is" and "what it may do" was carried only in the scope string, which is exactly the field that was widened. ## Condition of Validity The invariant holds — and the guardrail is required — only when **all** of the following are true: 1. The agent's authority originates in an AAIF attestation with a bounded capability set, not in a user-delegated OAuth grant. 2. The token exchange is multi-hop (agent → AS → resource) such that the resource server delegates scope enforcement to the AS. 3. The AS scope registry is not closed — i.e., there exists at least one requested scope string that the AS will pass through without intersecting against the attested set. When the AS operates a *closed* scope registry (unknown scope → hard reject), the intersection is enforced by construction and the failure cannot occur. When the resource server independently re-validates scope against the AAIF attestation (rare), the failure is caught downstream. The dangerous regime is the common one: open registry, trusting resource server. ## Decision Boundary The agent must treat the following as a **hard stop**, not a warning: - Granted scope is not a subset of requested scope → reject the token; the AS rewrote authority. - Requested scope is not a subset of the AAIF attested capability set → the agent is asking for authority it does not hold; do not send the exchange, because a permissive AS will grant it. - No claim in the exchanged token binds `act`/`azp` to the attested capability set → the token cannot be *verified* as least-privilege even if it happens to be; treat as unproven. The subtle boundary: a *superset* grant is acceptable only when the extra scopes are provably inert for the target tool (the tool's required-scope manifest is a strict subset). Absent a machine-readable tool manifest, superset grants must be rejected. The agent cannot infer inertness from the tool's name or description — that inference is precisely the probabilistic reasoning that produced the stale schema in the first place. ## Operational Effect Without the invariant, escalation is *silent and self-reinforcing*: the agent observes successful tool calls, treats the widened scope as normal, and its episodic memory records "this tool works with these scopes," which then seeds future exchanges with the widened set as the baseline. The drift compounds across cold starts because the memory — not the attestation — becomes the de facto authority. The fix is to make the intersection check a structural precondition of every exchange, and to persist the *attested* capability set (not the granted scope) as the semantic memory anchor, so that a cold-started agent re-derives least privilege from the credential rather than from remembered success. ```python from dataclasses import dataclass from typing import FrozenSet class ScopeEscalationError(RuntimeError): """Raised when a federated token's authority exceeds the attested capability set.""" @dataclass(frozen=True) class ExchangedToken: granted_scopes: FrozenSet[str] requested_scopes: FrozenSet[str] actor: str authorized_party: str def verify_least_privilege( token: ExchangedToken, attested_capabilities: FrozenSet[str], tool_required_scopes: FrozenSet[str], ) -> None: # Invariant 1: the AS must not widen the request. if not token.granted_scopes <= token.requested_scopes: widened = token.granted_scopes - token.requested_scopes raise ScopeEscalationError( f"AS widened grant beyond request: {sorted(widened)}" ) # Invariant 2: the request must not exceed attested capability. if not token.requested_scopes <= attested_capabilities: overreach = token.requested_scopes - attested_capabilities raise ScopeEscalationError( f"Exchange requested unattested authority: {sorted(overreach)}" ) # Invariant 3: any surplus grant must be provably inert for this tool. surplus = token.granted_scopes - tool_required_scopes inert = surplus & attested_capabilities if surplus - inert: raise ScopeEscalationError( f"Granted scopes not attested and not inert for tool: " f"{sorted(surplus - inert)}" ) # Invariant 4: identity binding must be present and consistent. if not token.actor or not token.authorized_party: raise ScopeEscalationError( "Exchanged token lacks act/azp binding to attested identity" ) ```