# CVE-2023-36807: Infinite Loop when reading malformed objects in pypdf

> An attacker can cause a denial of service via infinite loop by crafting a malformed PDF processed by the pypdf library.

- **Severity:** Medium 6.2 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 30 Jun 2023
- **Updated:** 6 Nov 2024
- **Also known as:** DEBIAN-CVE-2023-36807, GHSA-hm9v-vj3r-r55m, PYSEC-2026-1836

## What is CVE-2023-36807?

CVE-2023-36807 is a medium-severity denial of service vulnerability in Pypdf Project Pypdf, published on 30 Jun 2023. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

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.

Weakness: CWE-835 (Loop with Unreachable Exit Condition)

## Which versions are affected by CVE-2023-36807?

3 open source packages ship an affected version, including pypdf2 and PyPDF2. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `pypdf2` | PyPI | From 2.10.5 | 2.10.6 |
| `pypdf2` | PyPI | From 2.10.5 | 2.10.6 |
| `PyPDF2` | PyPI | From 2.10.5 | 2.10.6 |

Products: Pypdf Project Pypdf.

## How do I fix CVE-2023-36807?

Upgrade pypdf2 to 2.10.6 or later.

## Is CVE-2023-36807 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-36807 exists.

## Other vulnerabilities in Pypdf Project Pypdf

- [CVE-2026-102993](https://insights.sbomify.com/CVE-2026-102993/): pypdf: Possible large memory usage when retrieving Roman page labels (high 8.7)
- [CVE-2026-102994](https://insights.sbomify.com/CVE-2026-102994/): pypdf: Possible long runtimes/large memory usage when parsing indirect objects (high 8.7)
- [CVE-2026-102995](https://insights.sbomify.com/CVE-2026-102995/): pypdf: Possible large memory usage for large /ToUnicode streams (Follow-up 2) (high 8.7)
- [CVE-2026-102996](https://insights.sbomify.com/CVE-2026-102996/): pypdf: Possible large memory usage when parsing font data (high 8.7)
- [CVE-2026-102997](https://insights.sbomify.com/CVE-2026-102997/): pypdf: Possible long runtimes for partially malformed FlateDecode streams (Follow-up) (high 8.7)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-36807 and fix it if it is affected.

What it is: CVE-2023-36807 is a medium-severity denial of service vulnerability in Pypdf Project Pypdf, published on 30 Jun 2023. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-36807 exists.

Affected packages and fixed versions:
- pypdf2 (PyPI): affected from 2.10.5; fixed in 2.10.6
- pypdf2 (PyPI): affected from 2.10.5; fixed in 2.10.6
- PyPDF2 (PyPI): affected from 2.10.5; fixed in 2.10.6

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-36807/ (Markdown: https://insights.sbomify.com/CVE-2023-36807/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-36807
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-36807
- OSV: https://osv.dev/vulnerability/CVE-2023-36807

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-36807/
Summaries are generated and may contain mistakes; the official description above is the record.
