Skip to content

Fix Windows OAuth login: cmd /c start truncates auth URL at first & - #53

Open
MediaJohnD wants to merge 1 commit into
apolloio:mainfrom
MediaJohnD:fix-windows-oauth-redirect-uri
Open

Fix Windows OAuth login: cmd /c start truncates auth URL at first &#53
MediaJohnD wants to merge 1 commit into
apolloio:mainfrom
MediaJohnD:fix-windows-oauth-redirect-uri

Conversation

@MediaJohnD

Copy link
Copy Markdown

Summary

  • Fixes Windows: auth login fails with "redirect uri is malformed or doesn't match" — cmd /c start truncates the auth URL at the first & #46: on Windows, apollo auth login fails with "The requested redirect uri is malformed or doesn't match client redirect URI"
  • Root cause: openBrowser()'s Windows branch passes the full OAuth authorize URL to cmd /c start. cmd.exe's start re-parses its argument line and treats an unescaped & as a command separator, even though the URL arrives as its own spawnSync array element -- silently truncating the URL at the first &. Since the authorize URL is ...?client_id=...&redirect_uri=...&response_type=...&scope=..., only client_id ever reaches the browser; redirect_uri and everything after it is dropped, so Apollo's OAuth server correctly rejects the (missing) redirect_uri.
  • Fix: escape & as ^& (cmd's own escape sequence) before handing the URL to start, Windows-only. macOS (open) and Linux (xdg-open) paths are untouched since they don't share this parsing behavior.

Test plan

🤖 Generated with Claude Code

cmd.exe's `start` re-parses its argument line and treats an unescaped
`&` as a command separator, even when the URL is passed as its own
array element to spawnSync. This silently truncated the OAuth
authorize URL at the first `&` -- only `client_id=...` reached the
browser, dropping redirect_uri and every param after it -- producing
"The requested redirect uri is malformed or doesn't match client
redirect URI" on every Windows login attempt.

Escaping `&` as `^&` (cmd's own escape sequence) before the URL
reaches `start` fixes it. macOS/Linux paths are untouched.

Verified live: fresh `apollo auth login` on Windows now opens the
full authorize URL, completes the OAuth flow, and `apollo auth
whoami` correctly reports the logged-in user.

Fixes apolloio#46

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@orca-security-us orca-security-us Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

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.

Windows: auth login fails with "redirect uri is malformed or doesn't match" — cmd /c start truncates the auth URL at the first &

1 participant