Skip to content

fix: return browser-open command instead of spawning it (CodeQL command-injection)#308

Merged
gaurav-singh-9227 merged 2 commits into
mainfrom
fix/codeql-command-injection-openbrowser
May 28, 2026
Merged

fix: return browser-open command instead of spawning it (CodeQL command-injection)#308
gaurav-singh-9227 merged 2 commits into
mainfrom
fix/codeql-command-injection-openbrowser

Conversation

@gaurav-singh-9227
Copy link
Copy Markdown
Collaborator

@gaurav-singh-9227 gaurav-singh-9227 commented May 28, 2026

What

Resolves CodeQL js/command-line-injection (critical, alert #2) at src/tools/applive-utils/start-session.ts.

Approach

Instead of the MCP server spawning a browser process itself with a user-influenced launch URL (childProcess.spawn(...)), the server now returns the platform-appropriate open command as text. The host AI agent surfaces that command, asks the user for permission, and runs the same command.

The server never spawns a process, so the command-injection surface is eliminated rather than merely guarded. The URL is still validated (https: + *.browserstack.com allowlist) before being surfaced; untrusted/malformed URLs are refused.

Changes

  • src/tools/applive-utils/start-session.ts — the file flagged by alert add MCP server badge #2. openBrowser()getOpenBrowserCommand(); returns the command in the tool response.
  • src/tools/live-utils/start-session.ts — the identical openBrowser/spawn in the Live-session path, converted for parity (CodeQL flagged only applive, but both shared the same vulnerable code).

Verification

  • tsc --noEmit → clean
  • eslint on changed files → clean
  • vitest → 77/77 pass

🤖 Generated with Claude Code

gaurav-singh-9227 and others added 2 commits May 29, 2026 00:48
Restrict openBrowser() to https URLs on *.browserstack.com so
attacker-influenced URL data cannot reach `cmd /c start` on Windows
or the equivalent open/xdg-open calls on macOS/Linux. Closes the
CodeQL js/command-line-injection alert (#2).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Resolves CodeQL js/command-line-injection (alert #2) at
src/tools/applive-utils/start-session.ts. Instead of the server calling
childProcess.spawn() with a user-influenced launch URL, it now returns the
platform-appropriate open command as text. The host agent prompts the user
before executing it, so the server never spawns a process and the
command-injection surface is eliminated. The URL is still validated
(https + *.browserstack.com allowlist) before being surfaced.

Applies the same conversion to the identical openBrowser/spawn in
live-utils/start-session.ts for parity.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gaurav-singh-9227 gaurav-singh-9227 changed the title fix: validate launchUrl before spawning browser process fix: return browser-open command instead of spawning it (CodeQL command-injection) May 28, 2026
@gaurav-singh-9227 gaurav-singh-9227 merged commit 87588f7 into main May 28, 2026
5 checks passed
@ruturaj-browserstack ruturaj-browserstack deleted the fix/codeql-command-injection-openbrowser branch May 28, 2026 19:54
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.

2 participants