Summary
Cloud CLI (Claude Code UI) contains an OS command injection flaw in several Git-related API endpoints that construct shell commands using string interpolation of user-controlled parameters.
Authenticated users who can invoke these endpoints may execute arbitrary operating system commands on the host by supplying crafted values for fields like file, branch, message, or commit.
Affected context
This vulnerability affects Cloud CLI deployments where:
- The Git-related API endpoints are exposed to authenticated users
- Backend logic constructs Git commands using
execAsync()with concatenated user input - The host environment has access to sensitive resources (filesystem, network, credentials)
It primarily impacts environments where Cloud CLI is run on developer machines, CI runners, or shared servers and where users are not fully trusted or plugins/scripts can issue authenticated API calls.
Exploit preconditions
- Attack surface: Git-related API endpoints within the Cloud CLI backend (desktop or mobile app environment).
- Required access: Valid authenticated access to the application or any channel that can issue authenticated requests (e.g., extensions, automation scripts).
- User-controlled parameters: Git inputs such as
file,branch,message, andcommitare passed into shell commands via string interpolation. - Trigger point: When the application calls
execAsync()to run Git commands that include these interpolated parameters. - Why exploitation is possible: The code treats user-controlled parameters as trusted, embedding them directly into shell command strings without proper escaping or use of argument-safe APIs, enabling injection of additional shell syntax.
Why this happens
The underlying issue is a classic OS command injection vulnerability, mapped to CWE-78: Improper Neutralization of Special Elements used in an OS Command.
The Git-related API endpoints build shell command strings by interpolating user-controlled values (e.g., branch names or commit messages) and then execute them via execAsync().
Because the input is not strictly validated, normalized, or passed as discrete arguments, attackers can craft values containing shell metacharacters (such as command separators or redirection operators).
This pattern transforms benign data parameters into part of the executable command, allowing unintended commands to run with the privileges of the Cloud CLI backend process.
Potential impact
- Execution of arbitrary OS commands with the privileges of the Cloud CLI process
- Reading, modifying, or deleting files accessible to the host user
- Exfiltration of SSH keys, API tokens, or other developer secrets
- Tampering with local Git repositories (rewriting history, injecting malicious code)
- Pivoting to other systems via network access from the compromised host
- Planting backdoors or malicious scripts in development environments and CI pipelines
General mitigation guidance
Effective mitigation generally focuses on eliminating string-based shell command construction and tightening trust boundaries around command execution:
- Prefer using process-spawning APIs that accept command and arguments as separate parameters, avoiding shell interpretation entirely.
- For Git operations, use dedicated library APIs or higher-level abstractions instead of hand-rolled shell commands.
- Apply strict input validation and normalization on Git parameters:
- Enforce allowed character sets and length limits for branch names, file paths, and messages.
- Reject or sanitize characters with special meaning in shells (e.g.,
;,&,|, backticks). - Run the backend with least privilege so that, if a command is injected, its access to files and network resources is constrained.
- Isolate the command-execution context (e.g., restricted working directories, sandboxing) to limit blast radius.
- Treat all inputs that can influence command construction as untrusted, even when supplied by authenticated users or plugins.
How teams detect issues like this
Detection typically combines code-centric and runtime-focused approaches:
- Static analysis: Configure rules to flag:
- Uses of
exec,execAsync, or similar APIs that receive concatenated/templated strings. - Any command-building logic that includes user-controlled variables without prior validation.
- Code review signals:
- Shell commands built via template literals or string concatenation in backend controllers or Git utilities.
- Missing or weak validation on Git parameters such as branch, file, and commit identifiers.
- Policy enforcement in CI/CD:
- Linting rules that prohibit shelling out to Git when a library alternative exists.
- Security checks that fail builds when dangerous patterns appear.
- Runtime monitoring:
- Logging of executed commands and arguments for anomaly detection (e.g., presence of unexpected shell metacharacters).
- Alerting on suspicious command patterns initiated by the Cloud CLI process.

