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

[treekill] RCE via insecure command concatenation (only Windows)

The treekill module concatenates user input into a Windows command without sanitisation, allowing an attacker to execute arbitrary commands. The reporter demonstrated that a crafted input could create a file on the victim's machine.

mik317 Follow

Originally disclosed on HackerOne

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

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

Module

module name: treekill version: 1.0.0 npm page: https://www.npmjs.com/package/treekill

Module Description

treekill process and it's all children and child offspring children.

Module Stats

[N/A] downloads in the last day [106] 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: https://github.com/node-modules/treekill/blob/master/index.js#L32 (as you can see, the Linux part is sanitized, while the Win one no ... it simply uses the + operand to concatenate the input)

Steps To Reproduce:

  1. Create the following PoC file:
JavaScript
// poc.js
var kill = require('treekill');
kill('3333332 & echo "HACKED" > HACKED.txt & ');
  1. Execute the following commands in terminal:
Bash
npm i tree-kill # Install affected module
dir # Check *HACKED.txt* doesn't exist
node poc.js #  Run the PoC
dir # Now *HACKED.txt* exists :)
  1. The HACKED.txt has been created

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]

PS: Note I'm working on a LInux machine, so I'm not sure if the syntax used to inject the command is successfull ... anyway, the issue is possible, as you can see from the code. If you'll not be able to reproduce the PoC, let me know and I'll switch on a Win machine in order to make working the PoC.

Impact

RCE on treekill 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 Windows code path concatenates user input directly into a shell command without sanitisation, unlike the Linux path which sanitises it.

Impact

An attacker could execute arbitrary commands on a Windows victim's machine, but the reporter was not sure the injection syntax would work on Windows and had not tested it there.

What the attacker needed

Windows operating system; Attacker controls the input to treekill

The fix

The fix is to avoid concatenating user input into commands and to sanitise or validate the input before use.

How it was found

  1. Create a PoC file that calls the treekill function with a malicious input.
  2. Install the affected treekill module.
  3. Check that the target file does not exist.
  4. Run the PoC script.
  5. Check that the target file now exists, confirming command execution.

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 is a remote code execution (RCE) bug in a small Node.js package called treekill. The package builds a system command by gluing together a user-supplied string, and on Windows it does not clean that string first. So if an attacker can control that string, they can add extra commands that the computer will run.

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.