---
id: "CVE-2026-112891"
kind: "vulnerability"
aliases: ["CVE-2026-112891", "GHSA-fc9g-5qg7-mf45"]
title: "Pillow: Quadratic GIF comment copying during save"
severity: "medium"
cvss: 6.9
epss: 0.003710000077262521
exploited: false
status: "open"
category: "package"
products: [{"name": "pillow", "fixed": ["13.0.0"], "affected": ">= 9.2.0, < 13.0.0", "ecosystem": "pypi"}]
ecosystems: ["pypi"]
tags: ["cwe-407", "image-upload", "package", "pillow", "python", "self-hosted"]
not_affected_if: ["no-untrusted-gif-save", "pillow-13-or-later", "pillow-below-9.2.0"]
published_at: "2026-10-19T22:17:08+00:00"
first_seen_at: "2026-10-23T19:11:32+00:00"
updated_at: "2026-10-23T21:57:19+00:00"
sources: [{"source": "ghsa", "url": "https://github.com/advisories/GHSA-fc9g-5qg7-mf45", "first_seen_at": "2026-10-23T19:11:32+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-112891", "first_seen_at": "2026-10-23T21:57:19+00:00"}]
---

# Pillow: Quadratic GIF comment copying during save

Pillow's GIF saver copies portions of a long comment repeatedly, so saving a crafted GIF takes quadratic CPU time. An attacker who can get a service to re-save an uploaded GIF can tie up CPU, causing denial of service.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- pypi:pillow affected >= 9.2.0, < 13.0.0 fixed 13.0.0

## How to check

pip show pillow (affected if version >= 9.2.0 and < 13.0.0)
Check whether the app saves uploaded GIFs with Pillow (Image.save with format GIF) and whether it preserves comments from input images

## Fix

Upgrade pillow to 13.0.0 or later.
If an upgrade is not possible, do not re-save untrusted GIFs or cap upload size and worker CPU time.

## Timeline

- 2026-10-23T19:11:32+00:00 ghsa https://github.com/advisories/GHSA-fc9g-5qg7-mf45
- 2026-10-23T21:57:19+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-112891

## From the sources

On Pillow 12.3.0 and upstream `main` (`ad277e2761b489681e71b51e91367d46b0ceabb9`), a GIF with a long comment makes `_get_global_header()` copy portions of the comment repeatedly when saving, including comments carried over from untrusted images. I suggest provisional **Moderate** severity for crafted-image CPU denial of service, with CVSS-B 6.9 assuming a network service automatically opens unauthenticated uploads and they are resaved as GIFs; impact depends on input-size, concurrency, and worker CPU limits.

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
