v0.15 is out: rules that were silently dropped on the shipped engine now run, and scans skip your test and mock files by default. Read more →
HIGH AI PREVALENCE: HIGH auth.py.mcp.token-audience-unchecked

This MCP server declares a resource_server_url but does not set validate_token_resource=True on AuthSettings.

Why AI tools produce this: AI coding tools generate this anti-pattern by default, it appears in a large share of AI-written auth code.

Why this matters

Per the MCP authorization spec an OAuth 2.1 resource server MUST reject a token that was not issued for it (RFC 8707 audience binding). Left unset, validate_token_resource behaves as False, so a token minted for a DIFFERENT resource is accepted here: a confused deputy (CWE-863), the exact class behind the MCP token reuse advisories.

Set it explicitly, and keep resource_server_url the exact URL clients connect to: AuthSettings( issuer_url=ISSUER, resource_server_url=THIS_MCP_URL, validate_token_resource=True, ) If your authorization server uses its own audience identifiers (an Auth0 API identifier, an Entra application ID), check aud in your TokenVerifier instead and return None for a token that is not for this server.

VULNERABLE
vulnerable.py
from mcp.server.auth.settings import AuthSettings

# ruleid: auth.py.mcp.token-audience-unchecked
settings = AuthSettings(
    issuer_url="https://auth.example.com",
    resource_server_url="https://mcp.example.com/mcp",
    required_scopes=["mcp:tools"],
)
SAFE
safe.py
from mcp.server.auth.settings import AuthSettings

# ok: auth.py.mcp.token-audience-unchecked
settings = AuthSettings(
    issuer_url="https://auth.example.com",
    resource_server_url="https://mcp.example.com/mcp",
    required_scopes=["mcp:tools"],
    validate_token_resource=True,
)

Suppressing this rule

If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.

# oauthlint-disable-next-line auth.py.mcp.token-audience-unchecked -- <reason>

References

https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization ↗https://datatracker.ietf.org/doc/html/rfc8707 ↗https://datatracker.ietf.org/doc/html/rfc9068 ↗