Skip to content
OpenAdvisories
Medium · 6.2 CVE-2022-24859 EUVD-2022-0214GHSA-xcjx-m2pj-8g79PYSEC-2022-194

Manipulated inline images can cause Infinite Loop in PyPDF2

Published Apr 18, 2022 · Updated Apr 22, 2025 · Assigned by GitHub_M

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 products

VendorProductAffectedFixed
py-pdf PyPDF2 < 1.27.5 —

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
Debian 12 pypdf2 1.27.9-1 —
Debian 10 pypdf2 1.26.0-2+deb10u1 DLA-3451-1
Debian 9 pypdf2 1.26.0-2+deb9u1 DLA-3039-1
ReleasePackageFixed inAdvisory
Ubuntu 22.04 LTS pypdf2 1.26.0-4ubuntu0.22.04.1 USN-6176-1
Ubuntu 20.04 LTS pypdf2 1.26.0-3ubuntu1.20.04.1 USN-6176-1
Show 2 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Ubuntu Pro 18.04 LTS pypdf2 1.26.0-2ubuntu0.1~esm1 USN-6176-1
Ubuntu Pro 16.04 LTS pypdf2 1.25.1-1ubuntu0.1~esm1 USN-6176-1
ReleasePackageFixed inAdvisory
SUSE Package Hub 15 SP6 python-PyPDF2 1.26.0-bp156.4.3.1 openSUSE-SU-2024:0366-1
ReleasePackageFixed inAdvisory
openSUSE Leap 15.6 python-PyPDF2 1.26.0-bp156.4.3.1 openSUSE-SU-2024:0366-1

Affected packages

EcosystemPackageAffectedFixedRecord
PyPI pypdf2 < 1.27.5 1.27.5 GHSA-xcjx-m2pj-8g79

Advisories 4

References