fix: return browser-open command instead of spawning it (CodeQL command-injection)#308
Merged
gaurav-singh-9227 merged 2 commits intoMay 28, 2026
Merged
Conversation
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>
ruturaj-browserstack
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Resolves CodeQL
js/command-line-injection(critical, alert #2) atsrc/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.comallowlist) 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 identicalopenBrowser/spawnin the Live-session path, converted for parity (CodeQL flagged only applive, but both shared the same vulnerable code).Verification
tsc --noEmit→ cleaneslinton changed files → cleanvitest→ 77/77 pass🤖 Generated with Claude Code