Stored MCP OAuth token is replayed to a repointed server URL with no URL check and no re-consent
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- authentication, security
Research direction
Start in packages/core/src/mcp/oauth-token-storage.ts: read saveToken() to see what mcpServerUrl is recorded and getCredentials(serverName) to confirm the URL is never read back. Then trace createTransport() in packages/core/src/tools/mcp-client.ts (~line 2312) and getValidTokenWithMetadata() in packages/core/src/mcp/oauth-provider.ts to see where the current url/httpUrl is still in scope, since the fix is to pass it down and compare. Done means a repointed server name no longer receives the stored token and the user is forced to re-consent, covered by a test alongside the existing MCP OAuth tests.
Written by the indexing model from the issue text.
Description
Stored MCP OAuth token is replayed to a repointed server URL with no URL check and no re-consent
Repo: google-gemini/gemini-cli
Summary
When gemini-cli reconnects to an HTTP MCP server, it replays the stored MCP OAuth access token to whatever URL is currently configured for that server name — with no check that the URL matches the URL the token was originally issued for, and no re-consent. The stored mcpServerUrl is recorded alongside the token at save time but is never compared against the current URL at reconnect time. If an attacker controls the new URL (via a trusted-workspace settings repoint, an extension update, or DNS/domain takeover of the original host), the victim's stored bearer token is sent to the attacker's server on CLI launch, and is valid at the legitimate MCP service and replayable there.
This is the access-token replay variant. It is distinct from the previously reported refresh-token variant, which was settled as a duplicate of CVE-2026-104850 / GHSA-6qxp-vccf-f47h (TS MCP SDK, fixed 1.31.0) — that variant is NOT part of this report.
Root cause
In packages/core/src/ (verified first-hand at repo HEAD cd1b45c):
tools/mcp-client.tscreateTransport()(:2312): ifMCPOAuthTokenStorage.getCredentials(serverName)returns anything, it attachesDynamicStoredOAuthProvider— with NO comparison of the storedmcpServerUrlagainst the currenturl/httpUrlanywhere in that branch.mcp/oauth-token-storage.tsgetCredentials(serverName)(:177): keyed by server name only, no URL parameter.saveToken()recordsmcpServerUrlalongside the token; nothing ever reads it back for comparison.mcp/oauth-provider.tsgetValidTokenWithMetadata(serverName, config)(:720): no URL parameter; returns the stored access token as-is when unexpired. The refresh path uses the STOREDtokenUrl/mcpServerUrlonly for the refresh call, then hands the fresh access token to the SDK, which sends it to the CURRENT URL.mcp/stored-token-provider.tstokens(): returns the stored/fresh access token; the refresh token itself is never sent to the new host — only access tokens leak.
So a stored token is bound to a server name, not to a server URL.
Reproduction (live proof, loopback only, fake token)
Build a small proof against the repo at HEAD cd1b45c, using the exported createTransport() + MCP SDK Client.connect():
- Store a fake OAuth token for a server named
victim-server, with storedmcpServerUrl=https://real-mcp.example.com/mcp. - Reconfigure the same server name to point at a local capture server (
http://127.0.0.1:<ephemeral>/mcp). - Connect. The capture server receives the stored token in the
Authorizationheader on the initialize POSTs.
Verbatim output (second independent live confirmation — the same script and command shape also confirmed it in an earlier run, identical 2/2 header capture):
Found stored OAuth token for server 'victim-server'
REQUESTS_SEEN: ["POST /mcp","POST /mcp"]
AUTH_HEADER_COUNT: 2
AUTH_PREFIX: Bearer TOKEN_MATCHES_STORED_FAKE: true TOKEN_LEN: 51
AUTH_PREFIX: Bearer TOKEN_MATCHES_STORED_FAKE: true TOKEN_LEN: 51
RESULT: REPOINT-CONFIRMED — stored token sent to repointed URL
No real credentials were used (fake token only), no real MCP service was contacted (loopback capture server only).
Preconditions (all required)
(a) The victim already holds a stored MCP OAuth token under that server name.
(b) The attacker controls the new URL — via a trusted-workspace .gemini/settings.json repoint (cloned repo + trust click), a model write in an already-trusted folder, an extension update changing a URL, or DNS/domain takeover of the original host.
(c) The victim launches the CLI in that folder context (startup auto-connects HTTP MCP servers).
Honest limits (please read before triaging)
- The proof is at the code-path level via exported
createTransport()+ MCP SDKClient.connect()— NOT a fullgeminibinary relaunch. - The token in the proof was unexpired, so the refresh leg (expired token → refresh against the stored tokenUrl → fresh access token sent to the repointed URL) was NOT executed live; its code path was re-read first-hand but not executed.
- The refresh token is NOT sent to the new host — only access tokens leak.
- Token scope is whatever the legitimate MCP service grants that token (service-dependent).
- There is NO proof here that workspace settings alone can repoint without trust (workspace settings are emptied when untrusted); that gating was re-read from code, not re-tested live.
- The vulnerable path is still present at upstream HEAD
d4cb1713f(2026-11-19): the latest commit touchingoauth-token-storage.tsis 2026-09-11 and the latest touchingmcp-client.tsis 2026-10-20, both predating the local HEAD — no change to either file between local HEAD and upstream HEAD.
Severity
High-candidate credential theft / token replay (Medium-to-High in VRP terms, depending on the MCP service's token scope). It is NOT RCE and NOT payload-run class — no code execution is shown, and it should not be presented as such. The natural fix is to bind the stored token to its URL: compare the stored mcpServerUrl against the current URL at reconnect time and require re-consent (or re-authentication) when it differs.
Dup-screen note
Fresh searches on 2026-11-21 (this issue's filing day) in google-gemini/gemini-cli for the repoint-replay shape (mcp oauth token url repoint, mcpServerUrl, stored token repointed URL MCP) returned no matching open or closed issue. The closest results are all auth-flow-time or different defects: #15289 (OAuth resource validation at auth time), #20017 (auth-flow origin check), #18851 (auth-flow URL comparison), #18132 (consent at initial OAuth), #29081 (SSRF in OAuth metadata discovery), #29079 (MCP server command not validated), #28128 (cross-server resource URI confusion), #26785 (SSRF via unvalidated MCP server URLs), #26832 (unauthenticated MCP metadata access). None describes a stored token being sent to a changed URL without re-consent.
- Dominant language
- TypeScript
- Stars
- 109k
- Forks
- 15k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 106
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google-gemini/gemini-cli
-
status/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google-gemini/gemini-cli#30412 · 1 comment ·
Maintainers usually reply within 1 day
-
--acp never answers initialize when a sandbox is enabled (stdin read as a piped prompt before the sandbox hop)Possibly taken @Raamia claimed this 1 day ago. Openstatus/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
google-gemini/gemini-cli#30398 · 2 comments ·
Maintainers usually reply within 1 day
-
** Docs: `/shells` slash command (and `/bashes`) is documented but was removed in #22740 — tutorial and tip tell users to run a command that doesn't existPossibly taken @DZH166 claimed this 1 day ago. Openstatus/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
google-gemini/gemini-cli#30396 · 2 comments ·
Maintainers usually reply within 1 day
-
** Docs: System Prompt Override guide links "Persisting Environment Variables" to an anchor that does not exist in authentication.mdxPossibly taken @DZH166 claimed this 2 days ago. Openstatus/need-triage
Difficulty 1/5 Under an hour Newbie friendliness 82/100
google-gemini/gemini-cli#30394 · 2 comments ·
Maintainers usually reply within 1 day
-
core tests: orphan PTY slave fd test fails on Macs where /dev/ttys001 existsPossibly taken @Anoshor claimed this 2 days ago. Openstatus/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
google-gemini/gemini-cli#30384 · 2 comments ·
Maintainers usually reply within 1 day
All issues in google-gemini/gemini-cli
Similar issues
-
qa-manually-tested Status: Triage Type: Bug / Error
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
mermaid-js/mermaid-v13#1158 ·
Maintainers usually reply within 1 day
-
Bug Daily
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Expensify/App#107705 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Changing shipping to country value from storefront homepage creates an invalid URLPossibly taken @Riamus78 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
medusajs/dtc-starter#106 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
digitalfabrik/integreat-app#4558 ·
Maintainers usually reply within 5 days
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
redhat-developer/podman-desktop-ibmcloud-account-ext#755 ·
Maintainers usually reply within 1 day