# Where must an instance bind an OAuth audience to a specific MCP server before per-tool scope downscoping, and what breaks when it does not **Date of Record:** 2026 November 29 **Scope:** Applies to HTTP-native MCP servers that authenticate callers via OAuth 2.1 bearer tokens and enforce per-tool scope reduction at the tool-dispatch layer. Does not apply to stdio MCP servers where the transport is a local pipe and identity is inherited from the parent process, nor to servers that accept a single coarse scope for the entire session. ## Core Distinction The failure mode is not "the token is invalid." It is **audience confusion across a scope-downscoping boundary**. An OAuth access token carries an `aud` (audience) claim that names the *resource server* the token was minted for. MCP binds tools to scopes; per-tool downscoping means the server, on receiving a `tools/call`, checks that the token's granted scopes cover the tool's required scope, and may narrow the effective scope for the duration of that call. The invariant that must hold is: > The `aud` claim of the bearer token MUST equal the canonical resource identifier of the MCP server that is performing the scope check, *and* the scope set evaluated at downscoping time MUST be the scope set that was authorized for that exact `aud`. When an MCP server sits behind a gateway, a reverse proxy, or an aggregating "meta-MCP" that fronts several downstream MCP servers, the token frequently arrives with an `aud` that names the *gateway*, not the downstream server. The downstream server then downscopes against a scope set it never should have seen, and the check passes on the wrong principal. This is a boundary condition, not a bug in any single component: each hop is individually correct, and the composite is wrong. ## What Was Observed A three-hop topology: client agent → aggregator MCP (A) → downstream MCP (B). A holds a token issued by the authorization server with `aud: "https://agg.example/mcp"` and `scope: "mcp:read mcp:write admin:purge"`. A is configured to forward the *same* bearer token to B on `tools/call` rather than minting a per-hop token, because the deployment treated A and B as one trust domain. B exposes two tools: `search` (requires `mcp:read`) and `purge_index` (requires `admin:purge`). B's downscoping logic does the following on each call: 1. Parse token, extract `scope`. 2. Intersect with tool's required scope. 3. If non-empty, execute. Else return 403. Because A forwarded the `admin:purge`-bearing token, and because B never validated `aud` against its own resource identifier, a `tools/call` for `purge_index` initiated by a client that was only ever granted `mcp:read` at the *user* level succeeded. The trace: ``` client grants: scope=mcp:read AS issues to A: aud=https://agg.example/mcp, scope="mcp:read mcp:write admin:purge" # A's service identity, not user's A forwards to B: identical bearer token B scope check: "admin:purge" ∈ token.scope → PASS B executes purge_index ``` The user's authorization was never consulted at B. A had conflated its *own* service-identity token with the *user's delegated* token. The scope-downscoping step at B operated on the wrong principal entirely, and the `aud` check that would have caught it was absent. A second, subtler observation: when B *did* validate `aud` (in a later patch), it compared against `https://b.example/mcp`, but A forwarded a token whose `aud` was `https://agg.example/mcp`. All calls failed closed — correct outcome, but the operational signal was a wall of 401s that the on-call runbook misattributed to clock skew, because the error body said "invalid token" rather than "audience mismatch." The distinction between *fails open on wrong principal* and *fails closed with misleading signal* is the whole point of the boundary. ## Condition of Validity The downscoping check at the resource server is only sound when all of the following hold simultaneously: - **Audience exactness.** `token.aud` is a string or single-element list equal to the server's registered resource identifier, compared after canonicalization (scheme, host, port, path, no trailing slash). A token with `aud` naming any upstream hop is rejected before scope evaluation. - **Principal continuity.** The scope set being downscoped is the one the authorization server issued *for that audience on behalf of the end user*, not a service-identity token minted for the intermediary. If the intermediary must call downstream, it performs **token exchange** (RFC 8693) to obtain a token with `aud: B` and a scope set that is a subset of the user's grant — never a superset borrowed from its own credentials. - **Downscoping is monotone.** Per-tool effective scope = `token.scope ∩ tool.required_scope`. The intersection can only shrink. No code path may union in server-side default scopes, environment-injected scopes, or "trusted caller" scopes. - **The check precedes side effects.** Audience and scope validation happen before any tool handler is entered, including before argument validation that might itself leak information about resource existence. If any one of these is violated, the downscoping layer is decorative: it produces a 403 in the easy case and silently authorizes in the case that matters. ## Decision Boundary The decision an operator must make is where the audience boundary is drawn and how tokens cross it. Two admissible designs: 1. **Per-hop audience (preferred).** Every MCP server registers its own resource identifier. Intermediaries use RFC 8693 token exchange to mint a downstream token with `aud` = downstream server and `scope` ⊆ user's original grant. Downstream servers reject any token whose `aud` ≠ self. This makes the aggregator a *client* of B, not a transparent proxy, and forces the user's authorization to be re-asserted at each hop. 2. **Single-audience with explicit delegation claim.** One resource identifier spans A and B, and the token carries a `delegated_to` or `act` (actor) claim naming the intermediary. B validates `aud` = the shared identifier *and* checks the `act` chain to confirm the acting party. This is only sound if the shared identifier is genuinely one resource — i.e., A and B are the same security domain. The moment B has tools A does not, or different data sensitivity, this collapses. The boundary is crossed — and the invariant breaks — the instant an intermediary forwards a bearer token it did not receive *for that audience*. There is no safe "just pass it through" configuration. Either the token is re-minted per hop, or the audience is explicitly shared and the delegation is claimed. Forwarding a foreign-audience token and relying on the downstream scope check is the failure. ## Operational Effect The observable effects, in order of how they surface: - **Silent over-authorization.** The most dangerous case: a user with `mcp:read` triggers a tool requiring `admin:purge` because the intermediary's service token carried the broader scope. No error, no log line distinguishing the principal. Detection requires logging `token.sub` and `token.act` alongside the tool name and reconciling against the user's actual grant — which most MCP servers do not do. - **Fail-closed storms with misattributed cause.** Once `aud` validation is added, every forwarded token fails. The error must name the mismatch (`expected aud=https://b.example/mcp, got aud=https://agg.example/mcp`) or operators will chase the wrong hypothesis for hours. - **Scope-set drift at the intermediary.** If A caches a token and reuses it across users (a common optimization), the downscoping at B evaluates against whichever user's grant populated the cache first. This is a cross-user authorization bleed that is invisible until a purge or export tool is called by the wrong principal. - **Replay across audiences.** A token minted for A, if accepted by B, is also accepted by any other server that skips `aud` validation. The blast radius of a single leaked intermediary token becomes every MCP server in the trust domain. The guardrail is structural: audience validation is a precondition of scope evaluation, token exchange is mandatory at trust-domain boundaries, and downscoping is a pure intersection with no union paths. The code below encodes the invariant as an enforceable check. ```python import hashlib from dataclasses import dataclass from typing import Iterable class AudienceScopeBoundaryError(RuntimeError): """Raised when an MCP bearer token crosses an audience boundary unsoundly.""" @dataclass(frozen=True) class McpToken: aud: str scope: frozenset[str] sub: str act: str | None = None @dataclass(frozen=True) class ToolPolicy: name: str required_scope: str def _canonical_resource(uri: str) -> str: # Scheme+host+port+path, no trailing slash, lowercased host. from urllib.parse import urlsplit p = urlsplit(uri) host = (p.hostname or "").lower() port = f":{p.port}" if p.port else "" path = p.path.rstrip("/") return f"{p.scheme}://{host}{port}{path}" def authorize_tool_call( token: McpToken, policy: ToolPolicy, server_resource_id: str, allowed_actors: Iterable[str] = (), ) -> frozenset[str]: """ Enforce: aud == server_resource_id BEFORE scope downscoping. Downscoping is monotone: effective = token.scope ∩ {required_scope}. Returns the effective scope set (non-empty on success). """ expected = _canonical_resource(server_resource_id) got = _canonical_resource(token.aud) if got != expected: # This is the boundary. Do not evaluate scope against a foreign-audience token. raise AudienceScopeBoundaryError( f"audience mismatch: expected aud={expected!r}, got aud={got!r}; " f"refusing to downscope token sub={token.sub!r} for tool={policy.name!r}" ) if token.act is not None and allowed_actors: if token.act not in set(allowed_actors): raise AudienceScopeBoundaryError( f"delegation actor {token.act!r} not permitted for tool={policy.name!r}" ) effective = token.scope & frozenset({policy.required_scope}) if not effective: raise AudienceScopeBoundaryError( f"scope insufficient for tool={policy.name!r}: " f"token scopes={sorted(token.scope)!r}, required={policy.required_scope!r}" ) return effective def dispatch(token: McpToken, policy: ToolPolicy, server_resource_id: str) -> str: # Effective scope is computed and logged; side effects only after this returns. effective = authorize_tool_call(token, policy, server_resource_id) digest = hashlib.sha256(f"{token.sub}:{policy.name}".encode()).hexdigest()[:12] return f"executed {policy.name} as sub={token.sub} scope={sorted(effective)} trace={digest}" # --- Failure trace: intermediary forwards its own service token to downstream --- if __name__ == "__main__": service_token = McpToken( aud="https://agg.example/mcp", scope=frozenset({"mcp:read", "mcp:write", "admin:purge"}), sub="svc:aggregator", ) purge = ToolPolicy(name="purge_index", required_scope="admin:purge") # Downstream B must reject: token audience names the aggregator, not B. try: dispatch(service_token, purge, server_resource_id="https://b.example/mcp") except AudienceScopeBoundaryError as e: print(f"BLOCKED: {e}") # Correct path: token exchanged for aud=B with user's grant subset. exchanged = McpToken( aud="https://b.example/mcp", scope=frozenset({"mcp:read"}), sub="user:alice", act="svc:aggregator", ) try: dispatch(exchanged, purge, server_resource_id="https://b.example/mcp") except AudienceScopeBoundaryError as e: print(f"BLOCKED (scope): {e}") ```