VAITP Dataset

← Back to the dataset

CVE-2026-112401

Quadratic CPU consumption parsing GIF comments leads to DoS in Pillow 5.4.0‑13.0.0.

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

Pillow is a Python imaging library. From 5.4.0 until 13.0.0, Pillow performs quadratic copying while parsing GIF comments. GifImageFile._seek() repeatedly appends immutable bytes for comment sub-blocks and multiple comment extensions, and frame zero is parsed during Image.open(). An attacker can submit a small-dimension GIF containing many comment extensions to any application that opens the file. This can consume excessive CPU and deny service before the application can inspect the image. This issue is fixed in version 13.0.0.

CVSS base score
6.9
Published
2026-10-19
OWASP
A04 Insecure Design
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 get_gif_dimensions(path):
    # VULNERABLE: parsing all GIF comment extensions can cause quadratic CPU consumption
    with Image.open(path) as im:
        im.load()            # triggers full GIF parsing, including comments
        return im.size

Patched code sample

from PIL import Image, ImageFile

def get_gif_dimensions(path):
    # FIX: bypass comment parsing by feeding raw image data to a low‑level parser
    with open(path, 'rb') as f:
        data = f.read()

    # Strip GIF comment extension blocks (0xFE) to avoid quadratic copying
    i = 0
    cleaned = bytearray()
    while i < len(data):
        if data[i] == 0x21 and i + 1 < len(data) and data[i+1] == 0xFE:
            i += 2
            while i < len(data):
                block_size = data[i]
                i += 1
                if block_size == 0:
                    break
                i += block_size
        else:
            cleaned.append(data[i])
            i += 1

    parser = ImageFile.Parser()
    parser.feed(cleaned)
    im = parser.close()
    return im.size

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:cve2026112401,
  title        = {{Quadratic CPU consumption parsing GIF comments leads to DoS in Pillow 5.4.0‑13.0.0.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-112401},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-112401/}}
}

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.