Vulnerabilities in pkg:pypi/PyPDF2
PACKAGECVE-2022-24859 is a MODERATE (CVSS 6.2) manipulated inline images can cause vulnerability (CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')) affecting PyPDF2 libraries in the PyPI ecosystem. The issue involves manipulated inline images can cause infinite loop in pypdf2. Remediation is available by upgrading affected packages to version 1.27.5.
pkg:pypi/PyPDF2
Vulnerability advisories affecting package pkg:pypi/PyPDF2. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-xcjx-m2pj-8g79 | CVE-2022-24859 | MODERATE | Manipulated inline images can cause Infinite Loop in PyPDF2 |
| GHSA-4vvm-4w3v-6mr8 | CVE-2023-36464 | MODERATE | pypdf and PyPDF2 possible Infinite Loop when a comment isn't followed by a character |
| GHSA-hm9v-vj3r-r55m | CVE-2023-36807 | MODERATE | PyPDF2 vulnerable to possible Infinite Loop when reading malformed objects |
| GHSA-jrm6-h9cq-8gqw | CVE-2023-36810 | MODERATE | PyPDF2 quadratic runtime with malformed PDF missing xref marker |
CVE-2022-24859 at a Glance
Security Impact
CVSS: 6.2
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).
How to Fix CVE-2022-24859
To remediate this vulnerability, upgrade all affected PyPDF2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install PyPDF2>=1.27.5
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show PyPDF2
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2022-24859, inspect your installed packages using pip:
pip show PyPDF2
Analyze the terminal output to locate any version of PyPDF2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.27.5), your application is affected.
Note: The pip show PyPDF2 command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop'), where the product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. In PyPDF2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2022-24859 Affected PyPDF2 Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
PyPDF2
|
PyPI |
< 1.27.5
|
1.27.5
|
References
Frequently Asked Questions
What is CVE-2022-24859?
Which PyPDF2 versions are affected?
What version fixes CVE-2022-24859?
Is PyPDF2 affected?
What is the CVSS score of CVE-2022-24859?
What CWE is associated with CVE-2022-24859?
How can I check PyPI dependencies for CVE-2022-24859?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-xcjx-m2pj-8g79",
"modified" : "2024-10-14T16:49:22Z",
"published" : "2022-04-22T20:54:41Z",
"aliases" : [ "CVE-2022-24859" ],
"summary" : "Manipulated inline images can cause Infinite Loop in PyPDF2",
"details" : "### Impact\n\nAn attacker who uses this vulnerability can craft a PDF which leads to an infinite loop if the PyPDF2 user wrote the following code:\n\n```python\nfrom PyPDF2 import PdfFileReader, PdfFileWriter\nfrom PyPDF2.pdf import ContentStream\n\nreader = PdfFileReader(\"malicious.pdf\", strict=False)\nfor page in reader.pages:\n ContentStream(page.getContents(), reader)\n```\n\n### Patches\n\n[`PyPDF2==1.27.5`](https://pypi.org/project/PyPDF2) and later are patched.\n\nCredits to [Sebastian Krause](https://github.com/sekrause) for finding ([issue](https://github.com/py-pdf/PyPDF2/issues/329)) and fixing ([PR](https://github.com/py-pdf/PyPDF2/pull/740)) it.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
}, {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "PyPDF2"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.27.5"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/py-pdf/PyPDF2/security/advisories/GHSA-xcjx-m2pj-8g79"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-24859"
}, {
"type" : "WEB",
"url" : "https://github.com/py-pdf/PyPDF2/issues/329"
}, {
"type" : "WEB",
"url" : "https://github.com/py-pdf/PyPDF2/pull/740"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/py-pdf/PyPDF2"
}, {
"type" : "WEB",
"url" : "https://github.com/py-pdf/PyPDF2/releases/tag/1.27.5"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pypdf2/PYSEC-2022-194.yaml"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2022/06/msg00001.html"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2023/06/msg00013.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-835" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-04-22T20:54:41Z",
"nvd_published_at" : "2022-04-18T19:15:00Z"
}
}