{"id":"CVE-2022-24859","aliases":["CVE-2022-24859","GHSA-xcjx-m2pj-8g79","PYSEC-2022-194"],"related":[],"kind":"vulnerability","state":"published","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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### 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.","format":"markdown","source":"ghsa"},{"lang":"es","text":"PyPDF2 es una librería PDF de código abierto capaz de dividir, fusionar, recortar y transformar las páginas de los archivos PDF. En versiones anteriores a 1.27.5 un atacante que use esta vulnerabilidad puede diseñar un PDF que conlleva a un bucle infinito si el código de PyPDF2 intenta conseguir el flujo de contenido. La razón es que el último bucle while en \"ContentStream._readInlineImage\" sólo termina cuando encuentra el token \"EI\", pero nunca comprueba si el flujo ya ha terminado. Este problema ha sido resuelto en versión \"1.27.5\". Los usuarios que no puedan actualizarse deberán comprobar y PDFs antes de iterar sobre su flujo de contenido","source":"nvd"}],"published":"2022-04-18T00:00:00.000Z","modified":"2026-06-17T04:32:40.613Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":6.2,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":6.2,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":6.2,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H","score":5.5,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:M/Au:N/C:N/I:N/A:P","score":4.3,"rating":"MEDIUM"}],"cwes":["CWE-835"],"affected":[{"ranges":[{"version":"< 1.27.5","status":"affected"}],"vendor":"py-pdf","product":"PyPDF2","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.27.5"}],"ecosystem":"PyPI","package":"pypdf2","purl":"pkg:pypi/pypdf2","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"1.27.5"}],"vendor":"pypdf2_project","product":"pypdf2","cpe":"cpe:2.3:a:pypdf2_project:pypdf2:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"status":"affected","version":"9.0"}],"vendor":"debian","product":"debian_linux","cpe":"cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.27.5"}],"ecosystem":"PyPI","package":"pypdf2","purl":"pkg:pypi/pypdf2","source":"pysec"}],"references":[{"url":"https://github.com/py-pdf/PyPDF2/security/advisories/GHSA-xcjx-m2pj-8g79","tags":["advisory","exploit","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/py-pdf/PyPDF2/issues/329","tags":["exploit","report","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/py-pdf/PyPDF2/pull/740","tags":["patch","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/py-pdf/PyPDF2/releases/tag/1.27.5","tags":["release-notes","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://lists.debian.org/debian-lts-announce/2022/06/msg00001.html","tags":["mailing-list","third-party-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://lists.debian.org/debian-lts-announce/2023/06/msg00013.html","tags":["mailing-list","web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2022-24859","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/py-pdf/PyPDF2","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/pypdf2/PYSEC-2022-194.yaml","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-04-22T15:48:47.752Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2022-24859","url":"https://www.cve.org/CVERecord?id=CVE-2022-24859","licence":"CVE Terms of Use","modified":"2025-04-22T18:15:17.460Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-xcjx-m2pj-8g79","url":"https://github.com/advisories/GHSA-xcjx-m2pj-8g79","licence":"CC-BY-4.0","modified":"2024-10-14T18:55:47.089Z"},{"source":"nvd","name":"NVD","id":"CVE-2022-24859","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-24859","licence":"Public domain","modified":"2026-06-17T04:32:40.613Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2022-194","url":"https://osv.dev/vulnerability/PYSEC-2022-194","licence":"CC-BY-4.0","modified":"2023-11-08T04:08:38.867Z"}],"updatedAt":"2026-11-25T22:58:10.820Z","epss":{"score":0.01328,"percentile":0.71843,"date":"2026-12-01T12:00:22.000Z"}}