Skip to content

fix(auth): stop leaking oauth client secrets (adopted from #327) - #333

Open
K4bain wants to merge 1 commit into
tadata-org:mainfrom
K4bain:fix/oauth-secret-leak
Open

fix(auth): stop leaking oauth client secrets (adopted from #327)#333
K4bain wants to merge 1 commit into
tadata-org:mainfrom
K4bain:fix/oauth-secret-leak

Conversation

@K4bain

@K4bain K4bain commented Aug 27, 2026

Copy link
Copy Markdown

Adopted from #327 (original patch by @failsafesecurity) — rebased onto current main and verified.

Why this is needed

setup_oauth_fake_dynamic_register_endpoint exists because npx mcp-remote (the de-facto MCP client) requires a dynamic client registration endpoint. Instead of implementing RFC 7591, it just echoes back the pre-registered client secret to whichever client calls it — meaning the secret the server owner configured for their OAuth provider is handed out to every MCP client that hits /oauth/register.

This PR registers the caller as a public client instead:

  1. Omit client_secret from the registration response (and response_model_exclude_none=True so it never appears in the payload).
  2. Force token_endpoint_auth_method to 'none' rather than echoing back whatever the caller requested — consistent with a public client that has no secret.

The client_secret parameter of the setup function is kept (unchanged signature) since it is still validated upstream by AuthConfig; it is simply no longer disclosed.

Verification

  • New regression test tests/test_auth_proxy.py: fails on current main (response payload contains the secret), passes with this fix.
  • Full unit suite: 70 passed (69 existing + 1 new).

Credit to @failsafesecurity for the original report and patch in #327.

…ation

The fake dynamic client registration endpoint echoed back the pre-registered
client_secret to any caller, exposing it to every MCP client. Register the
caller as a public client instead: omit client_secret from the response and
force token_endpoint_auth_method to none.

Adopted from tadata-org#327 (original patch by @failsafesecurity).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant