CVE-2026-84311
Exponential traversal of reused form XObjects leads to high CPU/memory usage.
- CVSS 4.8
- CWE-834
- Resource Management
- Remote
pypdf is a free and open-source pure-python PDF library. Prior to 6.16.1, an attacker can craft a PDF that causes pypdf/_page.py PageObject._extract_text and PageObject.extract_xform_text to traverse a directed acyclic graph of reused form XObjects in which each form invokes a child multiple times, creating exponentially many traversal paths and causing long runtimes and large memory consumption. This issue is fixed in version 6.16.1.
- CWE
- CWE-834
- CVSS base score
- 4.8
- Published
- 2026-09-01
- 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.16.1 or newer.
Vulnerable code sample
import typing
from pypdf import PdfReader, PageObject
def extract_all_text(page: PageObject) -> str:
"""Recursively extract text from a page and all its form XObjects."""
# VULNERABLE: unbounded recursion over reused form XObjects can cause exponential blow‑up
def _walk(obj: typing.Any) -> str:
text = ""
if isinstance(obj, PageObject):
text += obj.extract_text() or ""
# Recurse into form XObjects referenced by the page
for xobj in obj["/Resources"].get("/XObject", {}):
text += _walk(obj["/Resources"]["/XObject"][xobj])
return text
return _walk(page)Patched code sample
import typing
from pypdf import PdfReader, PageObject
def extract_all_text(page: PageObject) -> str:
"""Recursively extract text from a page and all its form XObjects."""
# FIX: track visited XObjects to avoid exponential recursion
def _walk(obj: typing.Any, visited: set) -> str:
text = ""
if isinstance(obj, PageObject):
text += obj.extract_text() or ""
# Recurse into form XObjects referenced by the page
for name, xobj in obj["/Resources"].get("/XObject", {}).items():
if id(xobj) in visited:
continue
visited.add(id(xobj))
text += _walk(xobj, visited)
return text
return _walk(page, set())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 iterations for outline retrieval and XForm text extraction (#3966) (py-pdf/pypdf)
pypdf/_doc_common.py,pypdf/_doc_common.py · DocumentInformation.modification_date_raw,pypdf/_doc_common.py · PdfDocCommon._get_outline,pypdf/_page.py,pypdf/_page.py · PageObject.extract_xform_text,pypdf/_page.py · PageObject._extract_text,pypdf/_utils.py
Cite this entry
@misc{vaitp:cve202684311,
title = {{Exponential traversal of reused form XObjects leads to high CPU/memory usage.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-84311},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-84311/}}
}
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 ::
