VAITP Dataset

← Back to the dataset

CVE-2023-36464

pypdf PDF library infinite loop vulnerability

  • CVSS 5.5
  • CWE-835 Loop with Unreachable Exit Condition ('Infinite Loop')
  • Input Validation and Sanitization
  • Local

pypdf is an open source, pure-python PDF library. In affected versions an attacker may craft a PDF which leads to an infinite loop if `__parse_content_stream` is executed. That is, for example, the case if the user extracted text from such a PDF. This issue was introduced in pull request #969 and resolved in pull request #1828. Users are advised to upgrade. Users unable to upgrade may modify the line `while peek not in (b"\r", b"\n")` in `pypdf/generic/_data_structures.py` to `while peek not in (b"\r", b"\n", b"")`.

CVSS base score
5.5
Published
2023-06-27
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Algorithm
Code defect classification
Incorrect Algorithm
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Local
Impact
Denial of Service (DoS)
Affected component
pypdf
Fixed by upgrading
Yes

Solution

Update pypdf to version containing pull request #1828.

Vulnerable code sample

def parse_content_stream(stream):
    """Vulnerable function that demonstrates the security issue."""
    while True:
        peek = stream.peek(1)
        if peek not in (b"\r", b"\n"):
            pass
        else:
            break

Patched code sample

def parse_content_stream(stream):
    """Secure function that fixes the vulnerability."""
    while True:
        peek = stream.peek(1)
        if peek not in (b"\r", b"\n", b""):
            pass
        else:
            break

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.

Cite this entry

@misc{vaitp:cve202336464,
  title        = {{pypdf PDF library infinite loop vulnerability}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2023},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2023-36464},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-36464/}}
}

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.