---
schema_version: '1.0'
id: security-20261023-0b4cc3
title: 'CVE-2026-96638: Pillow: BMP RLE decoder memory-amplification DoS via unbounded
  delta escape / absolute mode'
url: https://osv.dev/vulnerability/GHSA-24rc-8hj2-v98c
url_hash: 0b4cc36d52650034bc6c11d531d7060c1f7ddadf8fe6a240edd2a82d154b1bf5
canonical_url: https://osv.dev/vulnerability/GHSA-24rc-8hj2-v98c
source: osv:ghsa
category: security/library
category_raw: cve/library
region: null
tags:
- cve
- CVE-2026-96638
- GHSA-24rc-8hj2-v98c
- severity:CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
- pillow
- PyPI
lang: en
published_at: '2026-10-22T15:59:35Z'
fetched_at: '2026-10-23T11:56:14.086787Z'
updated_at: '2026-10-23T13:34:24Z'
status: published
content_hash: 701242c48e71f2374b99954f2eeada40f259763386f4d45b055e36e0e944c9aa
content_changed_at: null
license_note: full
summary: 'Pillow: BMP RLE decoder memory-amplification DoS via unbounded delta escape
  / absolute mode'
summary_source: rss
summary_en: 'Pillow: BMP RLE decoder memory-amplification DoS via unbounded delta
  escape / absolute mode'
summary_omitted_reason: null
redistribution: true
keywords_en:
- absolute
- BMP
- cve
- CVE-2026-96638
- decoder
- delta
- DoS
- escape
- GHSA-24rc-8hj2-v98c
- library vulnerability
- MajorLeague
- memory-amplification
- mode
- pillow
- PyPI
- RLE
- severity:CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
- Shay McVeigh
- software security
- unbounded
- via
entities_en:
- name: MajorLeague
  type: concept
- name: Shay McVeigh
  type: person
topics_en:
- library vulnerability
- software security
numeric_facts: []
entities:
- name: Shay McVeigh
  type: person
- name: MajorLeague
  type: concept
key_facts: []
related: []
related_auto:
- name: Bristol Crown Court
  type: organization
  weight: 1.0
- name: Bristol Magistrates Court
  type: organization
  weight: 1.0
- name: Miguel Rojas
  type: person
  weight: 1.0
computed_at: '2026-10-23T13:34:22Z'
---

# CVE-2026-96638: Pillow: BMP RLE decoder memory-amplification DoS via unbounded delta escape / absolute mode

## TL;DR
Pillow: BMP RLE decoder memory-amplification DoS via unbounded delta escape / absolute mode

## Key Points
- cve / CVE-2026-96638 / GHSA-24rc-8hj2-v98c / severity:CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H / pillow / PyPI

## Details
**Severity:** CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
**Advisory:** GHSA-24rc-8hj2-v98c (CVE-2026-96638)

**Details:**
## Summary
BmpRleDecoder can be forced to allocate gigabytes of memory from a kilobyte-sized crafted BMP file via unbounded growth in the delta escape and absolute mode branches.

## Affected versions
All versions up to and including current HEAD (v13.0.0.dev0, commit e7a7ea84)

## Root cause
BmpRleDecoder.decode() (BmpImagePlugin.py:327-395) builds a Python bytearray `data` with dest_length = xsize*ysize, looping `while len(data) < dest_length`. The loop condition is only checked at the TOP; individual branches append attacker-controlled amounts UNBOUNDED by dest_length:

- delta escape (line 370): data += b"\x00" * (right + up * self.state.xsize) with right,up in 0..255 -> up to ~255*xsize bytes in ONE iteration.
- absolute mode (line 385): data += bytes_read (up to 255).

Because a single delta can push len(data) to ~256 * (row size), a tiny RLE stream combined with a large-but-legal xsize (xsize*ysize just under MAX_IMAGE_PIXELS, ~89M) yields a multi-GB `data` bytearray (then copied again by bytes(data) and set_as_raw). No heap OOB (bytearray/set_as_raw are bounds-safe), but a severe memory-amplification DoS: the attacker file stays tiny.

## Reproduction
Python 3.13, Pillow HEAD e7a7ea84

Attached: pillow_poc_bmp_rle_dos.py

A 1084-byte BMP (BI_RLE8, width=3,000,000, height=1 -> 3M px, passes bomb check) with one delta escape (00 02 00 150) produces ~429 MB `data`; measured peak RSS 911 MB. Scaling width toward the bomb limit and up=255 produces tens of GB from a ~1 KB file.

## Suggested fix
Cap growth at dest_length in the delta and absolute branches, e.g. clamp the delta fill to (dest_length - len(data)) and stop appending once len(data) >= dest_length; reject deltas that would move the cursor beyond the image, matching the existing per-row clamp at line 341-343.

Credit: Yazan Balawneh - CyStack Security Team (GitHub: sonicnew)

[pillow_poc_bmp_rle_dos.py](https://github.com/user-attachments/files/30244974/pillow_poc_bmp_rle_dos.py)

**References:**
- https://github.com/python-pillow/Pillow/security/advisories/GHSA-24rc-8hj2-v98c
- https://nvd.nist.gov/vuln/detail/CVE-2026-96638
- https://github.com/python-pillow/Pillow/pull/10015
- https://github.com/python-pillow/Pillow/commit/e7794835e323ff2691d9b3a974cade1a44301b9a
- https://github.com/python-pillow/Pillow
- https://github.com/python-pillow/Pillow/releases/tag/13.0.0

_Data: OSV.dev (upstream: ghsa) — https://osv.dev/vulnerability/GHSA-24rc-8hj2-v98c_

## Source
元記事: [CVE-2026-96638: Pillow: BMP RLE decoder memory-amplification DoS via unbounded delta escape / absolute mode](https://osv.dev/vulnerability/GHSA-24rc-8hj2-v98c) — published 2026-10-22T15:59:35Z
