Add callback ids to local MCP OAuth redirects#20237
Add callback ids to local MCP OAuth redirects#20237stevenlee-oai wants to merge 1 commit intomainfrom
Conversation
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c128f82bdb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let mut origin = format!("{}://{host}", parsed.scheme()); | ||
| if let Some(port) = parsed.port() { | ||
| origin.push(':'); | ||
| origin.push_str(&port.to_string()); | ||
| } |
There was a problem hiding this comment.
Include endpoint path when deriving callback IDs
callback_id_from_server_url hashes only {scheme, host, port} and drops the MCP endpoint path. Two different MCP servers hosted on the same origin therefore receive the same callback path, so the redirect is no longer bound to a unique server identity. This weakens the stated OAuth mix-up mitigation for path-based multi-tenant deployments.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
this sounds useful? but I doubt the chance of collision is hight (multiple auth flow at the same time)
Summary
Context
That thread calls out the OAuth mix-up class of issue for MCP servers. The connector/App Connect flow already has a callback_id concept that binds the OAuth callback URL to the MCP app/server identity. Codex desktop's local MCP OAuth flow was still using a generic local callback path like
/callback, so this PR adds the same shape to the shared local MCP OAuth helper.Behavior
Before this change, local MCP OAuth used:
http://127.0.0.1:<port>/callback<configured callback URL>unchangedAfter this change, Codex appends a deterministic callback-id segment:
http://127.0.0.1:<port>/callback/<callback_id><configured callback path>/<callback_id>The local callback server already compares the incoming request path against the path from the redirect URI. By appending the callback id before both authorization and callback validation, callbacks that arrive on the old generic path or a mismatched callback-id path are rejected.
The change lives in
codex-rmcp-client, so it covers both the normal desktop MCP OAuth login path and silent/plugin-triggered MCP OAuth login paths that use the sameperform_oauth_login_*helpers.Scope and non-goals
issvalidation; issuer validation is still useful when providers returniss.Validation
cargo fmt --allcargo test -p codex-rmcp-client perform_oauth_login