PyPI: pillow

CVE-2026-112390

Safety vulnerability ID: SFTY-20261021-15476

Affected versions of the Pillow package are vulnerable to Loop with Unreachable Exit Condition ('Infinite Loop') due to inconsistent frame-tracking state between `MicImageFile` and its parent `TiffImageFile` class. The inherited `TiffImageFile.n_frames` property walks the embedded TIFF's IFD chain using `self._seek(self.tell() + 1)` until `_n_frames` is set, but `MicImageFile.tell()` returns the constant OLE stream index rather than the advancing TIFF directory position, while `MicImageFile.seek()` calls `TiffImageFile._open()`, which resets `_n_frames` to `None`; when the embedded TIFF stream contains three or more chained IFDs, this causes the same directory to be re-parsed endlessly without progress. An attacker can craft a small OLE2-based MIC file whose embedded TIFF stream contains three or more chained IFDs and have it opened by any application using Pillow with the optional `olefile` dependency installed; simply reading `im.n_frames` (as done when checking if an image is animated or when re-saving with `save_all=True` to TIFF, PDF, or WebP) causes the process to hang indefinitely at 100% CPU with no exception raised and no memory growth, resulting in a Denial of Service that can only be stopped by an external watchdog.

Created at: Oct 23, 2026Updated at: Oct 23, 2026

Overview

Pillow: Infinite loop in MIC n_frames when the embedded TIFF

Advisory

pillow – Loop with Unreachable Exit Condition ('Infinite Loop')

Affected Package

Affecting pillow package, versions>= 7.2.0, < 13.0.0

Also affects

---

How to Fix

Upgradepillowto13.0.0or higher.

Mitigation and Workarounds

---

Vulnerable Functions

Functions linked to known vulnerabilities.

Vulnerable function data is available for Enterprise customers

Book a call with us to see Safety in action.

Safety

Verified by Safety

Our Cybersecurity Intelligence Team reviewed this vulnerability. We combine public data with our own research to find issues not yet reported to public sources.

Learn more