CVE-2026-119208
pypdf prior to 6.21.3 can be forced into high CPU/memory use via fake /Count in encrypted PDFs.
- CVSS 7.1
- CWE-400
- Resource Management
- Remote
pypdf is a free and open-source pure-python PDF library. Prior to 6.21.3, pypdf can consume excessive time and memory when an application accesses the page count of a crafted encrypted PDF whose page tree declares a forged /Count value. Even after successful decryption, page-count retrieval trusts the unvalidated declared count instead of walking the page tree, allowing the attacker-controlled value to drive excessive work and memory use. This issue is fixed in version 6.21.3.
- CWE
- CWE-400
- CVSS base score
- 7.1
- Published
- 2026-10-29
- OWASP
- A04 Insecure Design
- 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.21.3 or later.
Vulnerable code sample
from pypdf import PdfReader
def get_page_count(path: str) -> int:
# VULNERABLE: trusts forged /Count value from encrypted PDF
reader = PdfReader(path, strict=False)
# The property `num_pages` directly returns the /Count entry without validation
return reader.num_pagesPatched code sample
from pypdf import PdfReader
def get_page_count(path: str) -> int:
# FIX: walks the page tree to compute real page count
reader = PdfReader(path, strict=False)
# Access the pages iterator which validates the tree structure
return len(list(reader.pages))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: Use the validated page count after decrypting a document (#4270) (py-pdf/pypdf)
pypdf/_doc_common.py · PdfDocCommon.get_num_pages
Cite this entry
@misc{vaitp:cve2026119208,
title = {{pypdf prior to 6.21.3 can be forced into high CPU/memory use via fake /Count in encrypted PDFs.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-119208},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-119208/}}
}
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 ::
