Skip to content

Stop opening the OAuth authorization URL through cmd.exe on Windows - #382

Merged
jancurn merged 2 commits into
mainfrom
claude/security-review-2026-09-fix-nv4qav
Sep 2, 2026
Merged

Stop opening the OAuth authorization URL through cmd.exe on Windows#382
jancurn merged 2 commits into
mainfrom
claude/security-review-2026-09-fix-nv4qav

Conversation

@jancurn

@jancurn jancurn commented Sep 2, 2026

Copy link
Copy Markdown
Member

mcpc login handed the server-supplied authorization URL to cmd.exe /c start on Windows. libuv only quotes arguments with whitespace or double quotes, so &, |, ^ and %VAR% in the URL ran as commands once the user pressed Enter, and even a benign URL was cut off at its first &. The browser is now launched without any shell, and non-http(s) authorization URLs are refused.

  • Windows uses rundll32 url.dll,FileProtocolHandler <url> (same approach as the GitHub CLI); macOS and Linux keep open / xdg-open.
  • Authorization URLs with a scheme other than http:/https: are rejected in both login flows before they are printed or opened.
  • The launcher command is built by a pure exported function with unit tests asserting no shell binary is ever used and hostile URLs pass through as one verbatim argument.
  • Changelog Security entry and CLAUDE.md security note updated.

Not exercised on Windows itself; the reasoning follows libuv's quoting rules and the rundll32 precedent.

Fixes H1 in docs/security-review-2026-09.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HbTS6Mvbo9t5115trQQm6j

The authorization URL is built from the authorization server's metadata,
i.e. it is controlled by whatever server the user typed into `mcpc login`.
On Windows it was handed to `cmd.exe /c start "" <url>`. libuv only quotes
arguments containing whitespace or double quotes, so `&`, `|`, `^` and
`%VAR%` inside the URL reached cmd.exe unescaped and were interpreted as
commands: `https://evil.example/authorize?x=1&calc` ran `calc` once the
user pressed Enter. Even a benign URL was truncated at its first `&`.

The browser is now launched via `rundll32 url.dll,FileProtocolHandler`
on Windows (no command interpreter in between, same approach as the
GitHub CLI), and authorization URLs with a scheme other than http:/https:
are refused on every platform before they are shown or opened. The
launcher command is built by a pure, exported function with unit tests
that assert no shell binary is ever used and that hostile URLs pass
through as a single verbatim argument.

Fixes H1 in docs/security-review-2026-09.md.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HbTS6Mvbo9t5115trQQm6j
@jancurn jancurn changed the title Secure browser opening: reject non-http(s) authorization URLs Stop opening the OAuth authorization URL through cmd.exe on Windows Sep 2, 2026
Refs #382.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HbTS6Mvbo9t5115trQQm6j
@jancurn
jancurn merged commit b5259c4 into main Sep 2, 2026
8 checks passed
@jancurn
jancurn deleted the claude/security-review-2026-09-fix-nv4qav branch September 2, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants