CVE-2026-102996
Excessive memory use via oversized /Widths array in pypdf font handling vuln
- CVSS 8.7
- CWE-400
- Resource Management
- Remote
pypdf is a free and open-source pure-python PDF library. Prior to 6.18.1, a crafted PDF can provide a TrueType or Type1 simple font with an unusually large /Widths array, causing pypdf/_font.py Font._collect_tt_t1_character_widths to process entries beyond the 256 character codes meaningful for a simple font and consume excessive memory during operations such as text extraction. This issue is fixed in version 6.18.1.
- CWE
- CWE-400
- CVSS base score
- 8.7
- Published
- 2026-09-30
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- pypdf
- Fixed by upgrading
- Yes
Solution
Upgrade pypdf to version 6.18.1 or later.
Vulnerable code sample
from pypdf import PdfReader
def extract_char_widths(pdf_path):
reader = PdfReader(pdf_path)
font = reader.trailer["/Root"]["/Pages"]["/Kids"][0]["/Resources"]["/Font"]["/F1"]
# VULNERABLE: processes entire /Widths array, allowing unbounded memory growth
widths = {code: w for code, w in enumerate(font["/Widths"])}
return widthsPatched code sample
from pypdf import PdfReader
def extract_char_widths(pdf_path):
reader = PdfReader(pdf_path)
font = reader.trailer["/Root"]["/Pages"]["/Kids"][0]["/Resources"]["/Font"]["/F1"]
# FIX: limit processing to 256 character codes relevant for simple fonts
widths = {code: w for code, w in enumerate(font["/Widths"][:256])}
return widthsPublished fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- SEC: Limit entry count for TrueType and Type1 font `/Widths` (#4072) (py-pdf/pypdf)
pypdf/_font.py,pypdf/_font.py · Font._collect_tt_t1_character_widths,pypdf/_font.py · Font.__check_entry_count
Cite this entry
@misc{vaitp:cve2026102996,
title = {{Excessive memory use via oversized /Widths array in pypdf font handling vuln}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-102996},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-102996/}}
}
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 ::
