Skip to content
Memory corruption Disclosed report Beginner

`utile` allocates uninitialized Buffers when number is passed in input

The base64 encode and decode functions in the utile module allocate buffers without initialising them when a number is passed as input. On Node.js 6.x and below this could expose sensitive data from uninitialised memory, and on any Node.js version a large number could cause a denial of service by consuming memory.

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 utile. It allows to 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 (e.g. from JSON).

Module

module name: utile version: 0.3.0 npm page: https://www.npmjs.com/package/utile

Module Description

A drop-in replacement for util with some additional advantageous functions

Module Stats

101 762 downloads in the last day 560 195 downloads in the last week 2 301 434 downloads in the last month

Vulnerability

Vulnerability Description

See https://github.com/flatiron/utile/blob/master/lib/base64.js#L19 in utile.base64.encode (and similar in utile.base64.decode below that).

The problem arises when a number is passed in, e.g. from user-submitted JSON-encoded data. 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.

This can be also used to cause a DoS on any Node.js version by consuming the memory when large numbers are passed on input.

Steps To Reproduce:

console.log(require('utile').base64.encode(200)) (Node.js 6.x and lower — note uninitialized memory in output)

require('utile').base64.encode(1e8) (any Node.js verision — note memory usage and time)

Supporting Material/References:

State all technical information about the stack where the vulnerability was found

  • OS: Arch Linux current
  • Node.js 6.13.0
  • Node.js 9.5.0

Wrap up

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

I contacted the maintainer over email on 2016-01-20, got an initial reply, replied back, but nothing happened since then.

Impact

Sensitive uninitialized memory exposure on Node.js 6.x or lower Denail of Service on any Node.js version

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

Root cause

Likely the base64 encode and decode functions pass a number directly to Buffer allocation without checking the input type or initialising the buffer.

Impact

On Node.js 6.x and below, sensitive data from uninitialised memory could be exposed; on any Node.js version, a large number could cause a denial of service by consuming memory.

What the attacker needed

User input can be passed as a number; Node.js 6.x or lower for memory exposure

How it was found

  1. Call the base64 encode function with a small number on Node.js 6.x or lower and observe uninitialised memory in the output.
  2. Call the base64 encode function with a very large number on any Node.js version and observe high memory usage and time.

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 buffer (a chunk of memory for data), it should fill it with zeros first. If it does not, the buffer may contain leftover data from other parts of the program, which could be private. Also, if a user can supply a number instead of text, the program might try to create an enormous buffer and run out of memory, crashing the service.

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.