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

Command Injection Vulnerability in kill-port Package

The kill-port npm package passes a user-supplied port value into a shell command via exec, so an attacker who controls the port can inject arbitrary operating system commands. The reporter notes that real-world impact is likely low because port values are rarely attacker-controlled.

cris_semmle Follow

Originally disclosed on HackerOne

High 7.3 View original
  • Triaged in 4 days
  • Fixed in 4 months
  • Disclosed after 5 months

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

Module

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

Module Description

Kill the process running on given port

Module Stats

5,282 downloads in the last week

Vulnerability

Vulnerability Description

If an attacker can control the port, which in itself is a very sensitive value, he can inject arbitrary OS commands due to the usage of exec in a third-party module.

Steps To Reproduce:

JavaScript
const kill = require('kill-port');
kill("23;`touch ./success.txt; 2222222222`");

Patch

N/A replace exec (through execa.shell) with spawn

Supporting Material/References:

Wrap up

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

Impact

She can inject arbitrary commands. However, I assume that the real impact is not that high, since for most usages of the package I do not expect the user to be able to control the port value.

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

The package passes the port value into a shell command through exec (via execa.shell) without sanitising it, so shell metacharacters are interpreted.

Impact

An attacker who can control the port value could run arbitrary commands, though the reporter assumes real impact is low because port values are rarely user-controlled.

What the attacker needed

Attacker controls the port value passed to kill-port

The fix

The package should replace exec (through execa.shell) with spawn so the port is passed as an argument rather than interpreted by a shell.

How it was found

  1. Call the package's kill function with a port value that contains shell metacharacters and extra commands.

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 builds a command string and hands it to the operating system's shell, so special characters in the port value are treated as shell instructions rather than as part of a number. An attacker who can choose the port value can therefore 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 by cris_semmle

View all

8 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.