Uninitialized Memory Exposure

Affecting stringstream package, versions <0.0.6

Do your applications use this vulnerable package? Test your applications

Overview

stringstream Encode and decode streams into string streams in node.js.

Affected versions of this package are vulnerable to Uninitialized Memory Exposure. An attacker could extract sensitive data from uninitialized memory or to cause a DoS by passing in a large number, in setups where typed user input can be passed to the stream (e.g. from JSON).

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.

Note This is vulnerable only for Node <=4

Remediation

Upgrade stringstream to version 0.0.6 or higher.

References

Snyk patch available for versions:

CVSS Score

5.2
medium severity

Exploit: Mature
  • Attack Vector
    Physical
  • Attack Complexity
    Low
  • Privileges Required
    None
  • User Interaction
    None
  • Scope
    Unchanged
  • Confidentiality
    Low
  • Integrity
    None
  • Availability
    High
  • Exploit maturity
    Functional
  • Remediation Level
    Official
CVSS:3.0/AV:P/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:H/E:F/RL:O/RC:C
Credit
ChALkeR
CWE
CWE-201 CWE-215
Snyk ID
npm:stringstream:20180511
Disclosed
11 May, 2018
Published
13 May, 2018