Summary
A critical OS command injection vulnerability in Cloud CLI's WebSocket-based shell feature allows attacker-controlled data to be interpolated directly into bash command strings.
When an attacker can send crafted WebSocket messages (e.g., controlling projectPath, initialCommand, or sessionId), they may be able to execute arbitrary commands on the underlying operating system with the privileges of the Cloud CLI process.
Affected context
This vulnerability occurs in Cloud CLI's WebSocket shell functionality, implemented in server/index.js.
The issue arises when the server:
- Accepts WebSocket connections from clients,
- Reads
projectPath,initialCommand, andsessionIddirectly from the message payload, - Interpolates these values into a shell command string executed via bash, without enforcing input validation or shell-safe escaping.
It is most relevant when Cloud CLI is run in environments where untrusted or semi-trusted clients can establish WebSocket connections to the local or remote server component.
Exploit preconditions
- Attack surface: WebSocket endpoint used to provide a shell interface to Cloud CLI clients.
- Required access: Ability to connect to the Cloud CLI WebSocket server and send crafted messages (e.g., local user, remote user over exposed port, or any actor able to proxy requests).
- Trigger point: Processing of a WebSocket message where
projectPath,initialCommand, orsessionIdis concatenated or interpolated into a bash command string. - Why exploitation is possible: The server constructs shell commands by directly embedding untrusted fields into the command line without sanitization, quoting, or use of safer process-spawning APIs. Shell metacharacters and command separators in these fields are interpreted by bash as additional commands.
Why this happens
The root cause is direct use of untrusted WebSocket message fields inside a shell command, a classic case of OS Command Injection (CWE-78).
Instead of treating projectPath, initialCommand, and sessionId as data and passing them as discrete, validated arguments to a process invocation API, the code interpolates them into a single command string executed by bash.
This pattern allows an attacker to supply shell metacharacters (;, &&, |, backticks, subshells) or additional arguments so that bash parses and runs arbitrary commands beyond the intended program invocation.
Potential impact
- Execution of arbitrary OS commands with the privileges of the Cloud CLI server process.
- Reading, modifying, or deleting files accessible to the Cloud CLI user account.
- Installing backdoors or additional malicious software on the host system.
- Lateral movement within the user's environment, including accessing other services reachable from that host.
- Exfiltration of sensitive local data such as API keys, configuration files, or source code.
- Disruption of development workflows or sabotage of project repositories and build artifacts.
General mitigation guidance
Mitigation typically focuses on removing direct shell interpolation and treating user input as data, not code:
- Replace string-based shell execution with APIs that accept argument arrays (e.g., spawn/exec variants that bypass the shell) and never pass untrusted input through a shell.
- Normalize and strictly validate fields like
projectPathandsessionIdagainst expected formats (e.g., canonicalized paths, UUID-like identifiers) and reject or sanitize anything outside these patterns. - For command-like inputs such as
initialCommand, consider whitelisting a constrained set of allowed operations, or disallowing arbitrary command execution in favor of specific, higher-level actions. - Apply principle of least privilege to the Cloud CLI process, limiting filesystem and network permissions so that a compromised shell has reduced impact.
- Isolate the shell-execution component (e.g., via containers, sandboxes, or restricted user accounts) to minimize damage from potential injection.
How teams detect issues like this
High-level detection and assurance strategies include:
- Static analysis: Define rules that flag usage of shell-execution APIs with string concatenation or template literals that include WebSocket message fields or other untrusted sources.
- Code review: Look for patterns where
projectPath,initialCommand,sessionId, or similar user-provided values are embedded in command strings, especially within WebSocket and RPC handlers. - Security linters and CI policies: Enforce policies that disallow direct shell invocation with untrusted data, requiring the use of safer process-spawning APIs and input validation helpers.
- Runtime monitoring: Where feasible, monitor process creation from the Cloud CLI server, looking for unusual commands or argument patterns that may indicate command injection attempts.

