PyPI: pillow
CVE-2026-112891
Safety vulnerability ID: SFTY-20261021-20388
Affected versions of the Pillow package are vulnerable to Inefficient Algorithmic Complexity due to repeated copying of comment data when saving GIF images. The `_get_global_header()` function processes long GIF comment blocks in a manner that results in quadratic time complexity, as portions of the comment are repeatedly copied rather than handled in a single pass. An attacker can exploit this by supplying a crafted GIF containing an unusually long comment to a service that automatically processes and resaves untrusted images in GIF format, causing excessive CPU consumption and resulting in a Denial of Service condition.
Overview
Pillow: Quadratic GIF comment copying during save
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-20388/CVE-2026-112891
- https://github.com/python-pillow/Pillow/security/advisories/GHSA-fc9g-5qg7-mf45
- https://nvd.nist.gov/vuln/detail/CVE-2026-112891
- https://github.com/python-pillow/Pillow/commit/68a3fe957d8a4d552e8c69d96066d749f0614c7e
- https://github.com/python-pillow/Pillow/releases/tag/13.0.0
- https://github.com/advisories/GHSA-fc9g-5qg7-mf45
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
