VAITP Dataset

← Back to the dataset

CVE-2026-112891

Quadratic copying of large GIF comments causes CPU DoS in Pillow 9.2‑13

  • CVSS 6.9
  • CWE-407
  • Resource Management
  • Remote

Pillow is a Python imaging library. From 9.2.0 until 13.0.0, Pillow performs quadratic copying when saving a GIF with a long comment. _get_global_header() repeatedly copies portions of comment data while assembling the global header, including comments retained from an untrusted input image. An attacker can supply an image with a large GIF comment to an application that saves it as GIF. This can consume excessive CPU and delay or deny service. This issue is fixed in version 13.0.0.

CVSS base score
6.9
Published
2026-10-19
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Timing/Serialization
Code defect classification
Timing Issues
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Affected component
Pillow
Fixed by upgrading
Yes

Solution

Upgrade Pillow to version 13.0.0 or later.

Vulnerable code sample

from PIL import Image

def convert_to_gif(src_path, dst_path):
    # Load possibly untrusted image
    img = Image.open(src_path)

    # Preserve original comment when saving as GIF
    # VULNERABLE: quadratic copy of long comment during GIF save
    comment = img.info.get('comment')
    save_kwargs = {'format': 'GIF'}
    if comment is not None:
        save_kwargs['comment'] = comment

    img.save(dst_path, **save_kwargs)

Patched code sample

from PIL import Image

def convert_to_gif(src_path, dst_path):
    # Load possibly untrusted image
    img = Image.open(src_path)

    # Avoid copying large comments; truncate to safe size
    # FIX: limit comment length to prevent quadratic copying
    comment = img.info.get('comment')
    save_kwargs = {'format': 'GIF'}
    if comment is not None:
        max_len = 1024  # safe upper bound
        save_kwargs['comment'] = comment[:max_len]

    img.save(dst_path, **save_kwargs)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

Cite this entry

@misc{vaitp:cve2026112891,
  title        = {{Quadratic copying of large GIF comments causes CPU DoS in Pillow 9.2‑13}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-112891},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-112891/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.