Executive brief
Pillow, a widely used Python library for image processing, contains a flaw in how it handles certain image compression tasks. When saving images in the TGA format with RLE compression, the library may accidentally include sensitive data from the computer's memory into the resulting image file. This could allow an attacker to obtain private information, such as fragments of other files or system data, by analyzing images generated by a vulnerable application.
Technical details
An out-of-bounds read vulnerability exists in the TGA RLE encoder of Pillow. The root cause is a mismatch between buffer allocation and the encoding logic: for mode '1' (1-bit) images, the row buffer is allocated using a packed-bit formula, but the `ImagingTgaRleEncode()` function treats the row as having one full byte per pixel. This allows the encoder to walk up to ~57 KB past the allocated buffer for maximum-width images (65535 pixels). An attacker can trigger this via the public `save()` API, causing the library to serialize adjacent heap data into the output TGA file. The vulnerability is patched in version 12.3.0.
Affected products
- python-pillow Pillow >= 5.2.0, < 12.3.0
Timeline
- 2026-07-07: patched: Fixed in version 12.3.0
- 2026-07-14: advisory: NVD published advisory
- 2026-07-20: disclosed: GitHub Advisory published