Skip to content
DoS Disclosed report Intermediate CVE-2020-8175

Pixel flood attack cause the javascript heap out of memory

The jimp image library trusted EXIF orientation data in an uploaded image, so a tiny crafted file claiming enormous dimensions caused the library to try to allocate billions of pixels. An attacker could exhaust the JavaScript heap and crash the Node process, causing a denial of service.

mayaseven Follow

Originally disclosed on HackerOne

Medium 5.3 View original
  • Triaged in 20 hours
  • Fixed in 43 days
  • Disclosed after 44 days

I would like to report Pixel flood attack in jimp It allows flooding the memory and causing DoS by uploading a crafted image (5kb image), and the Jimp module will tries to allocate 4128062500 pixels into memory.

Module

module name: jimp version: <=0.10.1 npm page: https://www.npmjs.com/package/jimp

Module Description

An image processing library for Node written entirely in JavaScript, with zero native dependencies.

Module Stats

1,053,700 Weekly Downloads

Vulnerability

Vulnerability Description

The jimp module will load the pixel from the image file to the memory, and processing the image in order to get a new image file such as resize, rotate, blur, etc. The jimp using EXIF data for picture orientation, which was causing run out of memory in the system. The attacker could manipulate the exif data in the image file such as change the image pixel to 64250x64250pixels. If the jimp module loaded the crafted image, it tries to allocate 4128062500 pixels into memory.

Steps To Reproduce:

  1. First, install the jimp module : npm install --save jimp
  2. Second, download a crafted image from the attachment (lottapixel.jpg).
  3. Finally, create index.js file as the PoC code below and execute.
var Jimp = require('jimp');

Jimp.read('lottapixel.jpg', (err, lenna) => {
  if (err) throw err;
  lenna
    .resize(256, 256) // resize
    .quality(60) // set JPEG quality
    .greyscale() // set greyscale
    .write('image-small-bw.jpg'); // save
});

The output will display the error message like below when the memory is exhausted.

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Patch

Disable ImageMagick's EXIF orientation.

Supporting Material/References:

  • Pixel flood attack https://hackerone.com/reports/390
  • Nodejs v13.12.0

Wrap up

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

Impact

Denail of Service

Attachments

The original report as published on HackerOne, by mayaseven. 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 library derived image dimensions from untrusted EXIF orientation data without validating them against the actual file size before allocating memory.

Impact

An attacker could cause a denial of service by exhausting the JavaScript heap, crashing the process that processes the image.

What the attacker needed

Ability to submit an image to the target; target processes images with jimp

The fix

The suggested fix is to disable ImageMagick's EXIF orientation handling; the text does not say whether it was applied.

How it was found

  1. Install the jimp module.
  2. Obtain the crafted image file.
  3. Create a small script that reads the image, resizes it, sets quality, converts to greyscale and writes the output.
  4. Run the script and observe the heap out of memory error.

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.

An image file can carry hidden metadata called EXIF, which includes a note about how the picture should be rotated. This library believed that note and used it to decide how much memory to reserve, so a very small file could claim to be gigantic. The program then ran out of memory and stopped working, which is a denial of service.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.