Summary
A command-injection vulnerability in simple-git can cause Git to execute an attacker-selected shell command when configured trailer values are processed by git interpret-trailers.
The risk arises when an application passes attacker-controlled data through SimpleGitOptions.config or inline Git -c arguments, allowing code execution with the permissions of the Node.js process.
A command-injection vulnerability in simple-git can cause Git to execute an attacker-selected shell command when configured trailer values are processed by git interpret-trailers.
The risk arises when an application passes attacker-controlled data through SimpleGitOptions.config or inline Git -c arguments, allowing code execution with the permissions of the Node.js process.
Affected context
The vulnerability affects simple-git applications in the impacted release range when they expose Git configuration to attacker-controlled input. The default blockUnsafeOperationsPlugin does not classify trailer.<token>.cmd as unsafe, so a configured trailer command may be accepted and later invoked while Git processes trailer metadata.
The vulnerability affects simple-git applications in the impacted release range when they expose Git configuration to attacker-controlled input. The default blockUnsafeOperationsPlugin does not classify trailer.<token>.cmd as unsafe, so a configured trailer command may be accepted and later invoked while Git processes trailer metadata.
Exploit preconditions
- Attack surface: Node.js application code that invokes simple-git and forwards Git configuration or inline
-carguments - Required access: Ability to influence a configuration value, trailer definition, or other input that reaches the Git command invocation
- Trigger point: Processing of configured trailers through
git interpret-trailers - Why exploitation is possible: The unsafe
trailer.<token>.cmdconfiguration is not blocked, allowing Git to interpret attacker-controlled configuration as a shell command
- Attack surface: Node.js application code that invokes simple-git and forwards Git configuration or inline
-carguments - Required access: Ability to influence a configuration value, trailer definition, or other input that reaches the Git command invocation
- Trigger point: Processing of configured trailers through
git interpret-trailers - Why exploitation is possible: The unsafe
trailer.<token>.cmdconfiguration is not blocked, allowing Git to interpret attacker-controlled configuration as a shell command
Why this happens
The underlying flaw is incomplete validation of Git configuration keys in the default unsafe-operation filtering logic. Because trailer.<token>.cmd is not recognized as a dangerous command-bearing option, untrusted values can reach Git's trailer-processing functionality, which may invoke them as shell commands.
This maps primarily to CWE-78: Improper Neutralization of Special Elements used in an OS Command, with CWE-184: Incomplete List of Disallowed Inputs describing the omission in the safety filter.
The underlying flaw is incomplete validation of Git configuration keys in the default unsafe-operation filtering logic. Because trailer.<token>.cmd is not recognized as a dangerous command-bearing option, untrusted values can reach Git's trailer-processing functionality, which may invoke them as shell commands.
This maps primarily to CWE-78: Improper Neutralization of Special Elements used in an OS Command, with CWE-184: Incomplete List of Disallowed Inputs describing the omission in the safety filter.
Potential impact
- An attacker may execute arbitrary operating-system commands
- The Node.js process may be compromised with its current identity and permissions
- Application secrets, source code, or Git credentials could be accessed
- Data may be modified, deleted, or poisoned
- The compromised process could be used for lateral movement where network and service permissions allow
- An attacker may execute arbitrary operating-system commands
- The Node.js process may be compromised with its current identity and permissions
- Application secrets, source code, or Git credentials could be accessed
- Data may be modified, deleted, or poisoned
- The compromised process could be used for lateral movement where network and service permissions allow
General mitigation guidance
Mitigation centers on preventing untrusted data from becoming Git configuration or command arguments.
Common defensive patterns include:
- Rejecting or allowlisting Git configuration keys, including command-bearing trailer settings
- Avoiding dynamic inline
-carguments when values originate outside a trusted control plane - Treating repository metadata, commit messages, and trailer input as untrusted
- Separating user-controlled values from process-spawning APIs and using structured interfaces where available
- Running Node.js services with least-privilege operating-system identities and restricted filesystem and network access
- Applying defense-in-depth controls such as sandboxing and credential isolation
Mitigation centers on preventing untrusted data from becoming Git configuration or command arguments.
Common defensive patterns include:
- Rejecting or allowlisting Git configuration keys, including command-bearing trailer settings
- Avoiding dynamic inline
-carguments when values originate outside a trusted control plane - Treating repository metadata, commit messages, and trailer input as untrusted
- Separating user-controlled values from process-spawning APIs and using structured interfaces where available
- Running Node.js services with least-privilege operating-system identities and restricted filesystem and network access
- Applying defense-in-depth controls such as sandboxing and credential isolation
How teams detect issues like this
Detection approaches can include:
- Static analysis for attacker-controlled data flowing into SimpleGitOptions.config, inline
-carguments, or Git process-spawning APIs - Code review checks for dynamic construction of Git configuration keys and trailer definitions
- Policy rules that reject
trailer.*.cmdand other command-bearing Git options unless explicitly approved - Runtime monitoring for unexpected
git interpret-trailersexecutions or child processes spawned by Node.js services - Automated dependency and security review tools that identify unsafe command-invocation patterns
Detection approaches can include:
- Static analysis for attacker-controlled data flowing into SimpleGitOptions.config, inline
-carguments, or Git process-spawning APIs - Code review checks for dynamic construction of Git configuration keys and trailer definitions
- Policy rules that reject
trailer.*.cmdand other command-bearing Git options unless explicitly approved - Runtime monitoring for unexpected
git interpret-trailersexecutions or child processes spawned by Node.js services - Automated dependency and security review tools that identify unsafe command-invocation patterns

