CVE-2026-82398
Quadratic CPU consumption via read_until_whitespace on long non‑whitespace PDF data.
- CVSS 6.9
- CWE-407
- Resource Management
- Remote
pypdf is a free and open-source pure-python PDF library. Prior to 6.15.0, an attacker can craft a PDF that causes long runtimes when the pypdf/_utils.py function read_until_whitespace reads a stream containing a long run of bytes without whitespace. The function repeatedly performs immutable bytes concatenation in a one-byte loop, causing quadratic processing cost for the long non-whitespace input. This issue is fixed in version 6.15.0.
- CWE
- CWE-407
- CVSS base score
- 6.9
- Published
- 2026-08-31
- 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.15.0 or later.
Vulnerable code sample
import io
def read_until_whitespace(stream: io.BytesIO) -> bytes:
"""Read bytes from *stream* until a whitespace character is found."""
result = b""
while True:
ch = stream.read(1)
# VULNERABLE: repeated immutable bytes concatenation causes quadratic cost
if not ch or ch in b" \t\n\r\f\v":
break
result += ch
return resultPatched code sample
import io
def read_until_whitespace(stream: io.BytesIO) -> bytes:
"""Read bytes from *stream* until a whitespace character is found."""
chunks = []
while True:
ch = stream.read(1)
# FIX: accumulate chunks in a list and join once to avoid quadratic cost
if not ch or ch in b" \t\n\r\f\v":
break
chunks.append(ch)
return b"".join(chunks)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: Improve performance of read_until_whitespace (#3947) (py-pdf/pypdf)
pypdf/_utils.py · read_until_whitespace
Cite this entry
@misc{vaitp:cve202682398,
title = {{Quadratic CPU consumption via read_until_whitespace on long non‑whitespace PDF data.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-82398},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-82398/}}
}
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 ::
