Vulnerability · Published Apr 18, 2022 · Assigned by GitHub_M
CVE-2022-24859Manipulated inline images can cause Infinite Loop in PyPDF2
Medium 6.2
In plain English
A medium-severity infinite loop in PyPDF2 from py-pdf. Proof-of-concept exploit code is public. The chance it is exploited in the next 30 days is estimated at 1.3% (higher than 71% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.
Official description
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.
Affected packages & fixed versions
| Ecosystem | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian:12 | pypdf2 | 1.27.9-1 | DEBIAN-CVE-2022-24859 |
| PyPI | pypdf2 | 1.27.5 | GHSA-xcjx-m2pj-8g79 |
| PyPI | pypdf2 | 1.27.5 | PYSEC-2022-194 |
| Ubuntu:22.04:LTS | pypdf2 | 1.26.0-4ubuntu0.22.04.1 | USN-6176-1 |
| Ubuntu:22.04:LTS | pypdf2 | 1.26.0-4ubuntu0.22.04.1 | UBUNTU-CVE-2022-24859 |
Affected products (as reported)
Weakness: CWE-835 · Vector: CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
References
- https://github.com/py-pdf/PyPDF2/security/advisories/GHSA-xcjx-m2pj-8g79
- https://github.com/py-pdf/PyPDF2/issues/329
- https://github.com/py-pdf/PyPDF2/pull/740
- https://github.com/py-pdf/PyPDF2/releases/tag/1.27.5
- [debian-lts-announce] 20220603 [SECURITY] [DLA 3039-1] pypdf2 security update mailing-list
- [debian-lts-announce] 20230609 [SECURITY] [DLA 3451-1] pypdf2 security update mailing-list