SAIL Image Decoding Library Targa RLE Decoding heap-based buffer overflow vulnerability
A heap-based buffer overflow exists in the Targa RLE decoding of the SAIL image library. An attacker could craft a malicious .tga file that, when decoded, overflows a heap buffer and may lead to remote code execution.
A memory corruption vulnerability exists in the PCX Image Decoding functionality of the SAIL Image Decoding Library v0.9.8. When decoding the image data from a specially crafted .tga 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
The RLE decoding loop does not validate that the total number of pixels written stays within the allocated buffer size.
Impact
A crafted TGA file could cause a heap buffer overflow, potentially leading to code execution under the context of the library.
What the attacker needed
Victim opens a malicious .tga file
The fix
The vendor released a patch on 2025-07-30.
How it was found
- Craft a TGA file with an RLE image type (indexed, true-color, or grayscale).
- Set the image width and height to small values so the allocated buffer is tiny.
- Include an RLE packet whose repetition count exceeds the buffer size.
- Decode the file with the SAIL library to trigger the heap overflow.
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 decoded, the program reserves a fixed amount of memory based on the image's width and height. The Targa format can compress runs of identical pixels, and the decoder trusts the run length without checking if it fits in that reserved memory. A malicious file can therefore write past the end of the buffer, corrupting memory and potentially letting 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.