Skip to content
Memory corruption Write-up Advanced

Now Patched Vulnerability in WhatsApp could have led to data exposure of users

A heap-based out-of-bounds read and write existed in WhatsApp's image filter function because it assumed source and destination images had the same RGBA format. An attacker could send a crafted image that, when a user applied a filter and sent it back, caused memory corruption and potentially exposed sensitive information from WhatsApp memory.

Dikla Barda Follow

Published on research.checkpoint.com

As of 2021, WhatsApp is the most popular global mobile messenger app worldwide with approximately two billion monthly active users. It allows users to send text and voice messages, make voice and video calls, and share images, documents, user locations, and other content.

etal, on research.checkpoint.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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

How it worked

Root cause

The applyFilterIntoBuffer function did not validate that the source and filter images were in RGBA format (4 bytes per pixel) before iterating and copying pixels, leading to out-of-bounds access when a crafted image had a different format.

Impact

The vulnerability could have potentially led to the exposure of sensitive information from WhatsApp memory, but exploitation required a unique and complicated set of circumstances and extensive user interaction, and WhatsApp saw no evidence of abuse.

What the attacker needed

Victim opens a crafted image attachment; victim applies a filter to the image; victim sends the filtered image back

The fix

WhatsApp fixed the issue in version 2.21.1.13 by adding checks that both source and filter images are in RGBA format and that the image size matches the expected 4 bytes per pixel.

How it was found

  1. Generate malformed image files using AFL fuzzing on WhatsApp image libraries.
  2. Open a crafted GIF attachment in WhatsApp.
  3. Switch between various filters on the crafted image, causing WhatsApp to crash.
  4. Send the filtered image back to the attacker.

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 write-up has not been written yet. The Original tab links to the source.

When you apply a filter to a photo in WhatsApp, the app reads the image data and writes new pixel values. The code assumed every image uses four bytes per pixel, but a specially crafted image used only one byte per pixel, so the app read and wrote past the end of the image buffer. This memory corruption could crash the app and, in theory, leak data from 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 from Meta

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.