CVE-2022-24859: Manipulated inline images can cause Infinite Loop in PyPDF2
Impact
An attacker who uses this vulnerability can craft a PDF which leads to an infinite loop if the PyPDF2 user wrote the following code:
python from PyPDF2 import PdfFileReader, PdfFileWriter from PyPDF2.pdf import ContentStream
reader = PdfFileReader("malicious.pdf", strict=False) for page in reader.pages: ContentStream(page.getContents(), reader)
Patches
PyPDF2==1.27.5 and later are patched.
Credits to Sebastian Krause for finding (issue) and fixing (PR) it.
Other sources
PyPDF2 is an open source python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files. In versions prior to 1.27.5 an attacker who uses this vulnerability can craft a PDF which leads to an infinite loop if the PyPDF2 if the code attempts to get the content stream. The reason is that the last while-loop in ContentStream.readInlineImage only terminates when it finds the EI token, but never actually checks if the stream has already ended. This issue has been resolved in version 1.27.5. Users unable to upgrade should validate and PDFs prior to iterating over their content stream.
— NVD
Affected Software
Remediation
Patch Available
Event History
Frequently Asked Questions
What is CVE-2022-24859?
CVE-2022-24859 is a vulnerability in PyPDF2, an open source python PDF library, that allows an attacker to craft a malicious PDF file that can cause an infinite loop in the software.
How does CVE-2022-24859 impact PyPDF2?
CVE-2022-24859 can lead to an infinite loop in PyPDF2 if a specially crafted PDF file is processed by the software.
What versions of PyPDF2 are affected by CVE-2022-24859?
Versions of PyPDF2 prior to 1.27.5 are affected by CVE-2022-24859.
How severe is CVE-2022-24859?
CVE-2022-24859 has a severity rating of 5.5, which is considered medium.
How can I fix CVE-2022-24859?
To fix CVE-2022-24859, update PyPDF2 to version 1.27.5 or newer.