Security: CLI login lacks user-visible device verification code
Opened by swampadmin · 1/25/2025
Summary
The CLI browser-based login flow (swamp auth login) does not display a user-visible verification code that the user can cross-check between the CLI and the web UI. This means a user has no way to confirm that the browser session they are authenticating actually corresponds to the CLI session that initiated the request.
Current Behavior
- CLI generates a random
stateUUID and opens the browser to/login?cli_callback=...&state=... - User authenticates in the browser
- Browser redirects back to the CLI's localhost callback server with a session token
- CLI validates the
stateparameter matches (CSRF protection only)
The state parameter is a machine-level CSRF nonce — it is never shown to the user and cannot be visually verified.
Problem
Without a user-visible verification code, the flow is vulnerable to session fixation / phishing-adjacent attacks:
- An attacker could trick a user into authenticating a CLI session the attacker controls (e.g. by sending them a crafted login URL)
- The user has no way to verify that the browser login page corresponds to their CLI instance
- This is a known gap addressed by standards like OAuth 2.0 Device Authorization Grant (RFC 8628), which requires a
user_codeto be displayed on both the device and the browser for cross-verification
Proposed Solution
Implement a user-visible verification code similar to the OAuth device flow:
- CLI displays a short code (e.g.
ABCD-1234) in the terminal when initiating login - Web UI displays the same code on the authorization page
- User confirms the codes match before approving the login (or types the code into the web UI)
This ensures the user can verify that the browser session they are about to authorize actually belongs to the CLI session in front of them.
References
- RFC 8628 - OAuth 2.0 Device Authorization Grant — standard pattern for device-to-browser verification codes
- GitHub CLI (
gh auth login) and other CLIs use similar verification code patterns
Closed
No activity in this phase yet.
Sign in to post a ripple.