SAIL Image Decoding Library BMPv3 RLE Decoding integer overflow vulnerability
The BMPv3 RLE decoder in SAIL v0.9.8 writes run-length encoded pixel data into a scan-line buffer without checking it against the image dimensions, so a crafted .bmp file causes a heap-based buffer overflow. An attacker who gets the library to decode such a file could achieve remote code execution in the context of the library.
A memory corruption vulnerability exists in the BMPv3 RLE Decoding functionality of the SAIL Image Decoding Library v0.9.8. When decompressing the image data from a specially crafted .bmp file, a heap-based buffer overflow can occur which allows for remote code execution.
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 report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the RLE8 decode loop trusts the run-length count from the file and writes that many bytes to the scan line without checking the count against the remaining width of the allocated row buffer.
Impact
A heap-based buffer overflow could allow code execution under the context of the library, though the attacker must first convince the library to read a crafted file.
What the attacker needed
Victim opens a crafted .bmp file; library decodes the file
The fix
The vendor released a patch on 2025-07-31, two days after disclosure.
How it was found
- Create a BMP with a v3 header whose compression field selects RLE8 and whose width and height are 1 with 8 bits per pixel.
- Place RLE-encoded data after the header where the first byte is a run count and the next byte is the colour index.
- Run the sail decode command on the crafted file.
- Observe AddressSanitizer reporting a heap-buffer-overflow write in the BMP frame reading function.
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 library reads a small picture file and reserves a tiny amount of memory for one row of pixels. The file then claims a run of many pixels, and the library writes them all into that tiny space, spilling past the end. That spill can corrupt other memory and, in the worst case, let an attacker run their own code.
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.