MCP SDK OAuth Flaw: A Malicious Server Could Choose Where the Client Sends Its Credentials
The official Python and TypeScript SDKs for the Model Context Protocol (MCP, the open protocol AI applications use to connect to external tools and data) include an OAuth client. In affected versions, the MCP server being connected to decided which authorization server (the service that signs users in and issues tokens) received the client's credentials. Two maintainer advisories say a malicious or compromised MCP server could therefore collect a client secret, a stored refresh token, an authorization code or a signed client assertion meant for the legitimate authorization server. Upgrading is required but not sufficient: some providers and previously stored credentials also need an explicit issuer. There is currently no public evidence that this technique has been used in a real attack.
Threat Analysis
- The server decided where credentials went: An MCP client that signs in with OAuth learns which authorization server protects the MCP server from that server's protected resource metadata, a public document the server publishes for this purpose. It then reads that authorization server's metadata to find its
issuer(the URL that identifies it) and its token endpoint, where credentials are exchanged for tokens. According to the Python SDK advisory, the affected client did not validate the metadataissueron every discovery path and did not bind stored or pre-provisioned credentials to the authorization server they belong to. For example, a service holding aclient_secret(the password a client uses to prove its identity to an authorization server) issued byhttps://auth.example.comconnects tohttps://mcp.attacker.example, whose metadata nameshttps://login.attacker.example. The client then posts its token request, secret included, to that host. These addresses are invented to show the sequence. - Python SDK, two ways to steer the client: The MCP server either names its own authorization server in its protected resource metadata, or publishes none and serves metadata that presents the user's real authorization server as the issuer. It would then receive the
client_secret, the authorization code (the one-time code an authorization server returns after the user signs in) and the PKCEcode_verifier(the random value a client must present to redeem that code) meant for the real server. WithPrivateKeyJWTOAuthProviderit would receive a signed client assertion instead, a JWT the client signs with its private key in place of a secret. - TypeScript SDK, no user action needed: The TypeScript advisory states that once the MCP server names its own authorization server, the client would send it, with no user interaction, the
refresh_token(used to obtain new access tokens without a new sign-in) andclient_secretstored from an earlier sign-in, or theclient_secretor signed assertion configured on a bundled provider. This applies to anauthProvideron a transport, thewithOAuth()middleware, and direct calls toauth()orfetchToken(). - Affected versions and conditions: An application is affected when it uses the SDK's OAuth client over HTTP and may connect to an MCP server it does not fully trust while holding credentials for a legitimate authorization server. Python
mcp, withOAuthClientProvider,ClientCredentialsOAuthProvider,PrivateKeyJWTOAuthProvideror the deprecated 1.xRFC7523OAuthClientProvider: 1.9.1 (inclusive) to 1.30.0 (exclusive), and 2.0.0a1 (inclusive) to 2.2.0 (exclusive). Releases 1.9.1 through 1.29.1 had neither check on any path. For 2.0.0 through 2.1.1 the advisory says both were missing when the server publishes no protected resource metadata or answers403 insufficient_scope. On both lines and every path,ClientCredentialsOAuthProviderandPrivateKeyJWTOAuthProviderhad no way to name the authorization server their credentials belong to. TypeScript:@modelcontextprotocol/sdk1.12.0 (inclusive) to 1.31.0 (exclusive), and@modelcontextprotocol/client2.0.0 (inclusive) to 2.2.0 (exclusive) only for bundled providers withoutexpectedIssuer, credentials stored or supplied withoutissuer, directfetchToken()calls, and providers that read storage back throughOAuthTokensSchemaorOAuthClientInformationSchema. MCP servers built with the SDKs and stdio clients (which talk to a local server process instead of HTTP) are not affected. The Python advisory also excludes clients that attach their own tokens or headers. - What the fixes change, and what stays with you: The fixed releases are
mcp1.30.0 and 2.2.0,@modelcontextprotocol/sdk1.31.0 and@modelcontextprotocol/client2.2.0. The Python client now determines the issuer it expects before fetching any authorization server metadata and refuses a mismatch withOAuthFlowError. The TypeScript client recordsissueron saved credentials and will not send them to a different authorization server. Both advisories say upgrading is not enough in specific cases. Providers configured with a secret or signing key still follow the server-named authorization server until the expected issuer is passed in code. Credentials stored without an issuer, including everything the 1.x lines saved before the fix, stay unbound. A custom TypeScriptOAuthClientProvideralso has to store theissuerit is given. The TypeScript fix does not cover a new interactive sign-in, which still goes to the authorization server the MCP server names, directrefreshAuthorization()orexchangeAuthorization()calls, or 2.x withskipIssuerMetadataValidation: true. - Identifiers and evidence status: A CVE is a public identifier for a disclosed security vulnerability. The Python flaw is CVE-2026-115563 (GitHub advisory GHSA-qx49-fqc8-xw99) and the TypeScript flaw is CVE-2026-104850 (GHSA-6qxp-vccf-f47h). Both are rated High, with a CVSS 3.1 score of 7.5. The Python advisory notes that the score is for unattended providers and gives 6.5 for the interactive
OAuthClientProvider, where a person has to start the sign-in. Both advisories were published by maintainer maxisbey. The Python advisory credits reporters Aviral2642, AlexMelanFromRingo, Gal3m, mrostamipoor, YuvalElbar6, yuvalelbar, RoniGurvich and mahmoudalbustan1. The TypeScript advisory credits Aviral2642, AlexMelanFromRingo, Gal3m, JosephDoUrden, Igfray, OriginalKazdov and lwebmedia. There is currently no public evidence that this technique has been used in a real attack. First-hand sources: Python SDK advisory and TypeScript SDK advisory.
Applicable AIDEFEND Defenses (6)
What Defenders Should Do Now
- Find every place the SDK runs as an OAuth-enabled MCP client over HTTP (desktop apps, agent runtimes, backend services, CI jobs) and read the installed version from the running environment, not the version range in the manifest. Pass condition:
mcpis 1.30.0 or later on 1.x, or 2.2.0 or later on 2.x;@modelcontextprotocol/sdkis 1.31.0 or later;@modelcontextprotocol/clientis 2.2.0 or later, with@modelcontextprotocol/coreat 2.2.0 or later if you import it directly. - Set the expected issuer on every provider that carries a secret or signing key. In Python, pass
issuer=toClientCredentialsOAuthProviderandPrivateKeyJWTOAuthProvider, and replaceRFC7523OAuthClientProvider, which has no issuer option, with one of those two. On 1.30.0 a missing issuer only raises aDeprecationWarningthat Python hides by default, so run tests with deprecation warnings shown and treat that warning as a failure. In TypeScript, passexpectedIssuertoClientCredentialsProvider,PrivateKeyJwtProvider,StaticPrivateKeyJwtProviderandCrossAppAccessProvider, removeskipIssuerMetadataValidation: true, and confirm that direct calls torefreshAuthorization()orexchangeAuthorization()can only target an issuer your configuration approves. - Deal with what is already stored. In Python, clear stored OAuth client information once so the client registers again; for a pre-registered client you placed in storage yourself, set
issueron that record instead. In TypeScript, addissuerto tokens and client information persisted to a file, keychain or database before the upgrade, or clear them so users sign in again. A customOAuthClientProvidermust save exactly whatsaveTokens()andsaveClientInformation()are given, includingissuer, and pre-registered credentials needissuerin whatclientInformation()returns. Pass condition: no stored token or registration record lacks an issuer. - Verify the result in an isolated test environment. Run a test MCP server that names a different authorization server (for Python, add the case that publishes no protected resource metadata while claiming your real issuer), and connect each client build using synthetic secrets, fake credentials created only for testing. Pass condition: the test token endpoint receives no secret, refresh token, authorization code or assertion, and the client raises an error or asks the user to sign in again. This test is our recommendation; the advisories do not describe running one.
- Until every client is fixed, connect OAuth-enabled clients only to MCP servers on an approved list, and keep that rule for interactive sign-ins after the upgrade. If an affected client may have connected to an MCP server you do not trust, rotate its client secret or signing key and revoke its tokens at the authorization server. This is a precaution based on possible exposure. The advisories are not evidence that any client was compromised.
1 additional consideration
Refresh token rotation with reuse detection
Conclusion
Last updated: