Home/Research/Post

GHSA-xcvg-w56q-r89m: Pillow: Heap buffer overflow saving TIFF with libtiff when tags override image size

  • Severity: HIGH
  • CVE: CVE-2026-128067
  • Ecosystems: pip
  • Packages: Pillow

“`
============================================================================
ANT-2026-CS7N494P [high] CWE-787 memory-safety
Heap buffer overflow saving TIFF with libtiff when tags override image size
Location: src/libImaging/TiffDecode.c:1035 in ImagingLibTiffEncode()
Commit: a707c6b21c313880d0771e54965d142dd42358b6
============================================================================
“`

When Pillow saves an image as a compressed TIFF, size information taken from the image’s metadata can make the encoder read past the end of a heap buffer. Someone who uploads an image can use this to get the server process’s memory, including pointers, copied into the saved file, or to crash the process. When the metadata also enables TIFF “Predictor=2” compression, the encoder writes past the buffer instead, corrupting the heap and aborting the process. This affects applications that write TIFF through libtiff (any `compression=` other than raw) and either carry the source metadata across with `exif=im.getexif()` / `tiffinfo=`, or simply re-save a crafted palette TIFF with `Image.open(f).save(out, “TIFF”)`, which inherits its compression and predictor from the upload.

In `TiffImagePlugin._save`’s libtiff branch, only `BitsPerSample` is pinned to the real image when the tag list for the encoder is built (`src/PIL/TiffImagePlugin.py:1955`). `ImageWidth`, `ImageLength` and `PlanarConfiguration` are set from `im.size` but are then overwritten by the `exif=`/`tiffinfo=` merge loop a…

Source: GitHub Security Advisories · 2026-11-12