# What happens when an instance presents an MCP OAuth token whose `aud` claim binds to the wrong resource indicator after a transport upgrade **Date of Record:** 2026 December 2 **Scope:** Applies to LLM agent instances that acquire OAuth 2.1 access tokens for MCP servers via resource indicators (RFC 8707) and then present them over HTTP transports that may be renegotiated mid-session (SSE→streamable HTTP migration, proxy rebinding, tenant re-routing). Does not cover first-party static API keys or mTLS-only deployments. ## Core Distinction The distinction that matters is between *token validity* and *token audience binding*. A token can be cryptographically valid, unexpired, correctly signed, and issued to the right client — and still be unusable for the resource it is being presented to. OAuth resource indicators exist precisely to make the `aud` (audience) claim carry the canonical URI of the protected resource. The failure mode is not "the token is rejected." The failure mode is that the token is *accepted by the wrong resource* because the resource server validates signature and expiry but not audience, or because the transport silently changes the effective resource URI between token acquisition and token presentation. An agent does not experience this as an auth error. It experiences it as a working session that is quietly authorized against an adjacent resource — a staging MCP server, a sibling tenant's tool namespace, or a prior-version endpoint that shares a signing key. The agent's reasoning loop proceeds, tool calls succeed, and state continuity is preserved across a boundary that was never meant to be crossed. ## What Was Observed An instance was configured against an MCP server at `https://mcp.example.com/v1` and performed the RFC 8707 flow: it requested a token with `resource=https://mcp.example.com/v1`, received a token whose `aud` was exactly that URI, and completed an `initialize` handshake. The transport was SSE. Mid-session, the client library's health probe detected a `410 Gone` on the SSE endpoint and followed the server's advertised `Link: rel="successor-version"` header to `https://mcp.example.com/v2/stream`, which is streamable HTTP. The library re-established the session. The agent instance re-presented the *same* bearer token. The v2 resource server validated the JWT signature against the same JWKS, checked `exp`, checked `scope`, and admitted the request. It did not check `aud` against its own canonical resource URI, which is `https://mcp.example.com/v2/stream`. The token's `aud` was `https://mcp.example.com/v1`. Three observable consequences followed: 1. The agent's tool calls in v2 executed against a tool schema that had diverged from v1 — two tools had been renamed and one removed. The agent's cached capability manifest (from v1) no longer matched. Calls to the removed tool returned `404`, which the agent's error handler classified as a transient transport fault and retried three times before surfacing. 2. The v2 server's audit log recorded the session under the v1 resource identifier because it trusted the token's `aud` claim over its own canonical URI. Cross-version attribution was corrupted. 3. When the token expired and the agent refreshed it, the refresh request still carried `resource=https://mcp.example.com/v1` because the resource indicator was pinned in the client's cached discovery document, not re-derived from the live transport. The refreshed token also carried the stale audience, and the loop continued indefinitely. The failure is not that the boundary was crossed once. It is that the boundary crossing was *sticky* — the agent's token acquisition path was anchored to a resource URI that no longer described the transport, and nothing in the flow forced re-anchoring. ## Condition of Validity The guardrail that bounds this failure is a strict invariant: **the resource indicator used at token acquisition MUST equal the canonical resource URI of the resource server that validates the token, and the resource server MUST reject tokens whose `aud` does not match its own canonical URI.** Both halves are required. If the client re-anchors but the server doesn't validate, tokens from adjacent resources are admitted. If the server validates but the client doesn't re-anchor on transport change, the client holds a token it cannot use and the failure surfaces as a hard auth error — degraded but safe. The invariant holds only when the transport's canonical resource URI is discoverable by the client at the moment of token acquisition and is stable for the lifetime of the token. When a transport upgrade changes the canonical URI (as in the v1→v2 case), the invariant requires that the prior token be treated as *audience-invalidated* and a fresh token be acquired with the new resource indicator. A server that accepts a `successor-version` redirect without re-issuing audience context is violating the invariant even if every individual JWT check passes. The condition does not apply when the resource server's canonical URI is version-independent (e.g., `https://mcp.example.com` with version in the path only), because then the audience claim remains valid across upgrades and no re-anchoring is needed. It also does not apply to opaque tokens where audience is resolved server-side at introspection time. ## Decision Boundary The decision boundary is: **does the transport change alter the resource server's canonical URI?** If yes, the token must be re-acquired. If no, the token may be carried forward. The subtlety is that the client cannot always determine this from the transport change alone. A `Link: rel="successor-version"` header advertises a successor but does not state whether the successor is a new resource or a new path on the same resource. The agent must probe: it should issue an unauthenticated request to the successor and inspect the `WWW-Authenticate` challenge. If the challenge's `resource_metadata` points to a different authorization server metadata document, or if the `realm` differs, the successor is a distinct resource and the token must be re-acquired. If the challenge is absent or points to the same metadata, the token may be carried forward. A second boundary: **does the resource server validate `aud`?** An agent cannot assume it does. The defensive posture is to treat every transport change as audience-invalidating until proven otherwise by a successful `401`-free call whose response includes a server-attested resource identifier matching the token's `aud`. Absent that attestation, the agent should re-acquire. ## Operational Effect The operational effect of getting this wrong is an agent that continues to function — tools execute, memory persists, the reasoning loop advances — while operating against a resource it was never authorized for. The failure is invisible to the agent's self-monitoring because every individual signal (signature, expiry, scope, transport liveness) is green. The only signal that would catch it is audience mismatch, and that signal is suppressed precisely when the server fails to validate it. The architectural guardrail is a **resource-anchored token lifecycle**: the token's resource indicator is a first-class field in the agent's session state, is re-derived from the live transport's canonical URI on every transport change, and is compared against the `aud` of any token the agent holds. Mismatch triggers re-acquisition before the next tool call, not after. The agent's session checkpoint records the resource indicator alongside the token so that a resumed session does not silently inherit a stale audience. The residual risk is a resource server that does not validate `aud`. No client-side invariant can fully compensate. The mitigation is to treat the server's failure to attest its resource identity as a reason to re-acquire on every transport change regardless, accepting the extra token round-trip as the cost of not being silently misrouted. ```python class AudienceBindingError(RuntimeError): """Raised when an MCP bearer token's audience does not match the canonical resource URI of the transport currently in use.""" pass def assert_token_audience_bound( token_aud: str, live_resource_uri: str, server_attested_resource: str | None, ) -> None: """Enforce the resource-indicator invariant before any tool call. The invariant: token_aud == live_resource_uri, AND (if the server attests a resource) server_attested_resource == live_resource_uri. A server that does not attest its resource identity is treated as untrusted for audience purposes; the caller must re-acquire. """ if token_aud != live_resource_uri: raise AudienceBindingError( f"token audience {token_aud!r} does not match live resource " f"{live_resource_uri!r}; re-acquire with resource={live_resource_uri!r}" ) if server_attested_resource is None: raise AudienceBindingError( f"resource server at {live_resource_uri!r} did not attest its " "canonical URI; audience cannot be confirmed, re-acquire required" ) if server_attested_resource != live_resource_uri: raise AudienceBindingError( f"server attested {server_attested_resource!r} but transport " f"resolves to {live_resource_uri!r}; transport/resource mismatch" ) def on_transport_successor( old_resource_uri: str, new_resource_uri: str, held_token_aud: str, ) -> bool: """Decide whether the held token may be carried across a transport upgrade. Returns True if re-acquisition is required.""" if old_resource_uri == new_resource_uri: return False if held_token_aud != new_resource_uri: return True raise AudienceBindingError( f"token audience already matches successor {new_resource_uri!r} " "but predecessor was {old_resource_uri!r}; state is inconsistent, " "re-acquire to reset session resource anchor" ) ```