Skip to content
RCE Disclosed report Beginner

[git-promise] RCE via insecure command formatting

The git-promise module builds a shell command by inserting user-supplied input without any validation, so a crafted argument can run extra shell commands. An attacker who can influence the argument passed to the module could execute arbitrary commands on the victim's machine.

mik317 Follow

Originally disclosed on HackerOne

Medium 6.2 View original
  • Triaged in 24 hours
  • Fixed in 6 months
  • Disclosed after 6 months

I would like to report a RCE issue in the git-promise module. It allows to execute arbitrary commands remotely inside the victim's PC

Module

module name: git-promise version: 0.3.1 npm page: https://www.npmjs.com/package/git-promise

Module Description

Simple wrapper that allows you to run any git command using a more intuitive syntax.

Module Stats

[~1.5k] downloads in the last day [11,322] downloads in the last week [~45k] downloads in the last month

Vulnerability Description

The issue occurs because a user input is formatted inside a command that will be executed without any check. The issue arises here: https://github.com/piuccio/git-promise/blob/master/index.js#L9

Steps To Reproduce:

  1. Create the following PoC file:
JavaScript
// poc.js
var git = require("git-promise");
 
git("init;touch HACKED").then(function (branch) {
  console.log(branch); // This is your current branch
});

  1. Check there aren't files called HACKED
  2. Execute the following commands in another terminal:
Bash
npm i git-promise # Install affected module
node poc.js #  Run the PoC
  1. Recheck the files: now HACKED has been created :)
    Screenshot_from_2019-11-02_23-31-57.png
    Screenshot_from_2019-11-02_23-31-57.png From the original on HackerOne

Patch

Don't format commands using insecure user's inputs :)

Supporting Material/References:

  • [OPERATING SYSTEM VERSION]: Kali Linux

Wrap up

  • I contacted the maintainer to let them know: [N]
  • I opened an issue in the related repository: [N]

Impact

RCE via command formatting on git-promise

The original report as published on HackerOne, by mik317. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the module concatenates user input into a shell command string and executes it through a shell, so shell metacharacters in the input are interpreted as separate commands.

Impact

An attacker able to control the argument passed to the module could execute arbitrary commands on the victim's machine.

What the attacker needed

Attacker controls argument passed to module; victim application uses git-promise

The fix

The module should stop building shell commands from user input, for example by passing arguments separately rather than concatenating them into a command string.

How it was found

  1. Create a small script that calls the module with an argument containing an extra shell command.
  2. Confirm the marker file does not exist yet.
  3. Install the affected module and run the script.
  4. Check again and observe that the marker file was created.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

This package lets a program run git commands. It takes whatever text the program passes in and glues it straight into a shell command, so extra commands hidden in that text also run. That means someone who controls the text can make the computer run their own commands.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by mik317

View all

23 more disclosed reports, best first.

More from Node.js third-party modules

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.