MCP TypeScript SDK: OAuth client could send credentials to an authorization server chosen by the MCP server
Affected releases · @modelcontextprotocol/client
- 2.x2.0.0 – 2.1.0Fixed in 2.2.0
On 2.x, the newest line:
npm install @modelcontextprotocol/client@2.2.0Affected
2.0.0 – 2.1.0
2 releases
Fixed
2.2.0 – 2.3.1
3 releases, latest
Affected releases · @modelcontextprotocol/sdk
- 1.x1.12.0 – 1.30.1Fixed in 1.31.0
On 1.x, the newest line:
npm install @modelcontextprotocol/sdk@1.31.0Not affected
0.4.0 – 1.11.5
33 releases
Affected
1.12.0 – 1.30.1
46 releases
Fixed
1.31.0 – 1.32.1
3 releases, latest
Is your project affected?
Paste your package.json, or type the range you declare for @modelcontextprotocol/client. It is read in your browser and sent nowhere.
Is your project affected?
Paste your package.json, or type the range you declare for @modelcontextprotocol/sdk. It is read in your browser and sent nowhere.
What happens
Summary
In affected versions, the SDK's OAuth client let the MCP server decide which authorization server received the client's OAuth credentials. Credentials were not tied to the authorization server they belong to.
A malicious or compromised MCP server could name its own authorization server. With no user interaction, the client would send it:
the
refresh_tokenandclient_secretstored from an earlier sign-inthe
client_secretor signed assertion configured on a bundled provider
Am I affected?
Yes, if both of these hold:
your application uses the SDK's OAuth client over HTTP, through any of:
an
authProvideron a transportthe
withOAuth()middlewaredirect calls to
auth()orfetchToken()
it may connect to an MCP server you do not fully trust while holding credentials for a legitimate authorization server
Affected versions:
@modelcontextprotocol/sdk1.12.0 through 1.30.1@modelcontextprotocol/client2.0.0 through 2.1.0, only for:bundled providers without
expectedIssuercredentials stored or supplied without
issuerdirect calls to
fetchToken()providers that read storage back through
OAuthTokensSchemaorOAuthClientInformationSchema
Not affected:
MCP servers built with the SDK
stdio clients
Fix
Upgrade to:
1.x:
@modelcontextprotocol/sdk1.31.0 or later2.x:
@modelcontextprotocol/client2.2.0 or later, and@modelcontextprotocol/core2.2.0 or later if you import it directly
The client now records the authorization server as issuer on saved credentials and does not send them to a different one. The user signs in again, or the call throws.
In the following cases, upgrading to the patched version is not enough. You also need to make a change:
Bundled providers (
ClientCredentialsProvider,PrivateKeyJwtProvider,StaticPrivateKeyJwtProvider,CrossAppAccessProvider): passexpectedIssuer, for exampleexpectedIssuer: 'https://auth.example.com'. Without it they still use whichever authorization server the MCP server names.Credentials saved without
issuer: tokens and client information yourOAuthClientProviderpersisted (file, keychain, database) before upgrading, including everything 1.x saved before 1.31.0. They still go to whichever authorization server is named at first use. Addissuerto them, or clear them so users sign in again.Your own
OAuthClientProvider: save exactly whatsaveTokens()andsaveClientInformation()are given, includingissuer. For pre-registered credentials, includeissuerin whatclientInformation()returns.
Not covered by this fix:
a new interactive sign-in, which still goes to the authorization server the MCP server names. Only complete sign-ins for servers you trust.
refreshAuthorization()andexchangeAuthorization()called directly2.x with
skipIssuerMetadataValidation: true
If an affected client may have connected to an untrusted MCP server, rotate its client secret or signing key and revoke its tokens.
If you cannot upgrade yet, connect OAuth clients only to MCP servers you trust. 2.0.0 and 2.1.0 already accept expectedIssuer.