The WebP vulnerability: a tale of a CVE with much bigger impl
A heap buffer overflow existed in the libwebp library's lossless WebP decoder, where a crafted image with an unbalanced Huffman tree caused lookup tables to be written past their allocated buffer. An attacker could corrupt adjacent memory and potentially execute their own code in any application that decodes WebP images.
blog.cloudflare.com
Published on blog.cloudflare.com
At Cloudflare, we're constantly vigilant when it comes to identifying vulnerabilities that could potentially affect the Internet ecosystem. Recently, on September 12, 2023, Google announced a security issue in Google Chrome, titled "Heap buffer overflow in WebP in Google Chrome," which caught our attention.
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 decoder built Huffman lookup tables and wrote them into a heap buffer before validating that the tree was consistent, so an oversized tree overflowed the allocation.
Impact
A malformed WebP image could corrupt heap memory and potentially lead to execution of attacker-supplied code; the text notes the exploit appeared to target specific individuals rather than Cloudflare's infrastructure, and no attempts against Cloudflare were found in its logs.
What the attacker needed
Victim opens a crafted WebP image; software uses a vulnerable libwebp version
The fix
The library was fixed by validating the input so it always produces a valid internal structure and allocating more memory when needed so the buffer is always large enough.
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.
Images are stored in a compressed format, and the software that opens them has to unpack the data into memory. A flaw in that unpacking code meant a deliberately malformed image could make the program write past the space it reserved, overwriting nearby memory. Because the same image library is used by browsers, chat apps and operating systems, a single bad image could in principle be dangerous almost anywhere.
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.