Uninitialized Memory Exposure

Affecting npmconf package, versions <2.1.3

Do your applications use this vulnerable package? Test your applications

Overview

Affected versions of npmconf are vulnerable to Uninitialized Memory Exposure. It allocates and writes to disk uninitialized memory content when a typed number is passed as input.

Details

The Buffer class on Node.js is a mutable array of binary data, and can be initialized with a string, array or number.

const buf1 = new Buffer([1,2,3]);
// creates a buffer containing [01, 02, 03]
const buf2 = new Buffer('test');
// creates a buffer containing ASCII bytes [74, 65, 73, 74]
const buf3 = new Buffer(10);
// creates a buffer of length 10

The first two variants simply create a binary representation of the value it received. The last one, however, pre-allocates a buffer of the specified size, making it a useful buffer, especially when reading data from a stream. When using the number constructor of Buffer, it will allocate the memory, but will not fill it with zeros. Instead, the allocated buffer will hold whatever was in memory at the time. If the buffer is not zeroed by using buf.fill(0), it may leak sensitive information like keys, source code, and system info.

Remediation

Upgrade npmconf to version 2.1.3. Note npmconf is deprecated and should not be used. Note This is vulnerable only for Node <=4

References

CVSS Score

7.4
high severity
  • Attack Vector
    Network
  • Attack Complexity
    Low
  • Privileges Required
    None
  • User Interaction
    Required
  • Scope
    Changed
  • Confidentiality
    High
  • Integrity
    None
  • Availability
    None
CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N/E:F/RL:O/RC:C
Credit
ChALkeR
CWE
CWE-201
Snyk ID
npm:npmconf:20180512
Disclosed
12 May, 2018
Published
13 May, 2018