{"id":"CVE-2023-36807","aliases":["CVE-2023-36807","GHSA-hm9v-vj3r-r55m","PYSEC-2026-1836"],"related":[],"kind":"vulnerability","state":"published","title":"Infinite Loop when reading malformed objects in pypdf","summary":"pypdf is a pure-python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files. In version 2.10.5 an attacker who uses this vulnerability can craft a PDF which leads to an infinite loop. This infinite loop blocks the current process and can utilize a single core of the CPU by 100%. It does not affect memory usage. That is, for example, the case if the user extracted metadata from such a malformed PDF. Versions prior to 2.10.5 throw an error, but do not hang forever. This issue was fixed with https://github.com/py-pdf/pypdf/pull/1331 which has been included in release 2.10.6. Users are advised to upgrade. Users unable to upgrade should modify `PyPDF2/generic/_data_structures.py::read_object` to an an error throwing case. See GHSA-hm9v-vj3r-r55m for details.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"pypdf is a pure-python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files. In version 2.10.5 an attacker who uses this vulnerability can craft a PDF which leads to an infinite loop. This infinite loop blocks the current process and can utilize a single core of the CPU by 100%. It does not affect memory usage. That is, for example, the case if the user extracted metadata from such a malformed PDF. Versions prior to 2.10.5 throw an error, but do not hang forever. This issue was fixed with https://github.com/py-pdf/pypdf/pull/1331 which has been included in release 2.10.6. Users are advised to upgrade. Users unable to upgrade should modify `PyPDF2/generic/_data_structures.py::read_object` to an an error throwing case. See GHSA-hm9v-vj3r-r55m for details.","source":"cvelist"},{"lang":"en","text":"### 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. That is, for example, the case if the user extracted metadata from such a malformed PDF.\n\n### Patches\nThe issue was fixed with https://github.com/py-pdf/pypdf/pull/1331\n\n### Workarounds\nIf you cannot update your version of `PyPDF2` (preferably to `pypdf>3.1.0` as PyPDF2 is deprecated), you should modify `PyPDF2/generic/_data_structures.py::read_object`.\n\nReplace:\n\n```python\n    else:\n        # number object OR indirect reference\n        peek = stream.read(20)\n        stream.seek(-len(peek), 1)  # reset to start\n        if IndirectPattern.match(peek) is not None:\n            return IndirectObject.read_from_stream(stream, pdf)\n        else:\n            return NumberObject.read_from_stream(stream)\n```\n\nby\n\n```python\n    elif tok in b\"0123456789+-.\":\n        # number object OR indirect reference\n        peek = stream.read(20)\n        stream.seek(-len(peek), 1)  # reset to start\n        if IndirectPattern.match(peek) is not None:\n            return IndirectObject.read_from_stream(stream, pdf)\n        else:\n            return NumberObject.read_from_stream(stream)\n    else:\n        raise PdfReadError(\n            f\"Invalid Elementary Object starting with {tok} @{stream.tell()}\"\n        )\n```\n\n### References\n* [pypdf issue #1329](https://github.com/py-pdf/pypdf/issues/1329)\n* [pypdf PR #1331](https://github.com/py-pdf/pypdf/pull/1331)","format":"markdown","source":"ghsa"}],"published":"2023-06-30T18:38:10.303Z","modified":"2026-11-02T16:06:04.477Z","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":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H","score":6.5,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","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"}],"cwes":["CWE-835"],"affected":[{"ranges":[{"version":"2.10.5","status":"affected"}],"vendor":"py-pdf","product":"pypdf","source":"cvelist"},{"ranges":[{"version":"2.10.5","status":"affected"}],"vendor":"pypdf_project","product":"pypdf","cpe":"cpe:2.3:a:pypdf_project:pypdf:2.10.5:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"2.10.5","status":"affected","fixed":"2.10.6"}],"ecosystem":"PyPI","package":"pypdf2","purl":"pkg:pypi/pypdf2","source":"ghsa"},{"ranges":[{"status":"affected","version":"2.10.5"}],"vendor":"py-pdf","product":"pypdf","cpe":"cpe:2.3:a:py-pdf:pypdf:2.10.5:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"2.10.5","status":"affected","fixed":"2.10.6"}],"ecosystem":"PyPI","package":"pypdf2","purl":"pkg:pypi/pypdf2","source":"pysec"}],"references":[{"url":"https://github.com/py-pdf/pypdf/security/advisories/GHSA-hm9v-vj3r-r55m","tags":["exploit","mitigation","patch","vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/py-pdf/pypdf/issues/1329","tags":["exploit","issue-tracking","vendor-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/py-pdf/pypdf/pull/1331","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-36807","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/py-pdf/pypdf/commit/e6531a25325e7e0174b6a1ba03b57320b5227f6b","tags":["fix","web"],"sources":["ghsa","pysec"]},{"url":"https://github.com/py-pdf/pypdf","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/pypdf2","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-hm9v-vj3r-r55m","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2024-11-06T19:51:03.876Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2023-36807","url":"https://www.cve.org/CVERecord?id=CVE-2023-36807","licence":"CVE Terms of Use","modified":"2024-11-06T19:51:43.120Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-hm9v-vj3r-r55m","url":"https://github.com/advisories/GHSA-hm9v-vj3r-r55m","licence":"CC-BY-4.0","modified":"2026-07-07T17:56:23.416Z"},{"source":"nvd","name":"NVD","id":"CVE-2023-36807","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-36807","licence":"Public domain","modified":"2026-11-02T16:06:04.477Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-1836","url":"https://osv.dev/vulnerability/PYSEC-2026-1836","licence":"CC-BY-4.0","modified":"2026-07-07T17:46:59.504Z"}],"updatedAt":"2026-11-25T22:58:25.343Z","epss":{"score":0.00573,"percentile":0.4872,"date":"2026-12-01T12:00:22.000Z"}}