SAIL Image Decoding Library BMPv3 Image Decoding integer overflow vulnerability
An integer overflow in the SAIL BMP image decoder's stride calculation leads to an undersized heap buffer, which is then overflowed when decoding a crafted BMP file. An attacker could exploit this to cause memory corruption and potentially achieve remote code execution.
A memory corruption vulnerability exists in the BMPv3 Image Decoding functionality of the SAIL Image Decoding Library v0.9.8. When loading a specially crafted .bmp file, an integer overflow can be made to occur when calculating the stride for decoding.
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
Impact
This could lead to remote code execution under the context of the library, but the attacker must convince the library to read a malicious file.
What the attacker needed
Victim opens a crafted BMP file
How it was found
- Craft a BMP file with a v2 or larger header, BI_RGB compression, and dimensions that cause the stride times height to overflow.
- Open the crafted BMP file with the SAIL library.
- The library allocates an undersized buffer based on the overflowed size.
- During decoding, the library reads image data into the buffer, overflowing it.
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 an image is loaded, the program calculates how much memory is needed by multiplying the image's width and height. If these numbers are very large, the multiplication can wrap around to a small number, so too little memory is reserved. The program then writes the image data into that small space, overflowing it and corrupting memory, which can 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.