Skip to content
RCE Disclosed report Intermediate

[meta-git] RCE via insecure command formatting

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

mik317 Follow

Originally disclosed on HackerOne

Medium 6.2 View original
  • Triaged in 25 hours
  • Fixed in 2 months
  • Disclosed after 2 months

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

Module

module name: meta-git version: 1.1.2 npm page: https://www.npmjs.com/package/meta-git

Module Description

git plugin for meta

Module Stats

[~60] downloads in the last day [429] downloads in the last week [~2k] 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/mateodelnorte/meta-git/blob/master/lib/metaGitUpdate.js#L49

Steps To Reproduce:

  1. Create a new directory and insert some test files:
Bash
mkdir tests
cd tests
touch test
touch secret
touch files
  1. Check there aren't files called HACKED
  2. Execute the following commands in another terminal:
Bash
npm i meta-git -g # Install affected module
meta-git clone 'sss||touch HACKED' # *HACKED* file is created
  1. Recheck the files: now HACKED has been created :)
    Screenshot_from_2019-11-02_23-08-42.png
    Screenshot_from_2019-11-02_23-08-42.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 meta-git

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

User input is concatenated into a shell command string that is executed without sanitisation, allowing shell metacharacters to inject extra commands.

Impact

An attacker could execute arbitrary commands remotely on the victim's PC through the crafted argument.

What the attacker needed

Meta-git installed; attacker controls the clone argument

The fix

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

How it was found

  1. Create a new directory and add some test files.
  2. Confirm no file named HACKED exists.
  3. Install the affected meta-git module globally.
  4. Run the clone command with a crafted argument.
  5. Check the directory again and see the HACKED 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 tool takes text you type on the command line and pastes it into a system command that the computer then runs. Because it does not clean that text first, someone can add extra instructions that the computer also runs, such as creating a file. That means an attacker could run their own programs on your machine.

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.