Last tested: 31 Jul, 2018

jshint vulnerabilities

Static analysis tool for JavaScript

View on npm

jshint (latest)

Published 30 Jul, 2018

Known vulnerabilities1
Vulnerable paths1
Dependencies136

Command Injection

high severity

Detailed paths

  • Introduced through: jshint@2.9.6 > shelljs@0.3.0

Overview

shelljs is a portable Unix shell commands for Node.js.

Affected version of this package are vulnerable to Command Injection. It is possible to invoke commands from shell.exec() from external sources, allowing an attacker to inject arbitrary commands.

Remediation

There is no fix version for shelljs.

References

Vulnerable versions of jshint

Fixed in 2.9.6

Prototype Pollution

low severity
  • Vulnerable module: lodash
  • Introduced through: lodash@3.7.0

Detailed paths

  • Introduced through: jshint@2.9.5 > lodash@3.7.0

Overview

lodash is a javaScript utility library delivering modularity, performance & extras.

Affected versions of this package are vulnerable to Prototype Pollution. The utilities function allow modification of the Object prototype. If an attacker can control part of the structure passed to this function, they could add or modify an existing property.

PoC by Olivier Arteau (HoLyVieR)

var _= require('lodash');
var malicious_payload = '{"__proto__":{"oops":"It works !"}}';

var a = {};
console.log("Before : " + a.oops);
_.merge({}, JSON.parse(malicious_payload));
console.log("After : " + a.oops);

Remediation

Upgrade lodash to version 4.17.5 or higher.

References

Fixed in 2.9.3

Insecure use of /tmp folder

low severity
  • Vulnerable module: cli
  • Introduced through: cli@0.6.6

Detailed paths

  • Introduced through: jshint@2.9.2 > cli@0.6.6

Overview

cli is an npm package used for rapidly building command line apps.

When used in daemon mode, the library makes insecure use of two files in the /tmp/ folder: /tmp/<app-name>.pid and /tmp/<app-name>.log. These allow an attacker to overwrite files they typically cannot access, but that are accessible by the user running the CLI-using app. This is possible since the /tmp/ folder is (typically) writeable to all system users, and because the names of the files in question are easily predicted by an attacker.

Note that while this is a real vulnerability, it relies on functionality (daemon mode) which is only supported in very old Node versions (0.8 or older), and so is unlikely to be used by most cli users. To avoid any doubt, the fixed version (1.0.0) removes support for this feature entirely.

Details

For example, assume user victim occasionally runs a CLI tool called cli-tool, which uses the cli package. If an attacker gains write access to the /tmp/ folder of that machine (but not the higher permissions victim has), they can create the symbolic link /tmp/cli-tool.pid -> /home/victim/important-file. When victim runs cli-tool, the important-file in victim's root directory will be nullified. If the CLI tool is run as root, the same can be done to nullify /etc/passwd and make the system unbootable.

Note that popular CLI tools have no reason to mask their names, and so attackers can easily guess a long list of tools victims may run by checking the cli package dependents.

Remediation

Upgrade cli to version 1.0.0 or greater, which disables the affected feature.

From the fix release notes:

This feature relies on a beta release (e.g. version 0.5.1) of a Node.js
module on npm--one that was superseded by a stable (e.g. version 1.0)
release published three years ago [2]. Due to a build-time dependency on
the long-since deprecated `node-waf` tool, the module at that version
can only be built for Node.js versions 0.8 and below.

Given this, actual usage of this feature is likely very limited. Remove
it completely so the integrity of this module's core functionality can
be verified.

References

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809252 [2] https://github.com/node-js-libs/cli/commit/fd6bc4d2a901aabe0bb6067fbcc14a4fe3faa8b9

Regular Expression Denial of Service (DoS)

high severity

Detailed paths

  • Introduced through: jshint@2.9.2 > minimatch@2.0.10
  • Introduced through: jshint@2.9.2 > cli@0.6.6 > glob@3.2.11 > minimatch@0.3.0

Overview

minimatch is a minimalistic matching library used for converting glob expressions into JavaScript RegExp objects. Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) attacks.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Many Regular Expression implementations may reach edge cases that causes them to work very slowly (exponentially related to input size), allowing an attacker to exploit this and can cause the program to enter these extreme situations by using a specially crafted input and cause the service to excessively consume CPU, resulting in a Denial of Service.

An attacker can provide a long value to the minimatch function, which nearly matches the pattern being matched. This will cause the regular expression matching to take a long time, all the while occupying the event loop and preventing it from processing other requests and making the server unavailable (a Denial of Service attack).

You can read more about Regular Expression Denial of Service (ReDoS) on our blog.

Remediation

Upgrade minimatch to version 3.0.2 or greater.

References