CVE-2026-102999
Inefficient attachment parsing in pypdf ≤ 6.18 causes excessive runtime.
- CVSS 8.7
- CWE-400
- Resource Management
- Local
pypdf is a free and open-source pure-python PDF library. Prior to 6.19.0, a crafted PDF containing many embedded files can cause the dictionary-based attachments API in pypdf/_doc_common.py to reparse the full attachment list for each content lookup, producing repeated work and long runtimes when an application accesses the embedded-file mapping. This issue is fixed in version 6.19.0.
- CWE
- CWE-400
- CVSS base score
- 8.7
- Published
- 2026-09-30
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Timing/Serialization
- Code defect classification
- Timing Issues
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Local
- Impact
- Denial of Service (DoS)
- Affected component
- pypdf
- Fixed by upgrading
- Yes
Solution
Upgrade pypdf to version 6.19.0 or later.
Vulnerable code sample
import typing
from pypdf import PdfReader
class AttachmentExtractor:
def __init__(self, path: str):
self.reader = PdfReader(path)
def _list_attachments(self) -> dict:
# Simulate the original per‑lookup reparsing logic
attachments = {}
for i, file_spec in enumerate(self.reader.trailer["/Root"].get("/Names", {}).get("/EmbeddedFiles", {}).get("/Names", [])):
if i % 2 == 0: # name
name = file_spec
else: # file spec dict
attachments[name] = file_spec.get_object()
return attachments
def get_attachment(self, name: str) -> typing.Optional[bytes]:
# VULNERABLE: reparses full attachment list on each lookup, causing O(N²) work
all_attachments = self._list_attachments()
spec = all_attachments.get(name)
if spec:
return spec.get_data()
return NonePatched code sample
import typing
from pypdf import PdfReader
class AttachmentExtractor:
def __init__(self, path: str):
self.reader = PdfReader(path)
self._cached_attachments: dict = {}
def _list_attachments(self) -> dict:
# Build the attachment dict once
attachments = {}
for i, file_spec in enumerate(self.reader.trailer["/Root"].get("/Names", {}).get("/EmbeddedFiles", {}).get("/Names", [])):
if i % 2 == 0:
name = file_spec
else:
attachments[name] = file_spec.get_object()
return attachments
def _ensure_cache(self):
if not self._cached_attachments:
# FIX: cache the parsed attachment list to avoid repeated work
self._cached_attachments = self._list_attachments()
def get_attachment(self, name: str) -> typing.Optional[bytes]:
self._ensure_cache()
spec = self._cached_attachments.get(name)
if spec:
return spec.get_data()
return NonePublished 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.
- PI: Reduce number of full data lookups for attachment mapping API (#4081) (py-pdf/pypdf)
pypdf/generic/_files.py,pypdf/generic/_files.py · EmbeddedFile._load,pypdf/generic/_files.py · EmbeddedFile._load_from_names,pypdf/_doc_common.py,pypdf/_doc_common.py · PdfDocCommon.attachments,pypdf/_doc_common.py · PdfDocCommon.attachment_list
Cite this entry
@misc{vaitp:cve2026102999,
title = {{Inefficient attachment parsing in pypdf ≤ 6.18 causes excessive runtime.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-102999},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-102999/}}
}
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 ::
