Skip to content
Memory corruption Disclosed report Intermediate

`base64url` allocates uninitialized Buffers when number is passed in input on Node.js 4.x and below

The base64url module allocates uninitialized Buffers when a number is passed as input, exposing sensitive memory contents on Node.js 4.x and below. An attacker could extract data from uninitialized memory or cause a denial of service by passing a large number.

chalker Follow

Originally disclosed on HackerOne

High 7.1 View original
  • Triaged in 35 days
  • Fixed in 2 months
  • Disclosed after 2 months

I would like to report an uninitialized Buffer allocation issue in base64url. 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), on Node.js 4.x and lower.

Module

module name: base64url version: 2.0.0 npm page: https://www.npmjs.com/package/base64url

Module Description

Converting to, and from, base64url

Module Stats

182 924 downloads in the last day 1 097 142 downloads in the last week 4 601 176 downloads in the last month

Vulnerability

Vulnerability Description

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 4.x and below (4.x is still supported), this exposes uninitialized memory, which could contain sensitive data. This can be also used to cause a DoS by consuming the memory when large numbers are passed on input.

Steps To Reproduce:

console.log(require('base64url').encode(1000)) (note uninitialized memory in output) require('base64url').encode(1e8) (note memory usage and time)

Supporting Material/References:

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

  • Arch Linux Current
  • Node.js 4.8.7

Wrap up

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

I tried to contact the maintainer over email, first time on 2017-03-02, last time on 2018-02-18, but did not receive a reply.

Impact

Sensitive uninitialized memory exposure Denail of Service This issue affects only setups using Node.js 4.x (still supported) 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

Root cause

Likely the module did not validate the input type and passed a number directly to Buffer allocation, which on Node.js 4.x and below does not zero-fill memory.

Impact

On Node.js 4.x and below, an attacker could read sensitive data from uninitialized memory or cause a denial of service by consuming memory with large numbers; other Node.js versions are not affected.

What the attacker needed

Node.js 4.x or lower; user input passed as a number

How it was found

  1. Call the encode function with a number such as 1000 and observe uninitialized memory in the output.
  2. Call the encode function with a very large number such as 1e8 and observe increased 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 new memory buffer, it should clear it first. If it does not, the buffer may contain leftover data from other programs, which could be sensitive. Here, passing a number instead of a string caused the module to create such an uncleared buffer, potentially leaking data or using too much memory.

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.