# In what scenarios must an instance reject an MCP OAuth token whose `aud` matches the resource server but whose `act`/scope chain was minted for a different upstream tool **Date of Record:** 2026 November 24 **Scope:** Applies to HTTP-native MCP servers (Streamable HTTP / SSE transport) that delegate authorization to an external OAuth 2.1 authorization server and validate bearer tokens per RFC 8707 resource indicators. Does not apply to stdio-local MCP servers or to servers that terminate identity internally without a separate AS. ## Core Distinction The confused-deputy failure in MCP-over-HTTP is *not* the classic "token audience not checked" bug. Modern MCP servers correctly verify `aud == https://mcp.example.com` per RFC 8707. The non-obvious boundary is subtler: **audience binding validates that the token was minted for *this resource server*, but says nothing about *which upstream tool or tenant* the token's scope and actor chain were originally consented for.** A token can be perfectly audience-bound to the MCP server yet carry a scope set or `act` (actor) claim that was granted by the user for a *different* MCP client, a *different* downstream tool behind the same server, or a *different* tenant sharing the same AS. The distinction that matters operationally: **audience is a property of the resource server; authority is a property of the (user, client, tool) triple.** A server that checks only `aud` has verified the envelope, not the grant. ## What Was Observed A representative trace from an MCP gateway fronting two downstream tools — `calendar.read` and `drive.write` — both registered under one resource identifier `https://mcp.example.com`: 1. Client A (a calendar assistant) completes the authorization code flow with `resource=https://mcp.example.com` and `scope=calendar.read`. The AS mints an access token with `aud=https://mcp.example.com`, `scope=calendar.read`, `sub=user-42`, `client_id=calendar-assistant`. 2. Client B (a document agent, same user `user-42`) previously obtained a token with `scope=drive.write calendar.read` — the user consented to both during B's onboarding. 3. An attacker who has compromised Client B's token store (or a malicious MCP client) replays B's token against the gateway's `calendar.read` tool. The gateway validates: signature OK, `exp` OK, `aud=https://mcp.example.com` OK, `scope` contains `calendar.read` OK. Request admitted. 4. The gateway's audit log attributes the call to `user-42` with no distinction from Client A. The `client_id` claim was present in the token but not propagated into the tool invocation context, so the downstream calendar tool could not distinguish "user-42 acting through their calendar assistant" from "user-42 acting through a document agent that happens to hold a calendar scope." The failure is not that the token was invalid. It is that **the token was valid for a grant the tool never intended to honor through this client.** RFC 8707 audience binding is satisfied; the confused-deputy defense is not, because the deputy (the MCP gateway) cannot tell which principal *delegated* the call. A second observed variant: a multi-tenant MCP server where the AS issues tokens with `aud=https://mcp.example.com` for tenants `t1` and `t2`. A token minted for `t1` with `scope=tools:invoke` was accepted by the `t2` tool handler because the handler only checked scope membership, not tenant binding. The `aud` matched; the tenant did not. ## Condition of Validity The invariant that must hold for a token to be admissible to a specific tool invocation is: ``` aud == resource_server_id AND client_id ∈ allowed_clients(tool) AND sub == invocation_subject AND tenant_claim == tool.tenant AND scope ⊇ required_scope(tool) AND (act chain, if present) terminates at a principal authorized for tool ``` Audience binding is necessary but not sufficient. The `client_id` claim — mandated by OAuth 2.1 for confidential clients and present in all AS-issued tokens — is the field that carries the *delegation principal*, and it is the field most commonly dropped at the MCP boundary because the MCP spec's authorization section emphasizes `aud` and `scope` and treats `client_id` as transport metadata rather than authorization input. The condition of validity therefore requires the MCP server to: - **Propagate `client_id` into the tool invocation context**, not just the audit log. A tool that cannot see which client originated the call cannot enforce per-client authorization. - **Bind tenant claims** (however the deployment encodes them — `tenant`, `org_id`, or a scoped `aud` like `https://mcp.example.com/t1`) to the tool's tenant, not just to the server. - **Validate the `act` (actor) chain** when tokens are obtained via token exchange (RFC 8693). An `act` chain that includes a client not authorized for the target tool is a confused-deputy indicator even when `aud` and `scope` match. ## Decision Boundary The boundary is between **envelope validation** and **grant validation**. Envelope validation (signature, `exp`, `aud`, `scope` membership) is stateless and can be performed by any gateway. Grant validation (client, subject, tenant, actor chain) requires the gateway to hold a per-tool authorization policy that maps `(client_id, sub, tenant, act)` to permitted tools. The decision rule: - If the MCP server fronts **a single tool with a single client and a single tenant**, envelope validation collapses to grant validation and `aud`-only checking is sound. - If the server fronts **multiple tools, multiple clients, or multiple tenants under one resource identifier**, `aud`-only checking is unsound and the server MUST perform grant validation before dispatch. The moment a second client or tenant is admitted to the same `aud`, the audience check stops carrying delegation information. A corollary boundary: **do not use `aud` to encode tenant.** Some deployments issue `aud=https://mcp.example.com/t1` to sidestep this. This works only if the AS enforces that a client requesting `resource=https://mcp.example.com/t1` is authorized for `t1` at token issuance time. If the AS will mint any requested `resource` for any authenticated client — which many do by default — then tenant-in-audience is theater: the attacker's client simply requests the victim tenant's resource indicator. RFC 8707 §2 explicitly warns that resource indicators are client-supplied and the AS must validate them against the client's registration; a server relying on `aud` for tenant isolation is trusting the client to have told the AS the truth. ## Operational Effect The operational consequence is that **MCP servers must treat `client_id` and any tenant/actor claims as first-class authorization inputs, and must fail closed when they are absent or unmatched.** In practice this means: 1. The token validation middleware returns a structured principal `(sub, client_id, tenant, act_chain, scope)` rather than a boolean. 2. The tool dispatch layer consults a policy table keyed on that principal before invoking the tool. 3. Tokens lacking `client_id` (opaque tokens, or AS misconfiguration) are rejected for multi-client servers rather than admitted on `aud` alone. 4. Token exchange flows that produce `act` chains are validated end-to-end; a chain containing an unauthorized actor is rejected even if the final subject is authorized. The failure mode when this is skipped is silent: the call succeeds, the audit log shows the correct `sub`, and the only signal is that a tool was invoked through a client that should not have been able to invoke it. There is no error to alert on — which is why the boundary must be enforced structurally rather than detected post hoc. ```python from dataclasses import dataclass from typing import FrozenSet, Optional, Tuple class ConfusedDeputyError(RuntimeError): """Raised when a token is audience-valid but grant-invalid for the target tool.""" @dataclass(frozen=True) class Principal: sub: str client_id: Optional[str] tenant: Optional[str] scope: FrozenSet[str] act_chain: Tuple[str, ...] @dataclass(frozen=True) class ToolPolicy: name: str tenant: str allowed_clients: FrozenSet[str] required_scope: FrozenSet[str] def authorize_invocation( principal: Principal, token_aud: str, expected_aud: str, tool: ToolPolicy, ) -> None: # Envelope check: audience binding (RFC 8707). Necessary, not sufficient. if token_aud != expected_aud: raise ConfusedDeputyError( f"audience mismatch: token aud={token_aud!r} != resource {expected_aud!r}" ) # Grant check: the deputy must know which principal delegated the call. if principal.client_id is None: raise ConfusedDeputyError( f"token for sub={principal.sub!r} lacks client_id; " f"cannot bind delegation for multi-client server" ) if principal.client_id not in tool.allowed_clients: raise ConfusedDeputyError( f"client {principal.client_id!r} not authorized for tool {tool.name!r}; " f"audience matched but grant did not" ) # Tenant binding: aud does not encode tenant; the claim must. if principal.tenant != tool.tenant: raise ConfusedDeputyError( f"tenant {principal.tenant!r} != tool tenant {tool.tenant!r} for {tool.name!r}" ) # Scope membership. missing = tool.required_scope - principal.scope if missing: raise ConfusedDeputyError( f"tool {tool.name!r} requires scope {sorted(missing)}; token lacks it" ) # Actor chain: any actor in the exchange chain must be authorized for the tool. for actor in principal.act_chain: if actor not in tool.allowed_clients: raise ConfusedDeputyError( f"actor {actor!r} in act chain not authorized for tool {tool.name!r}; " f"confused-deputy indicator despite valid aud" ) ```