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)
- 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:
breakPatched 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:
breakCite 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/}}
}
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 ::
