Medium

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

  • Disclosed: 22.10.2026
  • Updated: 22.10.2026 19:17

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

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Python (PyPI) pillow >= 9.1.0, < 13.0.0 13.0.0

References

CVSS score 6.5/10
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
Weakness (CWE)
CWE-400, CWE-770
Platform
Python (PyPI)
Package
pillow
Disclosed
22.10.2026
Updated
22.10.2026 19:17

Sources and licenses

OSV / GitHub Advisory Database - GHSA-24rc-8hj2-v98c - CC BY 4.0

Vulnerability history: pillow

All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (100) in the archive
Total entries
100
First → latest
04.2014 10.2026
Without a fix
0
Exploited in attacks
1

Severity breakdown

  • Critical 13
  • High 58
  • Medium 27
  • Low 1
  • Unrated 1

Disclosures per year

  1. 2017: 1
  2. 2018: 0
  3. 2019: 1
  4. 2020: 10
  5. 2021: 20
  6. 2022: 8
  7. 2023: 3
  8. 2024: 2
  9. 2025: 1
  10. 2026: 42

earlier: 12

Severity:
  1. Critical · 9.8 CVE-2026-96639 >= 11.0.0, < 13.0.0 13.0.0
  2. Pillow: BMP RLE decoder memory-amplification DoS via unbounded delta escape / absolute mode this entry
    Medium · 6.5 CVE-2026-96638 >= 9.1.0, < 13.0.0 13.0.0
  3. High CVE-2026-112892 >= 4.1.0, < 13.0.0 13.0.0
  4. High CVE-2026-112390 >= 7.2.0, < 13.0.0 13.0.0
  5. High CVE-2026-112405 >= 12.0.0, < 13.0.0 13.0.0
  6. High CVE-2026-112893 >= 10.0.0, < 13.0.0 13.0.0
  7. Critical CVE-2026-112900 >= 2.6.0, < 13.0.0 13.0.0
  8. Critical CVE-2026-112403 < 13.0.0 13.0.0
  9. High · 7.5 CVE-2026-59200 >= 5.1.0, < 12.3.0 12.3.0
Show more (20) Showing 20 of 72

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.