Why does an instance accept an OAuth token minted for one MCP resource server and replay it against another tool endpoint?

**Date of Record:** 2026 December 1 **Scope:** Applies to MCP deployments where an agent obtains OAuth 2.1 access tokens from an authorization server (AS) and presents them to one or more MCP resource servers (RS) exposing tools. Does not cover opaque session cookies, mTLS-only deployments, or token exchange (RFC 8693) chains where the AS re-issues audience-scoped tokens per hop.

Core Distinction

The distinction that collapses here is between **token validity** and **token audience binding**. A JWT access token is *valid* if its signature verifies, its `exp`/`nbf`/`iat` are within tolerance, and its `scope` covers the requested operation. It is *bound* only if the RS it is presented to is named in the token's `aud` claim (or an equivalent resource indicator, per RFC 8707). OAuth 2.1 §2.1 and the MCP authorization spec both require the RS to enforce `aud` match. The failure mode is that most MCP tool servers validate the first three conditions and treat `aud` as advisory—or never see it, because the agent's MCP client library silently reuses a cached token across all configured servers.

An LLM agent is uniquely exposed to this because it does not have a stable "which server am I talking to" identity. Its tool-call planner selects tools by *name and description*, not by transport origin. When two MCP servers both expose a tool called `read_file` or `query_db`, the planner will treat them as interchangeable and the client will happily attach whatever bearer token is in its cache.

What Was Observed

A three-server MCP topology: `files-rs` (scope `files:read`), `db-rs` (scope `db:query`), and `admin-rs` (scope `admin:write`). A single AS issues per-RS tokens with correct `aud` values. The agent's MCP client maintains one token cache keyed by `(issuer, client_id, scope)` — *not* by resource.

Trace:

  1. Agent calls `files-rs.list_dir`. Client fetches token `T1` with `scope=files:read`, `aud=https://files-rs.internal`. Call succeeds.
  2. Agent's planner, mid-task, decides it needs `db.query`. It emits a tool call to `db-rs`.
  3. Client's cache lookup for `scope=db:query` misses, but the cache's fallback path returns the most-recently-used token when the scope set is a *subset* of a cached token's scope — a common optimization to avoid re-auth. Here `db:query ⊄ files:read`, so this path is skipped.
  4. However, the client also has a "same-issuer reuse" heuristic: if `T1.iss` matches the target RS's configured issuer, it attaches `T1` and lets the RS reject it. `db-rs` validates signature and `exp` — both pass — and checks `scope` against the tool's declared requirement. The `db.query` tool was declared with `required_scope: null` (an oversight in the tool manifest), so the scope check is a no-op.
  5. `db-rs` executes `db.query` under `T1`'s subject. The token's `aud` was never compared. The call succeeds with `files:read` privileges against the database.

The observable symptom is not an error. It is a *successful* cross-resource call logged with a token whose `aud` names a different server. Detection only occurs if the RS logs `aud` and an external auditor diffs it against the RS's own identity.

Condition of Validity

The invariant that must hold is: **for every tool invocation, `token.aud` MUST contain the canonical resource identifier of the RS receiving the call, and the RS MUST reject on mismatch with `401 invalid_token` and `WWW-Authenticate: error="invalid_token", error_description="audience mismatch"`.**

This invariant is *only* satisfiable when all three of the following hold simultaneously:

Break any one and the token becomes a bearer credential valid anywhere the AS's signature is trusted. The condition is fragile because each of the three is owned by a different party (agent runtime, AS operator, tool author) and none observes the others' configuration.

Decision Boundary

At the moment of tool dispatch, the agent runtime faces a binary decision it usually gets wrong:

The boundary is: reuse is safe iff the agent has *positive evidence* that the target RS enforces audience binding — e.g., the RS's `/.well-known/oauth-protected-resource` document declares `resource` and the RS has previously returned `invalid_token` on a mismatched `aud` probe. Absent that evidence, the runtime must re-authorize. An agent that cannot distinguish "RS enforces aud" from "RS ignores aud" must assume the latter.

Operational Effect

The downstream effect is **privilege confusion across tool boundaries**, and it compounds with the planner's name-based tool selection. Once a `files:read` token is accepted by `db-rs`, the agent's episodic memory records the call as successful under the `db.query` tool. On the next task, the planner retrieves that episode and treats `db.query` as reachable with the current credential set — a semantic distillation of a *false* capability. The agent will attempt `db.query` earlier and with less hesitation, and if the AS later rotates `T1` out of scope, the agent will fail at a point its memory says should succeed, producing a reasoning divergence it cannot localize.

The guardrail is a pre-dispatch audience check in the runtime, plus a manifest-level assertion that every tool declares a non-null `required_scope` and that the RS's protected-resource metadata names its own `resource` identifier. Both must be enforced at the client, because the RS cannot be trusted to enforce what it does not log.

import time
from dataclasses import dataclass
from typing import Optional


class AudienceBindingError(RuntimeError):
    """Raised when a token is presented to an RS it was not minted for."""


@dataclass(frozen=True)
class AccessToken:
    value: str
    issuer: str
    audience: tuple[str, ...]
    scopes: frozenset[str]
    expires_at: float


@dataclass(frozen=True)
class ResourceServer:
    resource_id: str          # canonical RFC 8707 identifier
    issuer: str
    enforces_audience: bool   # positive evidence from protected-resource metadata


def dispatch_tool_call(
    token: Optional[AccessToken],
    rs: ResourceServer,
    tool_required_scope: Optional[str],
    now: Optional[float] = None,
) -> str:
    now = now if now is not None else time.time()

    if token is None:
        raise AudienceBindingError("no token available for dispatch")

    if token.expires_at <= now:
        raise AudienceBindingError(f"token expired at {token.expires_at}")

    if token.issuer != rs.issuer:
        raise AudienceBindingError(
            f"issuer mismatch: token.iss={token.issuer} rs.issuer={rs.issuer}"
        )

    # The invariant: audience MUST name the receiving RS. Reuse across
    # resources is only permitted when the RS is known to enforce aud itself.
    if rs.resource_id not in token.audience:
        if not rs.enforces_audience:
            raise AudienceBindingError(
                f"token aud={token.audience} does not contain {rs.resource_id} "
                f"and {rs.resource_id} does not enforce audience binding; "
                f"refusing cross-resource reuse"
            )
        # RS enforces aud; it will reject. Do not pre-empt, but do not
        # treat success as evidence of capability.
        return f"deferred:aud_enforced:{rs.resource_id}"

    if tool_required_scope is None:
        raise AudienceBindingError(
            f"tool on {rs.resource_id} declares no required_scope; "
            f"cannot verify least-privilege"
        )

    if tool_required_scope not in token.scopes:
        raise AudienceBindingError(
            f"scope {tool_required_scope!r} not in token scopes {sorted(token.scopes)}"
        )

    return f"ok:{rs.resource_id}:{tool_required_scope}"


def run_dispatch_example() -> None:
    tok = AccessToken(
        value="eyJ...",
        issuer="https://as.internal",
        audience=("https://files-rs.internal",),
        scopes=frozenset({"files:read"}),
        expires_at=time.time() + 300,
    )
    db_rs = ResourceServer(
        resource_id="https://db-rs.internal",
        issuer="https://as.internal",
        enforces_audience=False,
    )
    # This is the exact failure the article describes: a files token
    # replayed against db-rs whose protected-resource metadata does not
    # advertise audience enforcement.
    dispatch_tool_call(tok, db_rs, tool_required_scope="db:query")


if __name__ == "__main__":
    run_dispatch_example()