Summary
A command injection vulnerability in simple-git allows attacker-influenced Git clone arguments to cause Git to load an unintended configuration file. If the application can read an attacker-controlled file, that configuration may cause Git to execute commands with the privileges of the Node.js process.
Affected context
The vulnerability may occur in simple-git applications that:
- Use the Git clone operation with custom arguments influenced by an attacker
- Permit Git configuration include directives to be introduced through those arguments or related files
- Run the clone operation with access to an attacker-controlled, readable configuration file
- Execute Git with meaningful operating-system or application privileges
The issue involves incomplete filtering of both direct and conditional configuration include options.
Exploit preconditions
- Attack surface: An application endpoint, job, or workflow that invokes
git.clone() - Required access: Ability to influence the clone operation's custom arguments and provide or affect a file readable by the Node.js process
- Trigger point: Git configuration processing during the clone operation
- Why exploitation is possible: An insufficiently restricted include directive can cause Git to load attacker-controlled settings, including executable options that Git invokes during the operation
Why this happens
The underlying bug is incomplete validation of Git configuration-related arguments. The defensive plugin rejects some unsafe operations but does not fully classify both direct include.path and conditional includeIf.<condition>.path forms.
As a result, attacker-influenced input can cross the boundary from command configuration into executable Git behavior. When a loaded configuration specifies an option such as an SSH command, Git may invoke that command during cloning, mapping the issue to CWE-78: Improper Neutralization of Special Elements used in an OS Command.
Potential impact
- An attacker may execute operating-system commands with Node.js process privileges
- The application runtime could be compromised
- Repository credentials, tokens, or local files could be exposed
- Git operations or retrieved source code could be manipulated
- A compromised process could be used for lateral movement or further system damage
General mitigation guidance
Mitigation generally focuses on preventing attacker-controlled Git options and reducing the privileges available to Git subprocesses.
Common defensive patterns include:
- Use a secure-by-default Git argument policy that rejects all configuration include variants, including conditional forms
- Treat clone options and repository metadata as untrusted input, and permit only narrowly defined arguments
- Avoid passing arbitrary custom arguments from request or job data into Git subprocesses
- Restrict the files and directories readable by the Node.js process and Git child processes
- Run Git operations with a dedicated low-privilege identity, isolated filesystem access, and limited network permissions
- Apply repository, SSH, and credential policies that prevent unexpected command execution
- Validate arguments before process creation and maintain defense-in-depth controls around subprocess execution
How teams detect issues like this
Detection approaches may include:
- Static analysis rules for attacker-controlled values reaching
git.clone()custom arguments or child-process execution - Code review checks for allowlists that omit direct or conditional Git configuration include forms
- Runtime monitoring for unexpected Git configuration files, SSH command settings, or child processes spawned during cloning
- Policy enforcement that restricts Git subprocess arguments, readable configuration paths, and available credentials
- Automated security review tools that trace untrusted data into Git and operating-system command execution paths

