VAITP Dataset

← Back to the dataset

CVE-2026-96638

Pillow BMP RLE decoder can cause memory exhaustion via crafted delta runs.

  • CVSS 6.5
  • CWE-400
  • Resource Management
  • Remote

Pillow is a Python imaging library. From 9.1.0 until 13.0.0, BmpRleDecoder.decode() in src/PIL/BmpImagePlugin.py permits crafted RLE BMP delta escapes and absolute-mode runs to append beyond the remaining dest_length without a per-branch cap. A delta can add roughly 255 image rows in one iteration, so a kilobyte-sized file with a large but permitted width can expand the data bytearray to hundreds of megabytes or more, causing memory-exhaustion denial of service. This issue is fixed in version 13.0.0.

CVSS base score
6.5
Published
2026-10-21
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Checking
Code defect classification
Missing Check
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 newer.

Vulnerable code sample

from PIL import BmpImagePlugin

def decode_bmp_rle(data: bytes, width: int, height: int) -> bytearray:
    # VULNERABLE: unchecked expansion of destination buffer
    decoder = BmpImagePlugin.BmpRleDecoder()
    dest_length = width * height * 3  # assume 24‑bit RGB
    dest = bytearray()
    # The decoder may append far beyond dest_length when processing crafted delta escapes
    decoder.decode(dest, data, dest_length)
    return dest

Patched code sample

from PIL import BmpImagePlugin

def decode_bmp_rle(data: bytes, width: int, height: int) -> bytearray:
    # FIX: enforce per‑branch cap to prevent unchecked expansion
    decoder = BmpImagePlugin.BmpRleDecoder()
    dest_length = width * height * 3  # assume 24‑bit RGB
    dest = bytearray()
    # Wrap the decoder to stop appending beyond the intended size
    original_append = dest.append
    def limited_append(value):
        if len(dest) < dest_length:
            original_append(value)
    dest.append = limited_append  # type: ignore
    decoder.decode(dest, data, dest_length)
    # restore original method (optional)
    dest.append = original_append  # type: ignore
    return dest

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:cve202696638,
  title        = {{Pillow BMP RLE decoder can cause memory exhaustion via crafted delta runs.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-96638},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-96638/}}
}

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.