CVE-2018-16461: Libnmap Command Injection Vulnerability

MODERATE
Advisory Identifier: GHSA-7g2w-6r25-2j7p
CWE-77
Published
Advisory Summary

CVE-2018-16461 is a MODERATE command injection vulnerability (CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')) affecting Libnmap libraries in the npm ecosystem. The issue involves command injection in libnmap. Remediation is available by upgrading affected packages to version 0.4.16.

CVE-2018-16461 at a Glance

CVE Identifier CVE-2018-16461
GHSA Identifier GHSA-7g2w-6r25-2j7p
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')
Affected Product Libnmap
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2018-16461

To remediate this vulnerability, upgrade all affected Libnmap dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

libnmap fixed: 0.4.16
npm install libnmap@0.4.16
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls libnmap

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2018-16461, inspect your project dependencies using npm:

npm ls libnmap

Analyze the terminal output to locate any version of Libnmap in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.4.16), your application is affected.

Note: The npm ls libnmap command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection'), where the product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component. In Libnmap, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Versions of `libnmap` before 0.4.16 are vulnerable to command injection. Proof of concept ```js 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])); } }); ``` ## Recommendation Update to version 0.4.16 or later

CVE-2018-16461 Affected Libnmap Versions

1 component(s)
Fixed Versions:
0.4.16
Product / Package Ecosystem Affected Versions Fixed Version
libnmap
npm
< 0.4.16
0.4.16

References

Frequently Asked Questions

What is CVE-2018-16461?
CVE-2018-16461 is a security vulnerability in Libnmap involving Command Injection in libnmap under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').
Which Libnmap versions are affected?
Affected versions include releases prior to 0.4.16 across affected packages: libnmap.
What version fixes CVE-2018-16461?
Upgrading to 0.4.16 (or the latest patched release for your respective branch) resolves the vulnerability.
Is libnmap affected?
Yes, libnmap is affected in releases prior to 0.4.16. Upgrade your dependency to 0.4.16 or later.
What CWE is associated with CVE-2018-16461?
CVE-2018-16461 is classified under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection') (The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.).
How can I check npm dependencies for CVE-2018-16461?
Run the dependency tree command: 'npm ls libnmap'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-7g2w-6r25-2j7p",
  "modified" : "2023-09-07T18:15:41Z",
  "published" : "2018-11-01T14:51:33Z",
  "aliases" : [ "CVE-2018-16461" ],
  "summary" : "Command Injection in libnmap",
  "details" : "Versions of `libnmap` before 0.4.16 are vulnerable to command injection. \n\nProof of concept\n\n```js\nconst nmap = require('libnmap');\nconst opts = {\n    range: [\n        'scanme.nmap.org',\n        \"x.x.$(touch success.txt)\"\n    ]\n};\nnmap.scan(opts, function(err, report) {\n    if (err) throw new Error(err);\n\n    for (let item in report) {\n        console.log(JSON.stringify(report[item]));\n    }\n});\n```\n\n\n## Recommendation\n\nUpdate to version 0.4.16 or later",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "libnmap"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.4.16"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2018-16461"
  }, {
    "type" : "WEB",
    "url" : "https://hackerone.com/reports/390865"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-7g2w-6r25-2j7p"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nodejs/security-wg/blob/master/vuln/npm/474.json"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/advisories/719"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-77" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-06-16T21:22:42Z",
    "nvd_published_at" : null
  }
}