CVE-2026-102993
Memory exhaustion via huge Roman page labels in pypdf before 6.17.0.
- CVSS 8.7
- CWE-400
- Resource Management
- Remote
pypdf is a free and open-source pure-python PDF library. Prior to 6.17.0, a crafted PDF can provide unusually large Roman page-label values that cause pypdf/_page_labels.py to generate excessively large numeral strings when an application retrieves document page labels, consuming large amounts of memory and potentially making the application unavailable. This issue is fixed in version 6.17.0.
- CWE
- CWE-400
- CVSS base score
- 8.7
- Published
- 2026-09-30
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Algorithm
- Code defect classification
- Incorrect Algorithm
- 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.17.0 or newer.
Vulnerable code sample
from pypdf import PdfReader
def get_page_labels(pdf_path: str) -> list[str]:
"""
Returns the list of page labels for a PDF.
"""
reader = PdfReader(pdf_path)
labels = []
# VULNERABLE: unbounded Roman numeral generation
for i, entry in enumerate(reader.page_labels):
# entry.num is the start page number; entry.prefix may be a Roman numeral prefix
roman = _to_roman(entry.num) # library function that can produce huge strings
label = f"{roman}{entry.prefix}"
labels.append(label)
return labels
def _to_roman(num: int) -> str:
"""Converts an integer to a Roman numeral (no size checks)."""
vals = [
(1000, "M"), (900, "CM"), (500, "D"), (400, "CD"),
(100, "C"), (90, "XC"), (50, "L"), (40, "XL"),
(10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I")
]
result = ""
for value, numeral in vals:
while num >= value:
result += numeral
num -= value
return resultPatched code sample
from pypdf import PdfReader
_MAX_ROMAN_LENGTH = 30 # FIX: limit Roman numeral length
def get_page_labels(pdf_path: str) -> list[str]:
"""
Returns the list of page labels for a PDF.
"""
reader = PdfReader(pdf_path)
labels = []
# FIX: limit Roman numeral length
for i, entry in enumerate(reader.page_labels):
roman = _to_roman(entry.num)
# Truncate if the generated Roman numeral exceeds safe limits
if len(roman) > _MAX_ROMAN_LENGTH:
roman = roman[:_MAX_ROMAN_LENGTH] + "…"
label = f"{roman}{entry.prefix}"
labels.append(label)
return labels
def _to_roman(num: int) -> str:
"""Converts an integer to a Roman numeral (no size checks)."""
vals = [
(1000, "M"), (900, "CM"), (500, "D"), (400, "CD"),
(100, "C"), (90, "XC"), (50, "L"), (40, "XL"),
(10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I")
]
result = ""
for value, numeral in vals:
while num >= value:
result += numeral
num -= value
return resultPublished 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 value for Roman numerals (#4047) (py-pdf/pypdf)
pypdf/_page_labels.py,pypdf/_page_labels.py · get_label_from_nums,pypdf/_page_labels.py · number2uppercase_letter,pypdf/_page_labels.py · number2uppercase_roman_numeral,pypdf/_page_labels.py · nums_next
Cite this entry
@misc{vaitp:cve2026102993,
title = {{Memory exhaustion via huge Roman page labels in pypdf before 6.17.0.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-102993},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-102993/}}
}
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 ::
