Advisory Database
  • Advisories
  • Dependency Scanning
  1. pypi
  2. ›
  3. Pillow
  4. ›
  5. CVE-2026-54060

CVE-2026-54060: Pillow: `FontFile.compile()`: `Image.new()` called without `_decompression_bomb_check()`

July 20, 2026

PIL/FontFile.py FontFile.compile() assembles per-glyph images into a single combined bitmap using Image.new("1", (xsize, ysize)) without calling Image._decompression_bomb_check(). This is the base-class method shared by both BdfFontFile and PcfFontFile, and it is triggered whenever a loaded font is converted to an ImageFont or saved.

Neither BdfFontFile.BdfFontFile(fp) nor PcfFontFile.PcfFontFile(fp) is registered with Image.register_open(), so Pillow’s standard decompression bomb guard never fires for font objects. The compile step is the final opportunity to check the combined allocation — and it has no check.

Vulnerable code (PIL/FontFile.py lines ~64–92):

def compile(self) -> None:
if self.bitmap:
return

h = w = maxwidth = 0
lines = 1
for glyph in self.glyph:              # up to 256 glyph slots
if glyph:
d, dst, src, im = glyph
h = max(h, src[3] - src[1])   # max glyph height — attacker-controlled
w = w + (src[2] - src[0])
if w > WIDTH:                  # WIDTH = 800
lines += 1
w = src[2] - src[0]
maxwidth = max(maxwidth, w)

xsize = maxwidth                       # ≤ 800 (capped by WIDTH constant)
ysize = lines * h                      # ← lines(256) × h(65535) = 16,776,960

if xsize == 0 and ysize == 0:
return

self.ysize = h

References

  • github.com/advisories/GHSA-5x94-69rx-g8h2
  • github.com/pypa/advisory-database/tree/main/vulns/pillow/PYSEC-2026-2254.yaml
  • github.com/python-pillow/Pillow/blob/main/docs/releasenotes/12.3.0.rst
  • github.com/python-pillow/Pillow/commit/0a263e6264aa5399988d9acd3bbfbca2ca3ec77d
  • github.com/python-pillow/Pillow/security/advisories/GHSA-5x94-69rx-g8h2
  • nvd.nist.gov/vuln/detail/CVE-2026-54060

Code Behaviors & Features

Detect and mitigate CVE-2026-54060 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →

Affected versions

All versions before 12.3.0

Fixed versions

  • 12.3.0

Solution

Upgrade to version 12.3.0 or above.

Impact 7.5 HIGH

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Learn more about CVSS

Weakness

  • CWE-789: Memory Allocation with Excessive Size Value

Source file

pypi/Pillow/CVE-2026-54060.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sun, 08 Nov 2026 00:17:26 +0000.