GUIDE · MCP 10 min ·

An MCP server's login URL became a PowerShell commandopencode, Copilot and the client launch path

A remote MCP server could run code on a Windows opencode user's machine by naming a crafted login URL during the OAuth handshake. The URL was plain https, so scheme checks let it through. opencode fixed it in 1.18.33 without a CVE, so no scanner will tell you which installs still need the upgrade.

TL;DR· the answer, in twenty seconds

What happened: opencode 1.0.137 through 1.18.32 on Windows and WSL handed a login URL chosen by a remote MCP server to a launcher that built a PowerShell command from it. A plain https URL carrying $(...) ran code. The fix shipped in 1.18.33 as a refactor, with no CVE and no advisory.

The minimum fix: Upgrade opencode to 1.18.33 or later and patch Visual Studio and SSMS for CVE-2026-103572. Find the opencode installs by asking each host for its version, because no scanner has a record to match.

The lesson: An MCP client parses server data long before the model sees it. Any field the server controls, a URL included, can reach a shell or a config file unless the client passes it as an argument and binds it to an origin the operator chose.

A remote MCP server could run code on a Windows or WSL machine running opencode by returning a crafted login URL during the OAuth handshake, and the fix shipped in September as a refactor with no CVE attached.

Pillar Security reported the bug to Anomaly, the company behind opencode, through a GitHub Security Advisory on August 29, 2026. Pillar's proposed rating is 9.8. Affected versions run from 1.0.137 to 1.18.32 on Windows and WSL. Version 1.18.33, released September 28, fixes it. macOS and Linux were never affected, because the launcher on those platforms does not pass the URL through a shell.

The bug needs no prompt injection and no malicious package on disk. The attacker runs an MCP server, and the victim adds its URL to their config. Everything after that happens inside client code the model never touches.

A second bug from the same season shows the same shape from another angle. Johann Rehberger found that prompt injection could make Copilot in Visual Studio and SQL Server Management Studio write a new MCP server into its own config, which Microsoft patched on October 13 as CVE-2026-103572. In one case the server supplies the payload. In the other the model writes the launch config. Both end with code running as the developer.

How a login URL reached PowerShell

MCP's authorization spec uses OAuth. When a remote server wants the user to sign in, it answers a request with HTTP 401 and a WWW-Authenticate header that points at its discovery documents. The client fetches those documents and reads, among other fields, authorization_endpoint: the page where the user logs in. The server under authentication writes that field. It is a free-form string.

In opencode 1.18.32, Pillar traced that string along this path: the server's discovery document, the MCP TypeScript SDK, opencode's oauth-provider.ts, mcp/index.ts, browser.ts, then a call to open() from the open npm package. Pillar found no scheme check and no comparison against the origin of the server the user had configured. The call to open(authorizationUrl) arrived in commit 509e43d6 on December 7, 2025.

The open package launches a browser. On macOS it runs open and on Linux xdg-open, both through spawn with an argument array, so no shell parses the URL. Windows takes a different path. In open@10.1.2, the version every affected opencode release pinned, the code builds a PowerShell command, encodes it as UTF-16LE base64, and runs it with powershell -EncodedCommand. Pillar quotes the two relevant lines:

// open@10.1.2, Windows branch, as quoted by Pillar Security
encodedArguments.push(`"\`"${app}\`""`);      // app gets escaped
encodedArguments.push(`"${options.target}"`);  // target does not
options.target = Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');
// later: powershell -EncodedCommand <that base64>

PowerShell expands $(...) inside double-quoted strings. The target, the URL, sits in double quotes with nothing escaped. So a discovery document that names this as its authorization endpoint runs the code in the subexpression:

https://evil.test/$([IO.File]::WriteAllText('C:\Users\Public\pwned.txt','RCE'))

PowerShell evaluates the subexpression before it resolves the command. The browser launch then fails, opencode discards the error, and the file is already on disk.

Sources disagree on what the user has to do first. The Hacker News frames it as code execution "during sign-in", which reads as the user starting the OAuth flow. Pillar writes that "the whole handshake is automatic", since the point of the flow is to open the login page without making anyone copy a URL. The Cloud Security Alliance suggests a score near 8.8 if the attack needs user interaction. I have not reproduced it, so I can't settle which is right. Treat it as one connection away from code execution either way. Adding a server you would never sign in to is rare.

None of the reports I read mention exploitation in the wild.

Why https checks let it through

The standard defense for this bug class is scheme validation: allow http: and https:, reject the rest. It became the standard after CVE-2025-6514, which JFrog published in July 2025. That bug sat in mcp-remote, a proxy that lets local MCP clients reach remote servers, and it had the same sink: an authorization endpoint from the server, handed to open(). JFrog rated it 9.6, and mcp-remote 0.1.16 fixed it.

JFrog's payload used a made-up scheme, a:$(cmd.exe /c whoami ...), for a reason Pillar explains. The command had spaces, and the WHATWG URL parser percent-encodes spaces in an https URL, which breaks the PowerShell expression. An unknown scheme avoided that normalization. So the lesson MCP client authors took was "block odd schemes".

Pillar's payload has no spaces. It is a well-formed https URL, and it passes every scheme check involved:

  1. The MCP TypeScript SDK blocks javascript:, data: and vbscript:. PR #877 added that denylist in v1.17.4 in August 2025. A PR opened on August 5, 2025 proposed an http/https allowlist, and the maintainers closed it without merging. Pillar says SDK 1.32.0 still uses the three-scheme denylist.
  2. The stricter allowlist the SDK rejected would also have passed it, because the scheme is https:.
  3. The new openUrl() scheme check opencode added in 1.18.33 passes it too.

What fixed opencode was the dependency bump. PR #51414, merged September 25 as commit 29f07e0c, moved open to 11.0.4. open@11.0.0, released November 15, 2025, fixed the PowerShell escaping, and 11.0.4 wraps the target in single quotes, where PowerShell expands nothing. The PR also added the scheme checks, in openUrl() and in redirectToAuthorization. Those are worth having. They are not what stopped the payload.

The open maintainers knew about the expansion for years. Issue #202, filed in 2020, reported that a URL with $ in it broke on WSL 2. Issue #323, filed in October 2023 under the title "OS command injection on windows when opening urls", carried a one-line proof of concept: a call to open() with an https URL whose host was $(calc.exe). The reply quoted the README: the package makes no security guarantees, and sanitizing untrusted input is the caller's job. That README line dates from September 2021. It is a fair contract for a launcher. It means every caller that passes a remote string to open owns the bug.

If you added scheme validation after CVE-2025-6514 and still ship open 10.x or older, Pillar's payload still works against you.

A fix with no CVE

Anomaly fixed the bug in four weeks and in three layers, which is more than the report asked for. It also declined to treat it as a vulnerability. Pillar quotes Anomaly's reply: "trying to deal with a malicious MCP server is outside our threat model." opencode's SECURITY.md puts user-configured MCP servers "outside our trust boundary." PR #51414 describes itself as consolidating eight browser-launch call sites. Neither it nor the release notes mention security, and Anomaly requested no CVE.

I disagree with the position, and the reason is practical. A threat model that excludes malicious servers works when the client treats server output as untrusted data. It fails when the client hands a server field to a shell. A user who adds a server to try it out has not agreed to let it run code. A server sends two kinds of data: tool output, which the model reads, and protocol metadata such as discovery documents, which the client acts on. The opencode bug lived in the second kind, where no model judgment applies.

The cost of shipping without a CVE falls on defenders. Dependabot, npm audit, Snyk and most SBOM scanners match package versions against advisory records. With no record, nothing matches, so a host still on opencode 1.18.32 looks clean. Anyone who diffs v1.18.32...v1.18.33 can rebuild the exploit, and the people responsible for the fleet get no alert. Pillar published to close that gap. Its timeline dates the write-up to October 4. The Hacker News and CSA covered it later in October.

The Copilot bug wrote its own launch config

CVE-2026-103572 reaches code execution by another route. Rehberger reported it on August 4. Microsoft confirmed it on September 16, rated it Important with a CVSS score of 8.8, paid no bounty, and shipped the fix in the October 13 Patch Tuesday. It affects GitHub Copilot in Visual Studio 2022 and 2026 and in SQL Server Management Studio.

Copilot asks for confirmation before its agent edits sensitive files such as .mcp.json. The check lives in EditsFunctionHandler.GetEditConfirmationTypeAsync and compares file names. Rehberger asked for an edit to .mcp.json., with a trailing dot. The string does not match .mcp.json, so no prompt appears. Win32 file APIs strip trailing dots on write, so the edit lands on .mcp.json. A second bypass used ..\ segments in paths that start inside the trusted Extensions directory. That let the agent read SSMS.isolation.ini, which holds the installation ID needed to build the SSMS settings path.

From there he showed two chains:

  1. Add a stdio MCP server to .mcp.json, whose command is any program. Add its name to enabledMcpServers and remove it from disabledMcpServers in the settings file. The next session starts it.
  2. In Visual Studio, set copilot.general.tools.ripgrepPath in settings.VisualStudio.json to any binary. Copilot runs it on its next search. His demo launched calc.exe.

The entry point is indirect prompt injection, through a file in the repo or through MCP tool output. Rehberger notes the model in his demo, MAI-Code-1-Flash, had "quite poor" resistance to it. He reads the fix as an added GetFullPath call, which strips trailing dots and resolves .. before the comparison. That is his reading of the patched binary. Microsoft has not described the fix.

The pairing matters for defenders. In opencode, a server field became a shell command. In Copilot, the model became a writer of the file that decides which commands start. A stdio MCP entry is a command line. Any path that lets untrusted text write that file without a prompt is a code execution path, whatever the model's alignment.

Find affected installs without a CVE

Patch Copilot through the normal Visual Studio and SSMS update channels. CSA lists the fixed builds as 17.14.42 for Visual Studio 2022 and 18.10.4 for Visual Studio 2026. Your endpoint management will see that one, since it has a CVE.

opencode needs a direct inventory. On each Windows host and inside each WSL distribution:

# Windows: report the installed version and configured MCP servers
opencode --version
opencode mcp list

# Find every opencode binary on PATH, including stale global installs
Get-Command opencode -All | Select-Object Source
# Inside each WSL distribution
opencode --version
opencode mcp list
command -v -a opencode

# Global npm installs that may shadow a newer binary
npm ls -g opencode-ai

Anything from 1.0.137 to 1.18.32 needs the upgrade. The Hacker News also points readers to opencode mcp list and a direct version check, since there is no CVE for tooling to key on. Pillar's advice for hosts you cannot upgrade yet: remove remote MCP servers you have not vetted from the opencode config until you can. Expect developers to have more than one install. A global npm package and a standalone binary can coexist, and the one on PATH first wins.

If you maintain a Node tool that opens URLs, check which open you resolve:

# Every resolved copy of open, direct or transitive
npm ls open --all
# or, with pnpm
pnpm why open

Version 10.x or older on a Windows code path that receives a remote string has this bug. Upgrade to 11.0.4 or later, then fix the call site so the remote string never reaches a shell at all.

Pillar's comparison of other clients gives a useful bar. gemini-cli uses an execFile opener gated on scheme. Claude Code guards its opener twice, so a server-controlled value from the OAuth path can't reach it. github-mcp-server uses an argument-array opener and takes authorization servers from the operator, not from discovery. Docker's mcp-gateway checks every OAuth endpoint against an https allowlist and also opens URLs through an argument array. What the strong clients share is the argument array. The scheme check is extra.

For client authors, Pillar's list holds up:

  1. Pass URLs to the launcher as an argument. Never interpolate a remote string into a shell command, PowerShell included. Pillar calls this "the whole fix."
  2. Bind OAuth discovery to an origin the operator configured. A server that names its own authorization endpoint is making a trust decision for you. The spec allows the authorization server to differ from the MCP server's origin, so the fix is an operator-side allowlist, not a hardcoded same-origin rule.
  3. Treat every field the server sends as untrusted input: discovery documents, server metadata, tool and resource descriptors, error strings.
  4. Test the protocol surface on Windows. Both bugs here are Windows bugs, and opencode's also reached WSL.

For Copilot-style agents that edit files, normalize the path before you check it, using the same API that will perform the write. Then compare the canonical result against a denylist that includes every file that can start a process: .mcp.json, editor settings that name binaries, shell profiles, and the agent's own config.

What this means for your stack

Upgrade opencode to 1.18.33 or later on every Windows and WSL host, and apply the October Visual Studio and SSMS updates. Then list the remote MCP servers each developer has configured, and remove any no one can vouch for. That list is your inventory of who can send data to a parser running with full user rights.

The pattern that fixes this category is to treat an MCP server as untrusted code from the moment it is configured. The client passes its data as arguments, never as shell text. It binds discovery to origins the operator chose. It refuses to let the agent rewrite the files that decide what starts. And it assumes some of this will fail, so a compromised developer session finds as few standing credentials as possible: none in shell env, none in plaintext config, none in the agent's settings file for the next process to read.

hasp is one working implementation of that last part. curl -fsSL https://gethasp.com/install.sh | sh, hasp setup, connect a project, and secrets reach the processes that need them at runtime instead of sitting in env vars and config files that code running as you can read. Source-available (FCL-1.0), local-first, macOS and Linux, no account. It does not stop a launcher from running PowerShell.

The opencode bug went unflagged by every scanner because the vendor declined to call it a vulnerability. The next one may be in a client you have not inventoried. Know which MCP clients your developers run, which versions, and which servers they talk to, and keep that list without waiting for an advisory to start it.

Sources· cited above, in one place

NEXT STEP~90 seconds

Stop handing the agent your real keys.

hasp keeps secrets in one local encrypted vault, brokers them into the child process at exec, and never lets the agent read the value.

  • Local, encrypted vault — no account, no cloud, no telemetry by default.
  • Brokered run — agent gets a reference, the child process gets the value.
  • Pre-commit + pre-push hooks catch managed values before they ship.
  • Append-only HMAC audit log answers "did the agent touch the prod token?" in seconds.
→ okvault unlocked · binding ./api
→ okgrant once · pid 88421
→ okagent never read

macOS & Linux. Source-available (FCL-1.0, converts to Apache 2.0). No account.

Browse all clusters· eight threads, one index