PyPI: pillow
CVE-2026-112401
Safety vulnerability ID: SFTY-20261021-55110
Affected versions of the Pillow package are vulnerable to Inefficient Algorithmic Complexity (CWE-407) due to unbounded repeated concatenation of immutable byte strings while parsing GIF comment data. The `GifImageFile._seek()` method in `src/PIL/GifImagePlugin.py` builds `info["comment"]` by repeatedly using `comment += block` for each 255-byte sub-block and `info["comment"] += b"\n" + comment` for each comment extension, causing a full re-copy of all previously accumulated data on every append, which makes the cost of parsing grow quadratically with the amount of comment data; because `_open()` calls `self._seek(0)`, this cost is paid unconditionally inside `Image.open()` before any application logic inspects the image. An attacker can craft a small GIF file consisting of a 1×1 image with thousands of tiny comment extensions to force `Image.open()` to consume disproportionate processor time—for example, a 4 MB crafted file can take over 30 seconds to open versus a fraction of a second for an ordinary GIF of the same size—allowing a remote, unauthenticated attacker to exhaust worker processes and cause a Denial of Service in any service that opens, thumbnails, or identifies user-supplied GIF images.
Overview
Pillow: Quadratic GIF comment concatenation allows DoS in Image.open()
Advisory
pillow – Inefficient Algorithmic Complexity
How to Fix
Mitigation and Workarounds
---
Vulnerable Functions
Functions linked to known vulnerabilities.
References
- https://getsafety.com/vulnerabilities/SFTY-20261021-55110/CVE-2026-112401
- https://github.com/python-pillow/Pillow/security/advisories/GHSA-74r2-7ff9-mjj2
- https://nvd.nist.gov/vuln/detail/CVE-2026-112401
- https://github.com/python-pillow/Pillow/commit/68a3fe957d8a4d552e8c69d96066d749f0614c7e
- https://github.com/python-pillow/Pillow/releases/tag/13.0.0
- https://github.com/advisories/GHSA-74r2-7ff9-mjj2
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
