# OpenCode on Windows and WSL ran commands from a malicious MCP server during OAuth sign-in

Source: https://botpassword.com/incidents/2026-10-opencode-mcp-oauth-rce
Disclosed: 2026-10-04 · Type: AI agent · Status: Resolved · Updated: 2026-10-25

Pillar Security disclosed that OpenCode 1.0.137 through 1.18.32 passed the OAuth authorization URL supplied by a remote MCP server to a browser launcher that, on Windows and WSL, built a PowerShell command without escaping it. A hostile or later-compromised MCP server could therefore run code on the developer's machine when they signed in with `opencode mcp auth`. The fix shipped in 1.18.33 on 28 September 2026 without an advisory or CVE, so scanners will not flag old installs; update and remove MCP servers you have not vetted.

## What was exposed

Code execution with the developer's privileges, and so every credential the user account can read: model provider API keys stored by OpenCode, MCP server tokens, Git and cloud credentials, SSH keys and `.env` files. Pillar explains the mechanism: during MCP OAuth, OpenCode reads the `authorization_endpoint` from the server's discovery document and passed it unchecked to the `open` package (version 10.1.2). On Windows, `open` builds a PowerShell `-EncodedCommand`, and PowerShell expands a `$(...)` subexpression inside the double-quoted target, so an otherwise valid `https://` URL can carry a command. Scheme validation does not stop it. No prompt injection or extra user action beyond the normal sign-in is needed. macOS and Linux are not affected because their launchers do not pass the URL through a shell. Pillar's proof of concept writes a file; it reports no exploitation in the wild and proposes CVSS 9.8.

## Who is affected

You are affected if you ran OpenCode 1.0.137 through 1.18.32 on Windows or inside WSL, had a remote MCP server configured, and started its OAuth sign-in (for example `opencode mcp auth`). A server that was trustworthy when you added it still matters, since its domain or deployment could later change hands. Run `opencode --version` and `opencode mcp list` to see your version and configured servers. Because there is no CVE or advisory, dependency scanners will not report this; check installs directly.

## What to do

1. Update OpenCode to 1.18.33 or later.
2. If you cannot update on Windows or WSL, remove remote MCP servers you have not vetted from your configuration.
3. If you signed in to an unfamiliar MCP server on an affected version, rotate the provider API keys and tokens stored on that machine.
4. Inventory OpenCode installs across developer machines directly, since scanners rely on advisories that do not exist for this issue.

## Keys to rotate

- [Anthropic](https://botpassword.com/keys/anthropic)
- [OpenAI](https://botpassword.com/keys/openai)
- [GitHub](https://botpassword.com/keys/github)

## Timeline

- 2026-08-29: Pillar Security reports the issue privately through a GitHub security advisory. ([source](https://www.pillar.security/blog/open-and-shut-remote-code-execution-in-opencode-via-mcp-oauth))
- 2026-09-25: The fix (PR #51414) is merged; Pillar says the vendor stated that malicious MCP servers fall outside its threat model. ([source](https://www.pillar.security/blog/open-and-shut-remote-code-execution-in-opencode-via-mcp-oauth))
- 2026-09-28: OpenCode 1.18.33 is published to npm. ([source](https://www.npmjs.com/package/opencode-ai?activeTab=versions))
- 2026-10-04: Pillar's timeline gives this as the publication date of the research; the article byline shows 19 October 2026. ([source](https://www.pillar.security/blog/open-and-shut-remote-code-execution-in-opencode-via-mcp-oauth))

## Indicators

- An MCP OAuth discovery document whose `authorization_endpoint` contains `$(` or other PowerShell syntax.
- OpenCode versions 1.0.137 through 1.18.32 on Windows or WSL.

## Sources

- https://www.pillar.security/blog/open-and-shut-remote-code-execution-in-opencode-via-mcp-oauth
- https://www.npmjs.com/package/opencode-ai?activeTab=versions
