Summary
simple-git versions before 3.36.0 contain an argument injection flaw in their options handling that enables Remote Code Execution (RCE) via Git's protocol extension mechanism.
When untrusted user input is passed into the options array for simple-git commands, an attacker can re-enable dangerous Git configuration (protocol.ext.allow=always) using --config and then leverage an ext:: clone source to run arbitrary commands.
Affected context
This vulnerability affects Node.js applications that:
- Use the
simple-gitpackage prior to version 3.36.0 - Construct simple-git command options from untrusted or partially validated input
- Execute Git operations (e.g., clone, fetch) where options are passed as an array or list of arguments
The risk materializes when application logic assumes that blocking the -c flag is sufficient, while the equivalent --config form remains usable by an attacker to alter Git configuration at runtime.
Exploit preconditions
- Attack surface: Application features that trigger Git operations through simple-git (e.g., repository import, mirroring, user-supplied repo URLs or flags).
- Required access: Ability to influence or control data that flows into the
optionsargument (or equivalent) for simple-git commands; this can be via HTTP APIs, form fields, configuration panels, or CI job parameters exposed to untrusted users. - Trigger point: Execution of a simple-git command where the crafted options are appended to the Git invocation (commonly
git cloneor similar). - Why exploitation is possible: The previous fix blocked only the short
-cGit configuration flag, not its long--configequivalent, allowing attackers to setprotocol.ext.allow=alwaysand use anext::URL to execute arbitrary commands through Git's external protocol mechanism.
Why this happens
The underlying flaw is a code injection issue caused by incomplete validation of command-line options passed to an embedded tool, mapping to CWE-94: Improper Control of Generation of Code (Code Injection).
In this case, the library attempted to restrict dangerous Git configuration by blocking the -c option but overlooked the semantically equivalent --config form. Because simple-git forwards caller-supplied options directly to Git without a strict allowlist or robust normalization, attackers can still inject configuration directives that re-enable Git's ext:: protocol. That protocol, in turn, allows execution of arbitrary system commands as part of the Git operation, effectively turning argument injection into remote code execution.
Potential impact
- Remote execution of arbitrary OS commands under the privileges of the Node.js application process
- Complete compromise of the application server hosting the vulnerable simple-git usage
- Unauthorized access to source code repositories, build artifacts, or secrets accessible to the Git process
- Lateral movement within CI/CD environments where simple-git is used in automation scripts
- Data exfiltration, tampering with repository contents, or backdooring of software supply chains
General mitigation guidance
Effective mitigation focuses on treating all Git options and URLs as untrusted input and enforcing strict controls around them:
- Prefer fixed, hard-coded options for simple-git calls and avoid passing user-controlled flags or configuration switches altogether.
- Apply a positive allowlist for permissible Git options if options must be dynamic, explicitly disallowing configuration-related flags like
-cand--config, as well as protocol-altering options. - Normalize and canonicalize options before validation so that equivalent forms (short vs. long flags) are treated consistently.
- Restrict or sanitize repository URLs, explicitly disallowing
ext::and other non-standard or executable protocol schemes. - Run Git operations under least-privilege service accounts with minimal system access, limiting the blast radius if a command is abused.
- Isolate Git operations in hardened environments (e.g., containers or sandboxes) where direct system command execution has reduced impact.
These measures reduce the likelihood that malformed options or URLs can transition into arbitrary command execution paths.
How teams detect issues like this
Organizations can identify and monitor this pattern using a mix of code analysis and runtime observability:
- Static application security testing (SAST):
- Search for calls to
simple-gitwhere the options argument is constructed from HTTP request parameters, form inputs, environment variables, or other untrusted sources. - Flag usages where options are concatenated or directly forwarded without an explicit allowlist or validation function.
- Code review practices:
- Treat any dynamic command-line construction, especially around Git, as a security-sensitive area requiring explicit reviewer sign-off.
- Look for ad-hoc blacklist approaches (e.g., blocking only
-c) and ensure equivalent or alias forms (e.g.,--config) are considered. - Policies and tooling:
- Enforce secure wrappers or shared helper functions for Git operations that encapsulate safe option handling.
- Use automated code review tools or custom linters to detect disallowed flags (
-c,--config,ext::URLs) in Git-related code paths. - Runtime monitoring:
- Monitor Git command invocations for suspicious options or protocol usage, such as
protocol.ext.alloworext::URLs, and alert on anomalies.

