# Why does an instance accept a valid OAuth token for the wrong resource: the MCP audience-binding failure at tool-invocation time **Date of Record:** 2026 November 27 **Scope:** Applies to MCP tool servers that authenticate callers via OAuth 2.1 bearer tokens issued by a shared authorization server, where per-tool scope checks are enforced but token audience (`aud`) is validated only at the transport/handshake layer and not re-validated per tool invocation. Does not apply to servers using mutually-bound DPoP tokens with per-tool thumbprints, nor to single-tenant deployments where all tokens share one resource identity. ## Core Distinction There are two different questions an MCP server can ask about a bearer token, and conflating them is the entire failure: 1. **"Is this token valid?"** — signature, expiry, issuer trust. This is answered once, at the `initialize`/session-establishment boundary, and is a property of the *connection*. 2. **"Is this token authorized for *this specific tool, on this specific resource*?"** — audience binding plus per-tool scope. This must be answered on *every* `tools/call`, because the resource being acted upon is a parameter of the call, not a property of the connection. The confused-deputy failure arises when the server treats (1) as sufficient for (2). A token minted for resource `A` — audience `aud: mcp://server-a` — is presented to server `B`. Server `B` validates signature and issuer, sees valid scopes like `tools:read` and `tools:write`, and executes. The token was never *for* `B`. The authorization server was the deputy, and `B` just did the confused thing the token asked of it, on behalf of a client that should never have reached `B` with that credential. The non-obvious part: **per-tool scope enforcement does not save you.** A token can carry `tools:write` and still be audience-bound to a different resource. Scope is a *capability* grant; audience is a *recipient* constraint. They are orthogonal claims, and a server that checks one but not the other passes every test you write against a single-resource deployment. ## What Was Observed Setup: two MCP servers, `mcp://fs-server` (filesystem tools) and `mcp://mail-server` (mail tools), both trusting the same authorization server. The AS issues tokens with `aud` set to the requested resource and scopes `mcp:tools.read`, `mcp:tools.write`. The `mail-server` validates the token at `initialize`, checks `mcp:tools.write` before `send_message`, and does nothing else. Trace of the failure: 1. Agent session obtains a token for `fs-server`: `aud: mcp://fs-server`, `scope: mcp:tools.read mcp:tools.write`. Legitimate — it needs to read a config file. 2. The agent's tool router, holding a single session credential pool, reuses the *same bearer token* when it later decides to call `mail-server.send_message` (a plausible consequence of a shared `Authorization` header in a multi-server client, or of an agent that was told "the token works for our MCP servers"). 3. `mail-server` receives `tools/call` with `name: send_message`, `Authorization: Bearer `. It verifies signature against the AS JWKS, confirms `exp` is in the future, confirms `mcp:tools.write ∈ scope`, and executes `send_message`. 4. The mail is sent. The token's `aud` claim said `mcp://fs-server`. Nobody checked. The observable symptom in logs is *nothing anomalous*: a valid token, a valid scope, a successful tool call. The failure is invisible to per-tool scope logging because the scope check passed. It surfaces only when an auditor diffs the token's `aud` against the server's own resource identifier — which, in this deployment, no component did. A second, sharper variant: the `fs-server` exposes both `read_file` and `delete_file`. Both require `mcp:tools.write` in this deployment (the scope model was coarse). An agent holding a token with `aud: mcp://fs-server` and `scope: mcp:tools.write` — issued because the agent's *stated* need was `read_file` — can call `delete_file`. Scope was satisfied; the *intent* captured at token issuance was not. This is per-tool scope collapse: when multiple tools share a scope, the scope no longer encodes which tool the user consented to. ## Condition of Validity The audience check is only a real defense under all of the following: - **The AS binds `aud` to a single resource identifier** that the MCP server can compare against its own canonical URI (not a hostname, not a wildcard). If the AS issues `aud: mcp://*` or omits `aud`, the check is vacuous. - **The server re-validates `aud` on every `tools/call`**, not only at `initialize`. Session-scoped validation is insufficient because the same session can be handed a new token (refresh) whose audience differs. - **Per-tool scopes are distinct per tool**, or a tool-level allowlist is enforced independent of scope. Coarse scopes (`tools.write`) make audience the *only* thing standing between `read_file` consent and `delete_file` execution. - **The client does not pool tokens across servers.** If the client reuses one bearer across `fs-server` and `mail-server`, audience binding is the *only* defense — scope will always pass. Where any of these is false, the deployment is in the confused-deputy regime and the per-tool scope check is providing false assurance. ## Decision Boundary The boundary is: **does the server treat the token as a credential for the connection, or as a warrant for the specific (tool, resource) pair?** - If the token is a *connection credential*: validate once, cache the decision, execute any tool whose scope is present. This is the failing model. It is correct only when the server is the sole resource the AS ever mints tokens for. - If the token is a *warrant*: on every `tools/call`, assert `token.aud == self.resource_id` **and** `required_scope(tool) ⊆ token.scope` **and**, where the AS supports it, `token.cnf`/DPoP thumbprint matches the client key. Reject on any failure with a distinct error, because the three failures have different remediations: wrong audience = client misrouting; missing scope = consent gap; thumbprint mismatch = token theft. The subtle decision: **should a wrong-audience token be rejected even when the scope is right and the tool is harmless?** Yes — because "harmless" is a property you cannot verify at the boundary, and a server that accepts foreign-audience tokens for harmless tools will, under a later scope-model change, accept them for harmful ones. The invariant must be audience-strict regardless of tool sensitivity, or it is not an invariant. ## Operational Effect Enforcing per-call audience binding converts a silent cross-resource authorization bypass into a hard, attributable rejection. The client that pooled tokens now gets `403 invalid_token: audience mismatch` at the `mail-server` boundary and must acquire a token for `mail-server` — which routes the request back through the AS, where the user's consent for mail is actually captured. The deputy is no longer confused; the request fails at the point where the wrong credential was presented, not at the point where the wrong action was taken. The cost is one JWKS-cached signature check and one string comparison per tool call — negligible against the tool's own latency — plus the discipline of never caching an authorization decision across calls. The failure mode you are buying protection against is the one where every individual check passes and the composite is wrong, which is exactly the class of failure that per-tool scope logging will never show you. ```python from dataclasses import dataclass from typing import FrozenSet class AudienceBindingError(RuntimeError): """Raised when a bearer token is valid but not a warrant for this resource/tool.""" @dataclass(frozen=True) class Token: aud: str scope: FrozenSet[str] issuer: str exp: int @dataclass(frozen=True) class ToolPolicy: name: str required_scope: str class MCPAuthorizationGate: def __init__(self, resource_id: str, trusted_issuer: str): self.resource_id = resource_id self.trusted_issuer = trusted_issuer def authorize(self, token: Token, tool: ToolPolicy, now: int) -> None: # Signature/expiry are assumed pre-verified upstream; this gate is the # per-call warrant check that per-tool scope alone does not provide. if token.exp <= now: raise AudienceBindingError(f"token expired at {token.exp}") if token.issuer != self.trusted_issuer: raise AudienceBindingError( f"issuer {token.issuer!r} not trusted by {self.resource_id!r}" ) # The invariant: audience must name *this* resource, on *every* call. if token.aud != self.resource_id: raise AudienceBindingError( f"token audience {token.aud!r} does not bind to resource " f"{self.resource_id!r}; refusing tool {tool.name!r} " f"(confused-deputy: token was minted for another server)" ) if tool.required_scope not in token.scope: raise AudienceBindingError( f"tool {tool.name!r} requires scope {tool.required_scope!r}; " f"token carries {sorted(token.scope)}" ) def handle_tools_call( gate: MCPAuthorizationGate, token: Token, tool: ToolPolicy, now: int, ) -> str: gate.authorize(token, tool, now) return f"executed {tool.name} under aud={token.aud}" ```