Skip to content

fix(login): open the browser without a shell (CodeQL js/command-line-injection) - #31

Merged
Domantas merged 1 commit into
mainfrom
fix/open-browser-injection
Oct 3, 2026
Merged

Domantas merged 1 commit into
mainfrom
fix/open-browser-injection

Conversation

@Domantas

@Domantas Domantas commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Fixes code-scanning alert #1 (js/command-line-injection, error) in src/lib/device-login.ts.

Problem

openBrowser ran cmd /c start "" <url> on Windows. The URL is verificationUriComplete ?? verificationUri from the hub's /v2/auth/device/start response. cmd parses &, | and ^ in its arguments, so a hostile or compromised --server could make norbix login run arbitrary commands.

Fix

  • Only http:/https: URLs are opened; anything else (file:, javascript:, bare strings) is skipped. The URL is still printed, so login works either way.
  • Windows uses rundll32 url.dll,FileProtocolHandler <url>. spawn without a shell passes it as one argument; nothing parses it.
  • macOS / Linux unchanged (open / xdg-open, no shell).

Tests

New test/device-login.test.ts: scheme allow-list, and Windows command keeps &/| inside the URL argument. npm test 374/374 ✓, tsc --noEmit ✓.

Not tested on a real Windows machine.

🤖 Generated with Claude Code

…injection)

openBrowser ran `cmd /c start "" <url>` on Windows, with the URL taken from
the hub's device-login response. cmd parses `&`, `|` and `^` in its
arguments, so a hostile or compromised --server could run commands on the
user's machine.

- only http(s) URLs are opened (parsed with URL, normalised href)
- Windows uses `rundll32 url.dll,FileProtocolHandler <url>`, no cmd
- test/device-login.test.ts covers both

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Domantas
Domantas merged commit d4ea54a into main Oct 3, 2026
11 checks passed
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant