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

Command Injection vulnerability in kill-port-process package

The kill-port-process package passed a caller-supplied port value into a shell command without sanitising it, so a value containing shell syntax would run as a command. An attacker who controls the port argument could therefore execute arbitrary commands with the privileges of the process, which the report says is root.

effectrenan Follow

Originally disclosed on HackerOne

Medium 6.1 View original
  • Triaged in 3 days
  • Fixed in 5 months
  • Disclosed after 6 months

I would like to report a command injection vulnerability in the kill-port-process package. It allows an attacker to inject arbitrary commands.

Module

module name: kill-port-process version: 1.1.0 npm page: https://www.npmjs.com/package/kill-port-process

Module Stats

0 downloads in the last day 138 downloads in the last week 660 downloads in the last month

Vulnerability

Vulnerability Description

The attacker can control the port number. Then He/She can insert a shell command instead of a port number. The root user is the only user execute kill command on the OS, thus root will execute an arbitrary command.

Steps To Reproduce:

Installing the module: npm install kill-port-process -E

Following the example in the npm page:

JavaScript
const killPortProcess = require('kill-port-process');
const PORT = "$(<Shell Command>)";
await killPortProcess(PORT);

CLI mode:

Shell
kill-port "$(<Shell Command>)"

Patch

In the file src/lib/killer.ts: Replace: import { exec } from 'child_process' To: import { spawn } from 'child_process'

Supporting Material/References:

  • Arch Linux 5.2.1 x64
  • NODEJS 11.15.0
  • NPM 6.10.2

Wrap up

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

Impact

An attacker can execute arbitrary commands on the victim's machine.

The original report as published on HackerOne, by effectrenan. 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 port value was interpolated into a string passed to child_process exec, which runs it through a shell, instead of being passed as a separate argument.

Impact

An attacker who can influence the port argument could run arbitrary commands on the host, and the report claims this happens as root, though that depends on how the package is invoked.

What the attacker needed

Attacker controls the port value; package runs with elevated privileges

The fix

The report suggests switching from exec to spawn so the value is not interpreted by a shell; it does not say whether this was applied.

How it was found

  1. Install the package at the stated version.
  2. Call the exported function, passing a port value that contains shell syntax.
  3. Alternatively run the command-line tool with the same crafted value.
  4. The shell interprets the injected part and runs the extra command.

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 package is meant to stop whatever program is using a given network port. It took the port number as text and handed it to the operating system's command shell, which treats certain characters as instructions rather than plain text. Because of that, someone who can choose the port value can sneak extra commands in, and those commands run with the same power as the program using the package.

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 effectrenan

View all

1 more disclosed report, 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.