CVE-2026-102994
Excessive PDF token length leads to DoS via unbounded whitespace scanning.
- CVSS 8.7
- CWE-400
- Resource Management
- Remote
pypdf is a free and open-source pure-python PDF library. Prior to 6.18.0, a crafted PDF containing indirect-object identifiers or generation-number tokens that continue for a long time without whitespace can cause pypdf/_reader.py and pypdf/generic/_base.py to scan excessive input through read_until_whitespace, resulting in long runtimes and application unavailability. This issue is fixed in version 6.18.0.
- CWE
- CWE-400
- CVSS base score
- 8.7
- Published
- 2026-09-30
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Timing/Serialization
- Code defect classification
- Timing Issues
- 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.0 or later.
Vulnerable code sample
from pypdf.generic import read_until_whitespace
def extract_object_id(stream):
# VULNERABLE: unbounded read_until_whitespace can be abused with long token streams
obj_num = read_until_whitespace(stream)
gen_num = read_until_whitespace(stream)
return int(obj_num), int(gen_num)Patched code sample
from pypdf.generic import read_until_whitespace
MAX_TOKEN_LEN = 20 # reasonable bound for object / generation numbers
def _read_until_whitespace_limited(stream, max_len=MAX_TOKEN_LEN):
# read bytes manually, stop after max_len to avoid resource exhaustion
token = b""
while True:
char = stream.read(1)
if not char or char.isspace():
break
token += char
if len(token) > max_len:
raise ValueError("Token length exceeds safe limit")
return token
def extract_object_id(stream):
# FIX: limit token length to prevent excessive scanning
obj_num = _read_until_whitespace_limited(stream)
gen_num = _read_until_whitespace_limited(stream)
return int(obj_num), int(gen_num)Published 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 allowed length of indirect object tokens (#4055) (py-pdf/pypdf)
pypdf/generic/_base.py,pypdf/generic/_base.py · IndirectObject.read_from_stream,pypdf/generic/_utils.py · create_string_object,pypdf/generic/_utils.py · read_hex_string_from_stream,pypdf/_reader.py · PdfReader.read_object_header,pypdf/_reader.py · PdfReader._rebuild_xref_table,pypdf/_utils.py · read_until_whitespace
Cite this entry
@misc{vaitp:cve2026102994,
title = {{Excessive PDF token length leads to DoS via unbounded whitespace scanning.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-102994},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-102994/}}
}
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 ::
