# What happens when an instance accepts a forwarded bearer token across an MCP HTTP transport boundary **Date of Record:** 2026 November 23 **Scope:** Applies to MCP servers exposed over HTTP-native transports (Streamable HTTP, SSE) that perform OAuth 2.1 resource-server enforcement and sit behind one or more intermediary agents/proxies. Does not cover stdio transport, which has no origin or bearer-token surface, nor local process-spawning clients. ## Core Distinction The failure is not "an expired token" or "a missing scope." It is **confused-deputy token passthrough**: an MCP server accepts a bearer token whose `aud` (audience) does not name that server, because the token was minted for an upstream agent and forwarded verbatim. The server validates the signature, finds the scope it needs, and executes — while the token's audience, issuer binding, and origin claims all point at a *different* party. This is distinct from token theft: the token is valid. It is distinct from scope escalation: the scope was legitimately granted. The break is purely in **resource binding** — the invariant that a token presented to resource R must have been issued *for* R. The second, coupled distinction: **origin validation** is not CSRF hygiene here. For an HTTP-native MCP server with a browser-reachable endpoint, `Origin`/`Host` checking is the only mechanism that prevents a malicious web page from driving an already-authenticated agent's tool calls (DNS-rebinding and cross-origin streaming). Origin validation and audience validation are the same invariant viewed from two ends: *who is allowed to speak to this resource, and on whose behalf.* ## What Was Observed A three-tier deployment: a browser client → an orchestrator agent (holds a user-delegated token with `aud=orchestrator`) → an MCP server (`aud` should be `mcp://tools.internal`). The orchestrator called `tools/call` over Streamable HTTP and set `Authorization: Bearer `. The MCP server's middleware did the common partial check: 1. Verified JWT signature against the IdP's JWKS — **passed**. 2. Checked `exp`/`nbf` — **passed**. 3. Checked that the required scope `tools:write` was present — **passed** (the orchestrator's token carried it, because the orchestrator needed it to *delegate*). 4. **Did not check `aud`.** The server never compared `aud` to its own canonical resource identifier. Result: the server executed writes as if the orchestrator were the resource owner. The trace is deterministic and reproducible: ``` POST /mcp HTTP/1.1 Authorization: Bearer eyJ... # aud="orchestrator", scope="tools:write" Origin: https://orchestrator.example ``` The server logs `auth_ok scope_ok`, dispatches the tool, returns `200`. No error surfaces. The confused-deputy condition is silent — there is no failed assertion to alert on, because the assertion was never written. A parallel observation on the origin axis: the same server, reached from a browser tab via a page at `https://evil.example`, accepted a `POST /mcp` with a valid session cookie and `Origin: https://evil.example` because the server never inspected `Origin`. The session was the user's; the origin was the attacker's. The tool call executed under the user's authority. ## Condition of Validity The guardrail holds only under a conjunction, and each conjunct is independently violable: - **Canonical resource identifier is fixed and compared.** The server must define a single canonical `resource` URI (RFC 8707 resource indicator) and reject any token whose `aud` does not equal it. `aud` may be an array; membership must be exact string match against the canonical URI, not prefix or hostname-substring match (`mcp://tools.internal.evil` must fail). - **Token passthrough is prohibited at the transport layer.** An MCP server must never accept a token that was not issued *to it*. If the orchestrator needs to act on the user's behalf, it must obtain a **downscoped, audience-bound token** via token exchange (RFC 8693) with `audience=mcp://tools.internal` and a reduced scope. Forwarding the orchestrator's own token is the violation. - **Origin allowlist is enforced on every state-changing request and on the SSE/streaming handshake**, not just on the initial `POST`. The allowlist must be exact-match on scheme+host+port; `null` Origin must be rejected, not defaulted to allow. - **`Host` header is validated against the bound listener** to close DNS-rebinding, because `Origin` can be absent on non-browser clients and `Host` is the rebinding vector. If any conjunct is missing, the invariant is false and the server is a confused deputy. ## Decision Boundary The boundary is drawn as follows: - **Reject** when `aud` is absent, is a set not containing the canonical resource URI, or matches only by prefix/substring. Reject with `401` and `WWW-Authenticate: Bearer error="invalid_token", error_description="audience mismatch"` — *not* `403`, because the token is not authorized for this resource at all. - **Reject** when `Origin` is present and not in the allowlist, or is `null`, on any `POST`/`DELETE`/streaming `GET`. Return `403` with no body detail (do not leak the allowlist). - **Reject** when the server detects a token whose `iss` does not match the configured IdP *and* whose `aud` names an upstream agent — this is the passthrough signature. Log the `jti` and the presenting client identity. - **Allow** only when: signature valid ∧ `exp/nbf` valid ∧ `aud` exactly equals canonical resource URI ∧ required scope present ∧ `Origin` allowlisted (or absent *and* `Host` validated for non-browser clients) ∧ token was issued to this server (checked via `aud`, and optionally `azp`). The subtle boundary: a token with correct `aud` but wrong `Origin` is a **CSRF/rebinding** rejection (`403`), while a token with wrong `aud` is an **authentication** rejection (`401`). Conflating the two produces either over-permissive servers (treating audience failure as a soft warning) or unhelpful clients (retrying with the same passthrough token after a `403`). ## Operational Effect When the invariant is enforced, the orchestrator cannot silently escalate: it must perform token exchange, which produces an auditable `act` (actor) claim chain — the MCP server sees *both* the user and the orchestrator in the token, and can log the delegation. When the invariant is absent, the failure is **invisible in normal operation** and only manifests as an over-broad blast radius: any compromised orchestrator, or any prompt-injected tool call that induces the orchestrator to forward its token, executes with the orchestrator's full delegated scope against a resource that never consented to that delegation. The origin axis compounds it: without `Origin`/`Host` validation, a browser-resident agent session becomes a remote-controlled actuator. A single malicious page can drive `tools/call` against the user's authenticated session. The two failures chain: passthrough widens *what* can be called; missing origin validation widens *who* can call it. The operational repair is to treat `aud` and `Origin` as **hard preconditions in middleware, before any tool dispatch**, and to make audience mismatch a distinct, alertable error class — because a silent `200` is the actual danger. The code below encodes that precondition as a fail-closed check that raises rather than logs-and-continues. ```python import hmac from urllib.parse import urlparse class ResourceBindingError(RuntimeError): """Raised when a bearer token is not bound to this MCP resource, or when the request origin is not allowlisted. Fail-closed.""" CANONICAL_RESOURCE = "mcp://tools.internal" ALLOWED_ORIGINS = frozenset({ "https://orchestrator.example", "https://app.example", }) def _aud_matches(aud, canonical: str) -> bool: # aud may be a string or list; require EXACT membership, never prefix. if isinstance(aud, str): return hmac.compare_digest(aud, canonical) if isinstance(aud, (list, tuple)): return any(hmac.compare_digest(a, canonical) for a in aud) return False def enforce_resource_binding(claims: dict, origin: str | None, host: str | None) -> None: """Precondition gate for every HTTP-native MCP request. Must run BEFORE tool dispatch. Raises on any violation.""" aud = claims.get("aud") if not _aud_matches(aud, CANONICAL_RESOURCE): # Confused-deputy / token-passthrough signature. raise ResourceBindingError( f"audience mismatch: token aud={aud!r} does not name {CANONICAL_RESOURCE!r}; " f"refusing forwarded/passthrough bearer token (jti={claims.get('jti')!r})" ) if origin is None: # Non-browser client: Origin legitimately absent, but Host must be bound. if not host or urlparse(f"//{host}").hostname not in { "tools.internal", "localhost", }: raise ResourceBindingError( f"unbound Host header {host!r} with absent Origin; possible DNS rebinding" ) return if origin == "null" or origin not in ALLOWED_ORIGINS: raise ResourceBindingError( f"origin {origin!r} not in allowlist; refusing cross-origin MCP call" ) def handle_mcp_request(claims: dict, origin: str | None, host: str | None, tool: str) -> str: enforce_resource_binding(claims, origin, host) return f"dispatched {tool} under aud={CANONICAL_RESOURCE}" ```