CVE-2026-113794
pypdf <6.20 infinite loop on truncated PDF ending in cross‑ref table
- CVSS 6.0
- CWE-835
- Resource Management
- Remote
pypdf is a free and open-source pure-python PDF library. Prior to 6.20.0, an attacker can craft an incomplete PDF that ends inside a standard cross-reference table, causing pypdf to mishandle the unexpected end of file and enter an infinite loop. This issue is fixed in version 6.20.0.
- CWE
- CWE-835
- CVSS base score
- 6.0
- Published
- 2026-10-21
- OWASP
- A08 Software and Data Integrity Failures
- 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.20.0 or later.
Vulnerable code sample
import sys
from pypdf import PdfReader
def extract_text(pdf_path: str) -> str:
# VULNERABLE: infinite loop if PDF ends inside a cross‑reference table
reader = PdfReader(pdf_path)
text = ""
for page in reader.pages:
text += page.extract_text() or ""
return textPatched code sample
import sys
from pypdf import PdfReader
def extract_text(pdf_path: str) -> str:
# FIX: guard against endless parsing by limiting page iteration
reader = PdfReader(pdf_path)
text = ""
max_pages = 1000 # arbitrary safety ceiling
for i, page in enumerate(reader.pages):
if i >= max_pages:
break
text += page.extract_text() or ""
return textPublished 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.
- ROB: Handle EOF when reading standard xref table (#4170) (py-pdf/pypdf)
pypdf/_reader.py · PdfReader._read_standard_xref_table
Cite this entry
@misc{vaitp:cve2026113794,
title = {{pypdf <6.20 infinite loop on truncated PDF ending in cross‑ref table}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-113794},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-113794/}}
}
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 ::
