Every CVE Search/ Get API key

CVE-2022-24859

Manipulated inline images can cause Infinite Loop in PyPDF2

6.2 MediumFix available

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.

Attack profile

How easy it is to exploit

Attack vector
Local
Complexity
Low
Privileges needed
None
User interaction
None

What an attacker can affect

Confidentiality
None
Integrity
None
Availability
High

Exploit likelihood

1.33%Up 0.4 points since Apr 19, 2022
90%50%10%1%

What each source reports

CVE List Score used 6.2

Manipulated inline images can cause Infinite Loop in PyPDF2

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.

Record
CVE-2022-24859
CVSS 3.1
6.2 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Weakness
CWE-835
Updated
2026-11-02
EUVDEUVD-2022-0214 6.2

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.

Record
EUVD-2022-0214
CVSS 3.1
6.2 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Updated
2026-11-02
GitHub AdvisoriesGHSA-xcjx-m2pj-8g79 6.9

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:

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.

Record
GHSA-xcjx-m2pj-8g79
CVSS 4.0
6.9 MediumCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
CVSS 3.1
6.2 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Weakness
CWE-835
Updated
2026-11-02
NVD 6.2

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.

Record
CVE-2022-24859
CVSS 3.1
6.2 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
CVSS 2.0
4.3 MediumAV:N/AC:M/Au:N/C:N/I:N/A:P
Weakness
CWE-835
Updated
2026-11-02
OSV 6.2

Manipulated inline images can cause Infinite Loop in PyPDF2

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.

Record
CVE-2022-24859
CVSS 3.1
6.2 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Weakness
CWE-835
Updated
2026-11-02
OSVDEBIAN-CVE-2022-24859 5.5

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.

Record
DEBIAN-CVE-2022-24859
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
Updated
2026-11-03
Show 6 moreShow less
OSVGHSA-xcjx-m2pj-8g79 6.9

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:

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.

Record
GHSA-xcjx-m2pj-8g79
CVSS 4.0
6.9 MediumCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
CVSS 3.1
6.2 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Weakness
CWE-835
Updated
2026-11-02
OSVUBUNTU-CVE-2022-24859 5.5

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.

Record
UBUNTU-CVE-2022-24859
CVSS 3.1
5.5 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
CVSS 3.1
6.2 MediumCVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Updated
2026-11-02
OSVMGASA-2022-0224 No score

Updated python-pypdf2 packages fix security vulnerability

Infinite loop with manipulated inline images (CVE-2022-24859)

Record
MGASA-2022-0224
Updated
2026-11-02
OSVopenSUSE-SU-2024:0366-1 No score

Security update for python-PyPDF2

This update for python-PyPDF2 fixes the following issues:

  • CVE-2022-24859: Fixed infinite loop vulnerability (boo#1198588)
Record
openSUSE-SU-2024:0366-1
Updated
2026-11-02
OSVPYSEC-2022-194 No score

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.

Record
PYSEC-2022-194
Updated
2026-11-02
OSVUSN-6176-1 No score

pypdf2 vulnerability

It was discovered that PyPDF2 incorrectly handled certain PDF files. If a user or automated system were tricked into processing a specially crafted file, an attacker could possibly use this issue to consume system resources, resulting in a denial of service.

Record
USN-6176-1
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
pypdf2
PyPI
before 1.27.5
1.27.5
pypdf2
Debian:12
before 1.27.9-1
1.27.9-1
pypdf2
Debian:9
before 1.26.0-2+deb9u1, plus listed versions
1.26.0-2
1.26.0-2+deb9u1
pypdf2
Debian:10
before 1.26.0-2+deb10u1, plus listed versions
1.26.0-2
1.26.0-2+deb10u1
pypdf2
PyPI
before 1.27.5, plus listed versions
1.151.161.171.181.19
Show 13 moreShow less
1.201.211.221.231.241.251.25.11.26.01.27.01.27.11.27.21.27.31.27.4
1.27.5
python-pypdf2
Mageia:8
before 1.27.5-1.mga8
1.27.5-1.mga8
pypdf2
Ubuntu:Pro:16.04:LTS
before 1.25.1-1ubuntu0.1~esm1, plus listed versions
1.23+git20141008-11.25.1-1
1.25.1-1ubuntu0.1~esm1
pypdf2
Ubuntu:Pro:18.04:LTS
before 1.26.0-2ubuntu0.1~esm1, plus listed versions
1.26.0-2
1.26.0-2ubuntu0.1~esm1
pypdf2
Ubuntu:20.04:LTS
before 1.26.0-3ubuntu1.20.04.1, plus listed versions
1.26.0-21.26.0-3ubuntu1
1.26.0-3ubuntu1.20.04.1
pypdf2
Ubuntu:22.04:LTS
before 1.26.0-4ubuntu0.22.04.1, plus listed versions
1.26.0-4
1.26.0-4ubuntu0.22.04.1
python-PyPDF2
SUSE:Package Hub 15 SP6
before 1.26.0-bp156.4.3.1
1.26.0-bp156.4.3.1
python-PyPDF2
openSUSE:Leap 15.6
before 1.26.0-bp156.4.3.1
1.26.0-bp156.4.3.1

History

History
RecordedChangedSources
first indexedCVE List, EUVD, GitHub Advisories, NVD, OSV

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2022-24859 is a medium vulnerability (CVSS 6.2) in Py-pdf Pypdf2, published April 18, 2022. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 1.33%, the 71st percentile. Fixed in pypdf2 1.27.5.

References

Show 15 moreShow less
MoveEnter Open