Skip to content
Memory corruption Disclosed report Intermediate

`put` allocates uninitialized Buffers when non-round numbers are passed in input

The `put` module allocates a Buffer that is larger than the number of bytes actually written when non-integer values are passed to `pad`, and it does not trim the buffer. On Node.js 6.x and below, this exposes uninitialized memory that could contain sensitive data.

chalker Follow

Originally disclosed on HackerOne

  • Triaged in 9 days
  • Fixed in 2 months
  • Disclosed after 3 months

I would like to report an uninitialized Buffer allocation issue in put. It allows to extract sensitive data from uninitialized memory by passing in non-round numbers, in setups where typed user input can be passed (e.g. from JSON).

Module

module name: put version: 0.0.6 npm page: https://www.npmjs.com/package/put

Module Description

Pack multibyte binary values into buffers with specific endiannesses.

Module Stats

402 downloads in the last day 3 889 downloads in the last week 17 107 downloads in the last month

Vulnerability

Vulnerability Description

put incorrectly calculates the total length of the allocated Buffer and does not trim it to the total bytes written, see https://github.com/substack/node-put/blob/master/index.js#L51

The problem arises when non-round numbers are passed in to the pad function. The API should not propagate the already-bad Buffer issue further.

On Node.js 6.x and below, this exposes uninitialized memory, which could contain sensitive data.

Steps To Reproduce:

JavaScript
var Put = require('put');
var buf = Put().pad(0.99).pad(0.99).pad(0.99).pad(0.99).pad(0.99).buffer();
console.log(buf);
JavaScript
var Put = require('put');
var buf = Put();
for (var i = 0; i < 10000; i++) buf.pad(0.99);
console.log(buf.buffer().toString('ascii'));

Run on Node.js 6.x or below.

Supporting Material/References:

  • OS: Arch Linux current
  • Node.js 6.13.0

Wrap up

  • I contacted the maintainer to let them know: N
  • I opened an issue in the related repository: N

Impact

Sensitive uninitialized memory exposure on Node.js 6.x or lower

The original report as published on HackerOne, by chalker. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

On Node.js 6.x and below, sensitive uninitialized memory could be exposed.

What the attacker needed

Node.js 6.x or below; ability to pass non-round numbers to pad

The fix

The module should not propagate the bad Buffer issue further.

How it was found

  1. Require the `put` module.
  2. Create a Put instance and call `pad` repeatedly with a non-round number such as 0.99.
  3. Call `buffer()` to get the resulting buffer.
  4. Run on Node.js 6.x or below to observe uninitialized memory.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a program creates a new memory buffer, it sometimes gets memory that still holds old data from other programs. If the program doesn't fill the whole buffer but still sends it out, that old data can leak. Here, passing decimal numbers to a padding function made the buffer bigger than needed, so the extra part was never overwritten and could be read.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by chalker

View all

36 more disclosed reports, best first.

More from Node.js third-party modules

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.