Skip to main content

MCP SDK OAuth Clients Could Send Credentials to a Server-Chosen Authorization Server

· 8 min read
Ankush K
Co-founder and CTO, Dwaar
MCP SDK OAuth Clients Could Send Credentials to a Server-Chosen Authorization Server

Your agent holds a client secret for a real authorization server, and it connects to an MCP server. Which of the two decides where that secret goes? On affected versions of the official MCP SDKs, the MCP server could. The Python and TypeScript advisories published this week say so in their titles, and bumping the version does not finish the job.

At a glancePython SDKTypeScript SDK
IdentifierGHSA-qx49-fqc8-xw99GHSA-6qxp-vccf-f47h
Affectedmcp >= 1.9.1, < 1.30.0 and >= 2.0.0a1, < 2.2.0@modelcontextprotocol/sdk >= 1.12.0, < 1.31.0; @modelcontextprotocol/client >= 2.0.0, < 2.2.0
Fixed in1.30.0, 2.2.0sdk 1.31.0, client 2.2.0
Severity7.5 High (CVSS 3.1) in the project's GitHub advisory, no separate scorer named7.5 High (CVSS 3.1) in the project's GitHub advisory, no separate scorer named
Exploited as of 2026-09-30No public report found; not in CISA KEVNo public report found; not in CISA KEV
Disclosed2026-09-28; fix released 2026-09-072026-09-30; fix released 2026-09-28

Two defects, and not every version has both​

The metadata issuer was not always checked. The Python client accepted authorization server metadata without comparing its issuer to the URL the well-known document was built from. The Python advisory says 1.9.1 through 1.29.1 had "no issuer check and no credential binding on any path". Versions 2.0.0 through 2.1.1 lacked both only on the legacy fallback, used when a server publishes no protected resource metadata (PRM), and on a 403 insufficient_scope challenge. The advisory's range starts at 2.0.0a1 while its prose starts at 2.0.0, so treat the pre-releases as affected. The TypeScript advisory does not list this check as a defect, and the two TypeScript lines differ: 1.x does not compare the metadata issuer with the URL it was fetched from, while 2.x throws IssuerMismatchError unless skipIssuerMetadataValidation is set.

Credentials were not bound to an issuer. Both advisories describe this defect. On the 1.x lines, stored or pre-provisioned client IDs, client secrets and refresh tokens carried no record of who issued them, so they went to whichever authorization server the resource advertised next, or on the 2025-03-26 fallback to the resource server's own origin. TypeScript 2.x already had a binding, and its advisory limits 2.x exposure to gaps such as bundled providers without expectedIssuer and credentials stored without issuer. Machine-to-machine providers hold credentials the SDK never obtained, and as TypeScript PR #2887 puts it, "nothing but expectedIssuer says which authorization server they belong to". The Python equivalents had the same gap: ClientCredentialsOAuthProvider and PrivateKeyJWTOAuthProvider "used whichever authorization server discovery produced; nothing else in the flow can say which server issued those credentials", in the words of Python PR #3398.

The Python advisory describes two routes. A malicious or compromised server can name its own authorization server in its PRM. Or it can publish no PRM and serve metadata presenting your real authorization server as issuer, and its token endpoint "would then receive the client_secret, authorization code and PKCE code_verifier meant for that real server". With PrivateKeyJWTOAuthProvider, it gets a signed client assertion.

The TypeScript advisory adds the unattended case: a refresh_token and client_secret from an earlier sign-in, or a bundled provider's secret or assertion, could leave with no user interaction.

The fixes differ too. The Python fix decides the expected issuer before fetching metadata, rejects a mismatch and binds stored registrations to that issuer. The TypeScript fix records the authorization server as issuer on saved credentials and does not send them to a different one, but @modelcontextprotocol/sdk 1.31.0 still does not compare the metadata issuer with the URL it was fetched from.

Are you exposed?​

You need all of this: an HTTP MCP client, the SDK's OAuth client, credentials for a legitimate authorization server, and a possible connection to a server you do not fully trust. The Python advisory rules out MCP servers built with the SDK, stdio clients, and clients that attach their own tokens or headers.

My position: if users can add their own MCP server URL to your product, assume you are exposed. If your client only talks to one server you run, your risk is that server being compromised.

What to do now​

  1. Find it. Check lockfiles, not just direct requirements, for mcp, @modelcontextprotocol/sdk and @modelcontextprotocol/client.
  2. Upgrade. Python to mcp 1.30.0 or 2.2.0. TypeScript to @modelcontextprotocol/sdk 1.31.0 or @modelcontextprotocol/client 2.2.0, plus @modelcontextprotocol/core 2.2.0 if you import it directly.
  3. Pin the issuer on machine-to-machine providers. In Python, pass issuer="https://auth.example.com" to ClientCredentialsOAuthProvider and PrivateKeyJWTOAuthProvider, and move off the deprecated RFC7523OAuthClientProvider, which has no such option. Omitting it emits a deprecation warning, a DeprecationWarning hidden by default on 1.30.0, and it becomes required in 3.0. In TypeScript, pass expectedIssuer: 'https://auth.example.com' to ClientCredentialsProvider, PrivateKeyJwtProvider, StaticPrivateKeyJwtProvider and CrossAppAccessProvider.
  4. Fix what is already stored. Credentials saved before the upgrade stay unbound. In Python, clear stored client information once so the client registers again, or set issuer on records you pre-registered. In TypeScript, add issuer to saved credentials or clear them. A custom OAuthClientProvider must persist exactly what saveTokens() and saveClientInformation() receive, and, per the 1.31.0 release notes, storage that rejects unknown fields must allow issuer.
  5. Rotate where you cannot rule it out. If a client may have met an untrusted server, rotate its client secret or signing key and revoke its tokens. Neither advisory publishes indicators of compromise, so I would rotate rather than hunt.
  6. Know what the fix leaves open. The TypeScript fix does not cover new interactive sign-ins, direct refreshAuthorization() and exchangeAuthorization() calls, or 2.x with skipIssuerMetadataValidation: true. Remove that flag, and complete sign-ins only for servers you trust.

If you cannot upgrade yet, connect OAuth clients only to servers you trust. TypeScript 2.0.0 and 2.1.0 can already use expectedIssuer.

After upgrading, Python raises OAuthFlowError with "Authorization server metadata issuer mismatch", and in TypeScript 2.2.0 fetchToken() throws AuthorizationServerMismatchError before sending anything. Investigate that server.

An MCP server is not an identity authority​

In one client, this bug is one team's bad week. In the SDK's OAuth client, it is the default for every client built on it, including teams who chose the SDK so they would never have to think about this code.

The design error is about identity between agents and tools. The MCP server is where a credential gets used. It should have no say over where that credential gets sent. A long-lived agent secret already has a home, and the client holding it has to know that home itself.

A version check will not close this one. An SCA finding clears when the version moves, while an unpinned provider and an unbound stored credential remain. Treat issuer and expectedIssuer as configuration you audit, and add them to your MCP security checklist.

Read release notes for auth changes too. The Python change opened as a public hardening PR on 2026-08-26 and shipped on 2026-09-07 described as a behaviour change. The vulnerability label came three weeks later.

Today, open the code that constructs your MCP OAuth provider. Write down which authorization server each credential belongs to, then check that the code enforces it rather than asking the server.

References​