VAITP Dataset

← Back to the dataset

CVE-2026-113791

Memory exhaustion via crafted PDF with many small ops (pypdf <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 containing a content stream with many small operations, causing parsing to consume large amounts of memory. This issue is fixed in version 6.21.0.

CVSS base score
6.0
Published
2026-10-21
OWASP
A06 Vulnerable and Outdated Components
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.21.0 or later.

Vulnerable code sample

import sys
from pypdf import PdfReader

def extract_text(pdf_path: str) -> str:
    reader = PdfReader(pdf_path)
    text = ""
    # VULNERABLE: unbounded parsing of content stream operations
    for page in reader.pages:
        # iterate over all operators in the content stream without limit
        for op, args in page.get_contents().operations:
            if op == b"Tj":  # show text
                text += args[0].decode('utf-8', errors='ignore')
    return text

Patched code sample

import sys
from pypdf import PdfReader

MAX_OPERATIONS = 100000  # FIX: cap number of parsed operations to prevent exhaustion

def extract_text(pdf_path: str) -> str:
    reader = PdfReader(pdf_path)
    text = ""
    for page in reader.pages:
        op_count = 0
        for op, args in page.get_contents().operations:
            op_count += 1
            if op_count > MAX_OPERATIONS:
                break  # stop processing excessive operations
            if op == b"Tj":
                text += args[0].decode('utf-8', errors='ignore')
    return text

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 stream parsing work (#4218) (py-pdf/pypdf)
    pypdf/generic/_data_structures.py, pypdf/generic/_data_structures.py · ArrayObject.read_from_stream, pypdf/generic/_data_structures.py · ContentStream._parse_content_stream, pypdf/generic/_data_structures.py · ContentStream._read_inline_image, pypdf/generic/_data_structures.py · DictionaryObject.read_from_stream, pypdf/generic/_data_structures.py · read_object, pypdf/generic/_utils.py, pypdf/generic/__init__.py, pypdf/_configuration.py

Cite this entry

@misc{vaitp:cve2026113791,
  title        = {{Memory exhaustion via crafted PDF with many small ops (pypdf <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-113791},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-113791/}}
}

Download this entry as JSON Download the whole dataset

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 ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.