Insecure use of /tmp folder Affecting cli package, versions <1.0.0


Severity

Recommended
0.0
low
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0.14% (51st percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDnpm:cli:20160615
  • published27 Aug 2016
  • disclosed28 Dec 2015
  • creditSteve Kemp

Introduced: 28 Dec 2015

CVE-2016-10538  (opens in a new tab)
CWE-59  (opens in a new tab)

How to fix?

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.

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.

This vulnerability has also been assigned CVE-2016-1000021.

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.

CVSS Scores

version 3.1