# What structural signals indicate an OAuth 2.1 resource-indicator binding failure when an MCP server's audience-restricted token survives a transport re-hop **Date of Record:** 2026 November 23 **Scope:** Applies to MCP servers that validate OAuth 2.1 access tokens carrying an `aud` (audience) claim bound to a specific resource indicator (RFC 8707), and to agent runtimes that relay or re-issue those tokens across transport hops (stdio→SSE, SSE→streamable-HTTP, or proxy-mediated A2A handoff). Does not apply to opaque bearer tokens with no audience binding, nor to same-process tool invocations that never cross a transport boundary. ## Core Distinction The failure mode is not "expired token" or "wrong scope." It is **audience-claim survival across a transport re-hop**: an MCP client acquires a token with `aud` set to resource indicator `R1` (the server the user authorized), then a transport upgrade or relay causes the token to be presented to resource indicator `R2`. Because OAuth 2.1 resource indicators are *advisory to the client* but *mandatory to the resource server*, the mismatch is only caught if `R2` actually validates `aud`. Many MCP servers validate signature and expiry but treat `aud` as informational. The boundary condition: **a token that is valid-but-wrong-audience is accepted by a permissive resource server and rejected by a strict one, and the two servers can be the same logical server behind different transport adapters.** The invariant that must hold: *the resource indicator embedded in the token's `aud` claim must equal the resource indicator the receiving MCP server advertises in its protected-resource metadata, at every hop, for the token's entire lifetime.* Any hop that re-presents the token without re-binding `aud` to the new resource indicator violates this invariant, and permissive validators will not signal it. ## What Was Observed Trace from a real relay: an agent runtime (client) performed the OAuth 2.1 authorization-code flow with `resource=https://mcp.example.com/sse` (R1). The authorization server issued a JWT with `aud: "https://mcp.example.com/sse"`, `exp` +3600s. The client opened an SSE session to R1, which upgraded mid-session to streamable-HTTP at `https://mcp.example.com/stream` (R2) — same host, different path, different advertised resource indicator in its `/.well-known/oauth-protected-resource` document. The client forwarded the same `Authorization: Bearer ` header to R2. R2's validator checked: signature ✓, `exp` ✓, `scope` ✓, `aud` — **not checked** (the validator's JWKS config omitted the audience constraint). The token was accepted. The session continued, tools executed, and a stateful MCP session (`Mcp-Session-Id`) was established under R2. Three structural signals were present but not surfaced: 1. **The `aud` claim value byte-for-byte did not match R2's advertised `resource` field.** R1's indicator ended in `/sse`; R2's ended in `/stream`. A strict equality check (not prefix, not host-only) would have failed closed. 2. **The `Mcp-Session-Id` was minted after the token was re-presented**, so session state was bound to a token whose audience was never re-validated against the new endpoint. Resuming the session later re-presented the same token to R2 — again accepted. 3. **The protected-resource metadata documents for R1 and R2 disagreed on `resource`**, but the client cached only R1's metadata at authorization time and never re-fetched on the transport upgrade. The client had no signal that R2 expected a different `aud`. The failure was silent for the token's full 3600s lifetime. It only became visible when a second, strict MCP server (R3, a different host) rejected the same token — at which point the agent runtime had already propagated the token into three downstream tool calls. ## Condition of Validity The invariant holds (i.e., the failure is bounded) only when **all three** of the following are true: - The receiving MCP server's token validator enforces `aud` with **exact string equality** against its own advertised `resource` indicator, and fails closed on absence of `aud`. Host-only or prefix matching is insufficient: `https://mcp.example.com/sse` and `https://mcp.example.com/stream` share a host. - The agent runtime re-fetches the protected-resource metadata of the *target* endpoint on every transport re-hop and confirms the token's `aud` matches before presenting it. Cached authorization-time metadata is not sufficient. - Token exchange (RFC 8693) or re-authorization is used to obtain a fresh token bound to R2, rather than forwarding the R1 token. Forwarding is only safe if R1 == R2 exactly. If any of these is false, the token is *valid-but-wrong-audience* and permissive validators will accept it. The condition of validity is therefore a property of the **validator's strictness and the client's re-binding discipline**, not of the token itself. ## Decision Boundary The decision boundary is the point at which the agent runtime must choose between **forwarding the existing token** and **performing a token exchange**. The rule: - If `token.aud == target.resource` (exact equality): forward. - If `token.aud != target.resource`: **do not forward**. Either (a) perform RFC 8693 token exchange to obtain a token with `aud = target.resource`, or (b) abort the hop and surface an `AudienceBindingError` to the orchestration layer. The boundary is *not* "same host" and *not* "same issuer." Two resource indicators on the same host with different paths are distinct audiences. The boundary is exact equality of the resource indicator string, evaluated at each hop, against freshly fetched metadata. A secondary decision boundary: when the MCP server's protected-resource metadata is unavailable or stale, the correct default is **fail closed** (reject the token) rather than **fail open** (accept on signature+expiry alone). Fail-open is the mechanism by which the observed failure propagated. ## Operational Effect The operational consequence of an unenforced audience binding is **silent privilege widening across transport hops**: a token authorized for one resource indicator is accepted by a sibling resource indicator, and any session state, tool grants, or downstream token propagation inherits that widened scope. Because the token is cryptographically valid, no signature or expiry alarm fires; the only detectable signal is the `aud`-vs-`resource` mismatch, which permissive validators discard. The guardrail that bounds this is a **two-sided check**: the resource server enforces exact `aud` equality and fails closed; the client re-fetches target metadata per hop and refuses to forward a token whose `aud` does not match, preferring token exchange or abort. Either side alone is insufficient — a strict server protects itself but not downstream hops; a strict client protects the chain but not against a misconfigured relay it does not control. Both must hold for the invariant to be preserved. The following reference implementation encodes the client-side decision boundary and the server-side fail-closed check as a single reusable validator, raising a typed error on any audience mismatch or missing audience. ```python import time from dataclasses import dataclass class AudienceBindingError(RuntimeError): """Raised when a token's aud claim does not exactly match the target resource indicator.""" pass @dataclass(frozen=True) class ProtectedResourceMetadata: resource: str # the resource indicator this server advertises issuer: str fetched_at: float # unix seconds; used to reject stale metadata @dataclass(frozen=True) class AccessToken: raw: str aud: str | None # exact resource indicator, or None if absent iss: str exp: float METADATA_MAX_AGE_S = 300.0 def _metadata_is_fresh(meta: ProtectedResourceMetadata, now: float) -> bool: return (now - meta.fetched_at) <= METADATA_MAX_AGE_S def validate_for_hop( token: AccessToken, target: ProtectedResourceMetadata, *, now: float | None = None, ) -> None: """ Enforce the audience-binding invariant at a single transport hop. Fails closed on: missing aud, stale target metadata, issuer mismatch, expired token, or any non-exact aud/resource match. """ now = time.time() if now is None else now if not _metadata_is_fresh(target, now): # Fail closed: we cannot confirm the target's expected resource indicator. raise AudienceBindingError( f"target metadata for {target.resource!r} is stale " f"({now - target.fetched_at:.0f}s old); refusing to forward token" ) if token.exp <= now: raise AudienceBindingError( f"token expired at {token.exp:.0f} (now {now:.0f})" ) if token.iss != target.issuer: raise AudienceBindingError( f"issuer mismatch: token.iss={token.iss!r} target.issuer={target.issuer!r}" ) if token.aud is None: # Absence of aud is not "wildcard"; it is unbound and must be rejected. raise AudienceBindingError( "token has no aud claim; unbound tokens are rejected at resource-indicator hops" ) if token.aud != target.resource: # Exact equality only. Same host, different path => different audience. raise AudienceBindingError( f"audience binding failed: token.aud={token.aud!r} " f"!= target.resource={target.resource!r}; " "perform RFC 8693 token exchange or abort the hop" ) def forward_or_exchange( token: AccessToken, target: ProtectedResourceMetadata, *, exchange_fn, now: float | None = None, ) -> AccessToken: """ Client-side decision boundary: forward iff aud matches exactly; otherwise attempt token exchange; if exchange cannot produce a bound token, raise. """ now = time.time() if now is None else now try: validate_for_hop(token, target, now=now) return token # safe to forward except AudienceBindingError: rebound = exchange_fn(token, target.resource) if rebound is None or rebound.aud != target.resource: raise AudienceBindingError( f"token exchange failed to bind aud to {target.resource!r}" ) from None validate_for_hop(rebound, target, now=now) return rebound ```