Skip to content
Heist/ feed
Back to feed
Medium

Manipulated inline images can cause Infinite Loop in PyPDF2

Type: advisorySources: OSV

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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2022-24859
Confirmed fixed CVEs
Not specified
Updated in this feed
4 Nov 2026, 01:23 UTC · Revision 1

Source evidence

Manipulated inline images can cause Infinite Loop in PyPDF2

core-osv · Original source

Published 18 Apr 2022, 00:00 UTC

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.

osv:CVE-2022-24859
Complete source record
{
  "id": "93e76d2ed0f413ec9763cceea3460019c9ca115037247720a232d37ccd566b03",
  "url": "https://osv.dev/vulnerability/CVE-2022-24859",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "Manipulated inline images can cause Infinite Loop in PyPDF2",
    "summary": "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.",
    "evidence": "osv:CVE-2022-24859",
    "products": [],
    "severity": "medium",
    "structured": {
      "id": "CVE-2022-24859",
      "aliases": [
        "CVE-2022-24859",
        "GHSA-xcjx-m2pj-8g79",
        "PYSEC-2022-194"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/py-pdf/pypdf",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "733989af6fc0f87d69d78509f3766b47ffc24e1d"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "1.27.5"
                      }
                    ],
                    "source": "AFFECTED_FIELD",
                    "strategy": "StringRangeExpression"
                  },
                  {
                    "range": [
                      {
                        "fixed": "733989af6fc0f87d69d78509f3766b47ffc24e1d"
                      }
                    ],
                    "source": "REFERENCES_TAG",
                    "original_tag": "1.27.5"
                  },
                  {
                    "cpe": "cpe:2.3:a:pypdf2_project:pypdf2:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "1.27.5"
                      }
                    ],
                    "source": "CPE_RANGE"
                  }
                ]
              }
            }
          ],
          "versions": [
            "1.27.4",
            "1.27.3",
            "1.27.2",
            "1.27.1",
            "1.27.0",
            "v1.24",
            "1.26.0",
            "v1.25.1",
            "v1.25",
            "v1.23",
            "v1.22",
            "v1.21",
            "v1.20",
            "v1.19",
            "v1.18",
            "v1.17"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2022-24859.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:32.298517702Z",
      "provider": "osv",
      "references": [
        "https://github.com/py-pdf/PyPDF2/releases/tag/1.27.5",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/24xxx/CVE-2022-24859.json",
        "https://github.com/py-pdf/PyPDF2/security/advisories/GHSA-xcjx-m2pj-8g79",
        "https://nvd.nist.gov/vuln/detail/CVE-2022-24859",
        "https://github.com/py-pdf/PyPDF2/issues/329",
        "https://github.com/py-pdf/PyPDF2/pull/740",
        "https://lists.debian.org/debian-lts-announce/2022/06/msg00001.html",
        "https://lists.debian.org/debian-lts-announce/2023/06/msg00013.html"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-835"
        ],
        "cna_assigner": "GitHub_M",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/24xxx/CVE-2022-24859.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2022-24859",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 499435,
  "published_at": "2022-04-18T00:00:00+00:00"
}