CVE-2022-24859
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.
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
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 Medium
CVSS: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 Medium
CVSS: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 Medium
CVSS: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 Medium
CVSS: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 Medium
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H - CVSS 3.1
- 5.5 Medium
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - CVSS 2.0
- 4.3 Medium
AV: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 Medium
CVSS: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 Medium
CVSS: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 Medium
CVSS: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 Medium
CVSS: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 Medium
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H - CVSS 3.1
- 6.2 Medium
CVSS: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
| Package | Affected | Fixed |
|---|---|---|
pypdf2PyPI |
before 1.27.5 | 1.27.5 |
pypdf2Debian:12 |
before 1.27.9-1 | 1.27.9-1 |
pypdf2Debian:9 |
before 1.26.0-2+deb9u1, plus listed versions 1.26.0-2 |
1.26.0-2+deb9u1 |
pypdf2Debian:10 |
before 1.26.0-2+deb10u1, plus listed versions 1.26.0-2 |
1.26.0-2+deb10u1 |
pypdf2PyPI |
before 1.27.5, plus listed versions 1.151.161.171.181.19 Show 13 moreShow less1.201.211.221.231.241.251.25.11.26.01.27.01.27.11.27.21.27.31.27.4 |
1.27.5 |
python-pypdf2Mageia:8 |
before 1.27.5-1.mga8 | 1.27.5-1.mga8 |
pypdf2Ubuntu: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 |
pypdf2Ubuntu:Pro:18.04:LTS |
before 1.26.0-2ubuntu0.1~esm1, plus listed versions 1.26.0-2 |
1.26.0-2ubuntu0.1~esm1 |
pypdf2Ubuntu: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 |
pypdf2Ubuntu: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-PyPDF2SUSE:Package Hub 15 SP6 |
before 1.26.0-bp156.4.3.1 | 1.26.0-bp156.4.3.1 |
python-PyPDF2openSUSE:Leap 15.6 |
before 1.26.0-bp156.4.3.1 | 1.26.0-bp156.4.3.1 |
History
| Recorded | Changed | Sources |
|---|---|---|
| first indexed | CVE 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
github.com/py-pdf/PyPDF2/security/advisories/GHSA-xcjx-m2pj-8g79
github.com/py-pdf/PyPDF2/issues/329
github.com/py-pdf/PyPDF2/pull/740
github.com/py-pdf/PyPDF2/releases/tag/1.27.5
lists.debian.org/debian-lts-announce/2022/06/msg00001.html
lists.debian.org/debian-lts-announce/2023/06/msg00013.html
Show 15 moreShow less
nvd.nist.gov/vuln/detail/CVE-2022-24859
github.com/pypa/advisory-database/tree/main/vulns/pypdf2/PYSEC-2022-194.yaml
github.com/advisories/GHSA-xcjx-m2pj-8g79
github.com/CVEProject/cvelistV5/tree/main/cves/2022/24xxx/CVE-2022-24859.json
security-tracker.debian.org/tracker/CVE-2022-24859
github.com/py-pdf/PyPDF2
advisories.mageia.org/MGASA-2022-0224.html
bugs.mageia.org/show_bug.cgi?id=30511
debian.org/lts/security/2022/dla-3039
ubuntu.com/security/CVE-2022-24859
ubuntu.com/security/notices/USN-6176-1
cve.org/CVERecord?id=CVE-2022-24859
lists.opensuse.org/archives/list/[email protected]/thread/JXAHSUMAQ6VKWEA3MS762SNZWXCCD54L
bugzilla.suse.com/1198588
suse.com/security/cve/CVE-2022-24859