/

CVE-2026-31975

Severity:

CRITICAL RISK

(9.8)

OS Command Injection in Cloud CLI WebSocket Shell Handler

CVE-2026-31975

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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, and sessionId directly 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, or sessionId is 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 projectPath and sessionId against 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.

Sources

SourceLink
github.comgithub.com/siteboon/claudecodeui/commit/12e7f074d9563b3264caf9cec6e1b701c301af26
github.comgithub.com/siteboon/claudecodeui/releases/tag/v1.25.0
github.comgithub.com/siteboon/claudecodeui/security/advisories/GHSA-gv8f-wpm2-m5wr

Frequently asked

questions

It can be, depending on how Cloud CLI is exposed. If the WebSocket endpoint is accessible to remote users (for example, bound to a non-local interface or tunneled over a shared environment), an attacker may be able to exploit the issue remotely. If it is strictly local, exploitation is typically limited to local users or processes that can connect to the WebSocket.

An attacker needs the ability to connect to the Cloud CLI WebSocket shell endpoint and send crafted messages containing specially formed projectPath, initialCommand, or sessionId values. No additional privileges are required beyond reachability of that interface.

The safest pattern is to stop passing untrusted data into a shell altogether. Use process execution APIs that accept argument arrays, validate all user-controlled fields against strict schemas, and—where possible—replace "run this command" features with explicit, parameterized operations that do not expose a general-purpose shell.

Adopt a defensive design rule that untrusted input must never be interpolated into command strings. Standardize on secure wrappers for process execution, enforce input validation libraries, include command-injection checks in static analysis and code review, and document clear guidelines for handling user data in any feature that touches the operating system.

Find out what's already
exploitable in your codebase.