Vulnerabilities in pkg:pypi/PyPDF2

PACKAGE
Advisory Identifier: GHSA-xcjx-m2pj-8g79
Advisory Summary

CVE-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.

4 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/PyPDF2

4 Known Advisory Record(s)

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

CVE Identifier CVE-2022-24859
GHSA Identifier GHSA-xcjx-m2pj-8g79
Severity MODERATE
CVSS v3.1 Base Score 6.2
CWE Classification CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')
Affected Product PyPDF2
Package Ecosystem PyPI
Published Date
Last Updated

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).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (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.

PyPDF2 fixed: 1.27.5
pip install PyPDF2>=1.27.5
Verify Direct and Transitive Dependencies

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

### 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: ```python 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`](https://pypi.org/project/PyPDF2) and later are patched. Credits 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.

CVE-2022-24859 Affected PyPDF2 Versions

1 component(s)
Fixed Versions:
1.27.5
Product / Package Ecosystem Affected Versions Fixed Version
PyPDF2
PyPI
< 1.27.5
1.27.5

References

Frequently Asked Questions

What is CVE-2022-24859?
CVE-2022-24859 is a security vulnerability in PyPDF2 involving Manipulated inline images can cause Infinite Loop in PyPDF2 under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop').
Which PyPDF2 versions are affected?
Affected versions include releases prior to 1.27.5 across affected packages: PyPDF2.
What version fixes CVE-2022-24859?
Upgrading to 1.27.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is PyPDF2 affected?
Yes, PyPDF2 is affected in releases prior to 1.27.5. Upgrade your dependency to 1.27.5 or later.
What is the CVSS score of CVE-2022-24859?
CVE-2022-24859 has a CVSS v3.1 base score of 6.2 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2022-24859?
CVE-2022-24859 is classified under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop') (The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.).
How can I check PyPI dependencies for CVE-2022-24859?
Run the dependency tree command: 'pip show PyPDF2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}