Severity:

CRITICAL RISK

(9.8)

Code Injection via Argument/Option Injection in simple-git

CVE-2026-6951

Modified

Vulnerability type

Category:

Code Injection via Argument/Option Injection

CWE:

CWE-94, CWE-88

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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-git package 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 options argument (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 clone or similar).
  • Why exploitation is possible: The previous fix blocked only the short -c Git configuration flag, not its long --config equivalent, allowing attackers to set protocol.ext.allow=always and use an ext:: 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 -c and --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-git where 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.allow or ext:: URLs, and alert on anomalies.

Sources

SourceLink
gist.github.comgist.github.com/KKC73/02d1d97f3410756095b501fda0ac8ca6
github.comgithub.com/steveukx/git-js/commit/89a2294febed5dfe737c4c735d936bb6018746a8
security.snyk.iosecurity.snyk.io/vuln/SNYK-JAVA-ORGWEBJARSNPM-16300211
security.snyk.iosecurity.snyk.io/vuln/SNYK-JS-SIMPLEGIT-15456078
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-6951
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2461750
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-6951.json

Frequently asked

questions

Yes, if the application exposes any network-accessible interface where user-controlled data can influence simple-git options or repository URLs, an attacker may be able to exploit the issue remotely to achieve code execution.

The attacker needs the ability to control or significantly influence inputs that flow into the simple-git options or Git command construction. This can be as minimal as being an unauthenticated web user, if those inputs are exposed without proper validation, or as high as having limited authenticated access in admin or CI configuration panels.

The safest pattern is to avoid passing user-controlled data into Git options entirely, and to constrain repository URLs to a vetted set of schemes and hosts. Wrap simple-git in a minimal API that uses only static, pre-defined options, and validate or normalize all remaining inputs against a strict allowlist.

Treat all interactions with external tools (like Git) as security-sensitive: use strict allowlists instead of blacklists, normalize input before validation, and avoid exposing low-level flags to callers. Incorporate security reviews for command construction logic, add automated checks for dangerous flags and protocols, and consider isolating external command execution in hardened, least-privilege environments.

Find out what's already
exploitable in your codebase.