CVE-2022-24859: Manipulated inline images can cause Infinite Loop in PyPDF2

Published Apr 18, 2022
·
Updated

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

3 affected componentsFixes available
pip/PyPDF2<1.27.5
1.27.5
Pypdf2 Project Pypdf2<1.27.5
Debian Debian Linux=9.0

Event History

Apr 18, 2022
CVE Published
via MITRE·12:00 AM
Data Sourced
via MITRE·12:00 AM
DescriptionSeverityWeakness
Apr 22, 2022
Advisory Published
via GitHub·08:54 PM

Frequently Asked Questions

1

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.

2

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.

3

What versions of PyPDF2 are affected by CVE-2022-24859?

Versions of PyPDF2 prior to 1.27.5 are affected by CVE-2022-24859.

4

How severe is CVE-2022-24859?

CVE-2022-24859 has a severity rating of 5.5, which is considered medium.

5

How can I fix CVE-2022-24859?

To fix CVE-2022-24859, update PyPDF2 to version 1.27.5 or newer.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203