Skip to content
RCE Disclosed report Intermediate CVE-2019-15599

[tree-kill] RCE via insecure command concatenation (only Windows)

The tree-kill module concatenates user input directly 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.0 View original
  • Triaged in 19 hours
  • Fixed in 2 months
  • Disclosed after 2 months

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

Module

module name: tree-kill version: 1.2.1 npm page: https://www.npmjs.com/package/tree-kill

Module Description

Kill all processes in the process tree, including the root process.

Module Stats

[N/A] downloads in the last day [2,108,440] downloads in the last week [~10M] downloads in the last month

Vulnerability Description

The issue occurs because a user input is concatenated with a command that will be executed without any check. The issue arises here: https://github.com/pkrumins/node-tree-kill/blob/master/index.js#L20 (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('tree-kill');
kill('3333332 & echo "HACKED" > HACKED.txt & ');
  1. Execute the following commands in another 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. A new file called HACKED.txt will be created, containing the HACKED string

Note I can't provide a screenshot as I'm working on Linux (I'll be able to reinstall win only the next week), but the code showed in the module (line 20) makes clear the attack is possible. Pls note I'm not sure of the batch syntax used , as said I can't verify it on a win machine. Before close the report, share with me eventual problems, in order to make me able to determine if the provided PoC is fully working or lacks in something :)

Patch

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

Supporting Material/References:

  • [OPERATING SYSTEM VERSION]: Kali Linux (should be used a win OS ... I've simply checked the code)

Wrap up

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

Impact

RCE on tree-kill 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-supplied input into a shell command without sanitisation, unlike the Linux path which is sanitised.

Impact

An attacker could execute arbitrary commands on a Windows machine running the vulnerable module, but the reporter could not verify the exploit on Windows and only inferred it from the code.

What the attacker needed

Windows operating system; tree-kill module version 1.2.1; attacker controls input to tree-kill

The fix

The module should avoid concatenating user input into commands and instead sanitise or escape it properly.

How it was found

  1. Create a JavaScript file that calls the tree-kill module with a malicious input.
  2. Install the tree-kill module.
  3. Check that a file named HACKED.txt does not exist.
  4. Run the JavaScript file.
  5. Check that HACKED.txt now exists.

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.

tree-kill is a small program that stops other programs. On Windows, it builds a command by gluing together text you give it. Because it does not clean that text, someone can sneak in 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.