`atob` allocates uninitialized Buffers when number is passed in input on Node.js 4.x and below
The atob module passed a number input directly to Buffer allocation, which on Node.js 4.x and below returned uninitialized memory. An attacker could read sensitive data from that memory or cause a denial of service by supplying a very large number.
- Triaged in 33 days
- Fixed in 36 days
- Disclosed after 36 days
I would like to report an uninitialized Buffer allocation issue in atob.
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: atob
version: 2.0.3
npm page: https://www.npmjs.com/package/atob
Module Description
Uses Buffer to emulate the exact functionality of the browser's atob.
Module Stats
492 191 downloads in the last day 2 890 027 downloads in the last week 11 036 537 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('atob')(1000)) (note uninitialized memory in output)
console.log(require('atob')(1e8)) (note memory usage and time)
Run on Node.js 4.x (or below).
Supporting Material/References:
- Arch Linux Current
- Node.js 4.8.7
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 Denail of Service This issue affects only setups using Node.js 4.x (still supported) or lower.
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 passed a numeric input straight to Buffer allocation without validating the type, and on Node.js 4.x and below Buffer allocation returned uninitialized memory.
Impact
An attacker could read sensitive data left in uninitialized memory or cause a denial of service by consuming memory, but only on setups using Node.js 4.x or lower.
What the attacker needed
Node.js 4.x or lower; attacker-controlled input reaches atob
The fix
The API should not pass the bad Buffer issue further.
How it was found
- Run the module with a small number as input on Node.js 4.x or below and observe uninitialized memory in the output.
- Run the module with a very large number as input and observe 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 asks the computer for memory, it should clear it first. On older Node.js versions, asking for memory without clearing it can hand back leftover data from other programs, which might include passwords or other secrets. This module let a number from user input reach that memory request, so an attacker could see the leftovers or ask for a huge amount and exhaust 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.