Summary
simple-git, a Node.js library for running git commands, contains a command injection flaw in versions 3.15.0 through 3.32.2 that allows crafted input to escape the intended git command context.
When untrusted data is passed into simple-git APIs and incorporated into underlying shell commands, an attacker may achieve full remote code execution (RCE) on the host machine despite earlier partial fixes.
Affected context
The vulnerability arises in Node.js applications that integrate simple-git (versions 3.15.0–3.32.2) and pass user-controlled or otherwise untrusted values into operations that are ultimately mapped to git command-line arguments or options.
It typically becomes exploitable when:
- Application logic constructs simple-git commands dynamically based on HTTP parameters, webhooks, CLI arguments, environment variables, or repository metadata from untrusted sources, and
- Those values are not sanitized or constrained to a safe subset before being handed to simple-git, and
- The library executes git via the system shell in a way that fails to robustly separate user data from command structure, allowing previously patched vectors to be bypassed.
Exploit preconditions
- Attack surface: Any application endpoint, API, job, or integration point where untrusted data influences simple-git calls (e.g., branch names, remote URLs, file paths, custom arguments).
- Required access: Ability to supply or control data that is fed into simple-git functions; this may be remote (web/API) or local (CI/job configuration), depending on the application.
- Trigger point: Invocation of git operations through simple-git that concatenate or interpolate untrusted input into command strings or argument lists without strict validation or escaping.
- Why exploitation is possible: The library's internal command construction and escaping logic does not fully neutralize metacharacters or shell syntax, enabling attackers to break out of intended git arguments and inject additional commands, bypassing prior CVE fixes (CVE-2022-25860 and CVE-2022-25912).
Why this happens
At its core, this is a command injection issue aligned with CWE-78: Improper Neutralization of Special Elements used in an OS Command.
The simple-git library assembles git commands from a mix of trusted and untrusted inputs, but relies on insufficient escaping and validation to keep those values purely as data.
Because the underlying execution model allows shell interpretation of special characters, crafted payloads can alter the command structure rather than just its parameters.
The regression or bypass aspect relates to CWE-178: Improper Handling of Case Sensitivity, and more broadly to incomplete or brittle filtering rules that attackers can circumvent by varying input shape, casing, or encoding.
Conceptually, the insecure pattern is: "build command lines using string concatenation or loosely validated arrays that accept arbitrary user-controlled tokens, then execute them in a context where the shell can interpret metacharacters."
Potential impact
- Remote code execution with the same privileges as the Node.js process running simple-git.
- Full compromise of the host system where the application is deployed (e.g., web server, CI runner, container).
- Theft, modification, or deletion of application data, source code, or secrets accessible to the compromised process.
- Lateral movement within the environment via additional tooling executed from the compromised host.
- Abuse of the host for further attacks, such as launching internal scans, exfiltrating credentials, or running cryptominers.
General mitigation guidance
Reducing risk focuses on eliminating command injection opportunities and tightening trust boundaries around git operations:
- Avoid shell-sensitive construction: Use execution patterns that do not depend on shell parsing; prefer APIs and libraries that enforce strict argument separation and do not expose raw command lines.
- Constrain input sources: Treat all values that may reach simple-git as untrusted by default; only permit a small, explicitly defined set of allowed branches, remotes, or paths when possible.
- Validate and normalize inputs: Apply strict allowlists for branch names, repo URLs, and paths (e.g., regex enforcing alphanumeric, dashes, and slashes only). Normalize and reject values containing control characters, whitespace tricks, or shell metacharacters.
- Minimize privileges: Run the Node.js process and any associated CI/CD or job runners with least privilege in isolated environments (containers, dedicated users, restricted file-system access) to limit blast radius if RCE occurs.
- Centralize command wrappers: Encapsulate all simple-git interactions behind a small abstraction layer with uniform validation and sanitization, rather than letting arbitrary application code construct commands.
How teams detect issues like this
Security teams can look for this bug class using a mix of static inspection, dynamic testing, and policy checks:
- Static analysis patterns:
- Flag usage of simple-git where untrusted variables are passed directly as arguments for branch names, remotes, or arbitrary options without clear validation.
- Identify any code paths that concatenate user-controlled values into strings later handed to git-related APIs, especially in request handlers or job definitions.
- Code review signals:
- Dynamic construction of git commands based on HTTP request fields, webhooks, environment variables, or configuration files not under strict control.
- Ad-hoc escaping logic (e.g., manual replacement of a few special characters) instead of robust allowlists and structured argument handling.
- Reintroduction of previously removed or patched argument patterns intended to fix earlier CVEs.
- Dynamic and policy-based checks:
- Fuzz endpoints and workflows that trigger git operations using payloads containing shell metacharacters to detect unexpected command behavior in test environments.
- Enforce organizational policies requiring that any use of command-executing libraries (including simple-git) be reviewed and approved with documented validation rules.
- Tooling support:
- Incorporate SAST/IAST tools that understand Node.js child-process and command-construction patterns, configured with custom rules to track untrusted data into git-related calls.

