Skip to content
RCE Write-up Advanced

From MCP to shell: MCP auth flaws enable RCE in Claude Code, Gemini CLI and more

MCP clients failed to validate the authorization URL supplied by an MCP server, allowing a malicious server to deliver a javascript: URL that executed arbitrary JavaScript in the client's browser. This XSS could be escalated to remote code execution on the user's machine by abusing local proxies or command injection in browser-launching code.

verialabs.com

Published on verialabs.com

During our security testing, we discovered that connecting to a malicious MCP server via common coding tools like Claude Code and Gemini CLI could give attackers instant control over user computers.

The author, on verialabs.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the MCP clients did not validate the scheme of the authorization URL provided by the server, allowing javascript: URLs to be opened and executed.

Impact

Attackers could achieve remote code execution on users' machines, potentially leading to full system compromise, though some defences like CSP blocked exploitation in ChatGPT.

What the attacker needed

Victim connects to malicious MCP server; vulnerable MCP client installed

The fix

The vulnerabilities were fixed by validating URL schemes, eliminating shell usage, and blacklisting dangerous URI schemes in the MCP TypeScript SDK.

How it was found

  1. Set up a malicious MCP server that returns a crafted authorization URL.
  2. Connect a vulnerable MCP client (e.g., Claude Code, Gemini CLI, or use-mcp) to the malicious server.
  3. The client opens the authorization URL, executing attacker-controlled JavaScript or commands.
  4. For RCE, the JavaScript steals the proxy authentication token and instructs the proxy to spawn a local command.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When you connect a coding tool to an MCP server, the server tells the tool where to send you for login. Many tools blindly trusted that address, so a malicious server could send a special link that runs harmful code in your browser. In some cases, that code could then run commands on your computer, letting an attacker take control.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.