Tags that all claim the same bytes make Pillow hold thousands of times a file's size in memory
Pillow: Memory DoS in TIFF and EXIF IFD parsing via overlapping tag data
- Advisory
- CVE-2026-128066
- Library
- Pillow, pillow on PyPI
- Published
- Severity
- not scored upstream
- Affected
- < 13.0.0
- Fixed in
- 13.0.0
- Reaches you
- by opening a file
What triggers it
Opening a TIFF or a JPEG whose tag directory holds thousands of tags that each claim the same bytes as their value; for a PNG, asking for the EXIF of one.
What sillybos does
Refused by default
sillybos refuses the triggering file under its default policy, through the allow_overlapping_tag_data check.
The trigger is a tag directory, which is a header: each entry gives the size of its value and where it lies, and the loader reads every value into memory with nothing to stop them all being the same bytes. The values of an honest directory do not overlap, so they cannot add up to more than the bytes they are read from, and the reader now adds them up: for each frame of a TIFF and the Exif, GPS and interoperability directories it points to, against the file; for the EXIF block of a JPEG or a PNG (its main, thumbnail, Exif, GPS and interoperability directories) and a JPEG's multi-picture index, against the block. A directory that claims more is refused by default, as is a block whose directories hold more entries between them than it has bytes for. The JPEG walk now goes on past the frame header to the image data, since Pillow reads an EXIF block from anywhere before the scan. The advisory's own TIFF was already refused, by accident: its tags point at the second byte of the file, inside the header, which the reader does not allow; moved eight bytes on, it passed every policy. Refusing private tags did not help, since the standard numbers serve as well. Two carriers are not seen: EXIF that a PNG holds in a text chunk ("Raw profile type exif"), which may be compressed and so cannot be read without inflating it, and a camera maker's own directory inside a maker note. Both are reached only when a program asks for the EXIF, not on opening.
Triaged from the advisory's text on 2026-11-16, and the bucket and the default confirmed by a person the same day. Upstream gives the severity as moderate, with no score. Each route was tried on Pillow 13.0.0, whose bounded loader warns where it used to read: a TIFF, a JPEG's EXIF block before or after the frame header and across several segments, and a JPEG's multi-picture index all reach the loader inside Image.open; a PNG's eXIf chunk and its raw-profile text chunk, compressed or not, on getexif; the Exif and GPS directories on get_ifd. An EXIF block with a BigTIFF header does not reach it. The reader was run over 3.2 million real images (7,501 JPEG, 126,337 TIFF, 3,064,088 PNG) and reported an overlap in none. The memory cost itself was not reproduced on an earlier Pillow. The check was built on 2026-11-16.
Proved by these tests in the sillybos suite, each of which builds the triggering file from bytes and checks that it is refused:
tests/test_check.py::TestHostileFiles::test_a_tiff_whose_tags_all_claim_the_same_bytestests/test_check.py::TestHostileFiles::test_a_jpeg_whose_exif_tags_all_claim_the_same_bytestests/test_check.py::TestHostileFiles::test_a_png_whose_exif_tags_all_claim_the_same_bytes
How to protect yourself
In general. Upgrade to Pillow 13.0.0, whose loader skips a tag once the directory's values add up to more than the stream.
Specifically. Keep allow_overlapping_tag_data off, as it is by default; on a Pillow before 13.0.0, do not ask for the EXIF of a PNG from outside (getexif, ImageOps.exif_transpose) unless its text chunks are known to hold none; upgrade to Pillow 13.0.0.
The general advice applies to every row here.
Sources
- https://osv.dev/vulnerability/GHSA-wqgw-9xfh-qf2g
- The record entry, triaged 2026-11-16, last checked 2026-11-16