CVE-2026-113789
Memory‑exhaustion DoS via crafted PDF when extracting form fields (pre‑6.21.0).
- CVSS 6.0
- CWE-400
- Resource Management
- Remote
pypdf is a free and open-source pure-python PDF library. Prior to 6.21.0, an attacker can craft a PDF that causes large memory usage or long runtimes when an application retrieves the document's form fields. This issue is fixed in version 6.21.0.
- CWE
- CWE-400
- CVSS base score
- 6.0
- Published
- 2026-10-21
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Timing/Serialization
- Code defect classification
- Timing Issues
- Category
- Resource Management
- Subcategory
- Memory Leaks
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- pypdf
- Fixed by upgrading
- Yes
Solution
Upgrade pypdf to version 6.21.0 or later.
Vulnerable code sample
from pypdf import PdfReader
def extract_form_fields(pdf_path):
"""Return all form field values from a PDF."""
reader = PdfReader(pdf_path)
# VULNERABLE: unrestricted extraction may allocate huge memory
fields = reader.get_form_text_fields()
return fieldsPatched code sample
from pypdf import PdfReader
def extract_form_fields(pdf_path):
"""Return all form field values from a PDF, with a safety limit."""
reader = PdfReader(pdf_path)
# FIX: limit the number of fields processed to avoid memory blow‑up
all_fields = reader.get_fields()
if len(all_fields) > 1000:
raise MemoryError("PDF contains too many form fields")
fields = {k: v.get("/V") for k, v in all_fields.items() if "/V" in v}
return fieldsPublished 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 and limit field work (#4219) (py-pdf/pypdf)
pypdf/_configuration.py,pypdf/_doc_common.py,pypdf/_doc_common.py · PdfDocCommon.get_fields,pypdf/_doc_common.py · PdfDocCommon._build_field,pypdf/_doc_common.py · PdfDocCommon._check_kids
Cite this entry
@misc{vaitp:cve2026113789,
title = {{Memory‑exhaustion DoS via crafted PDF when extracting form fields (pre‑6.21.0).}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-113789},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-113789/}}
}
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 ::
