CVE-2023-46250: Pypdf Possible Infinite Loop When PdfWriter(clone_from) Vulnerability
MODERATECVE-2023-46250 is a MODERATE (CVSS 5.1) possible infinite loop when pdfwriter(clone_from) vulnerability (CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')) affecting Pypdf libraries in the PyPI ecosystem. The issue involves possible infinite loop when pdfwriter(clone_from) is used with a pdf. Remediation is available by upgrading affected packages to version 3.17.0.
CVE-2023-46250 at a Glance
Security Impact
CVSS: 5.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H).
How to Fix CVE-2023-46250
To remediate this vulnerability, upgrade all affected Pypdf 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 pypdf>=3.17.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show pypdf
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2023-46250, inspect your installed packages using pip:
pip show pypdf
Analyze the terminal output to locate any version of Pypdf in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.17.0), your application is affected.
Note: The pip show pypdf 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 Pypdf, 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-2023-46250 Affected Pypdf Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
pypdf
|
PyPI |
≥ 3.7.0
< 3.17.0
|
3.17.0
|
References
Frequently Asked Questions
What is CVE-2023-46250?
Which Pypdf versions are affected?
What version fixes CVE-2023-46250?
Is pypdf affected?
What is the CVSS score of CVE-2023-46250?
What CWE is associated with CVE-2023-46250?
How can I check PyPI dependencies for CVE-2023-46250?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-wjcc-cq79-p63f",
"modified" : "2023-10-31T22:22:50Z",
"published" : "2023-10-31T22:22:50Z",
"aliases" : [ "CVE-2023-46250" ],
"summary" : "Possible Infinite Loop when PdfWriter(clone_from) is used with a PDF",
"details" : "### Impact\nAn attacker who uses this vulnerability can craft a PDF which leads to an infinite loop.\nThis infinite loop blocks the current process and can utilize a single core of the CPU by 100%. It does not affect memory usage.\n\nThat is, for example, the case when the pypdf-user manipulates an incoming malicious PDF e.g. by merging it with another PDF or by adding annotations.\n\n### Patches\nThe issue was fixed with #2264\n\n### Workarounds\nIf you cannot update your version of pypdf, you should modify `pypdf/generic/_data_structures.py` just like #2264 did.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "pypdf"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.7.0"
}, {
"fixed" : "3.17.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/py-pdf/pypdf/security/advisories/GHSA-wjcc-cq79-p63f"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-46250"
}, {
"type" : "WEB",
"url" : "https://github.com/py-pdf/pypdf/pull/2264"
}, {
"type" : "WEB",
"url" : "https://github.com/py-pdf/pypdf/commit/9b23ac3c9619492570011d551d521690de9a3e2d"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/py-pdf/pypdf"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-835" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2023-10-31T22:22:50Z",
"nvd_published_at" : "2023-10-31T16:15:09Z"
}
}