# CVE-2023-2512: Buffer under-read in workerd

> An integer overflow in workerd's FormData API can cause memory corruption and crashes when processing extremely large forms, requiring a runtime upgrade.

- **Severity:** Medium 6.5 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 12 May 2023
- **Updated:** 24 Jan 2025
- **Also known as:** GHSA-8vx6-69vg-c46f

## What is CVE-2023-2512?

CVE-2023-2512 is a medium-severity vulnerability in Cloudflare workerd, published on 12 May 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Prior to version v1.20230419.0, the FormData API implementation was subject to an integer overflow. If a FormData instance contained more than 2^31 elements, the forEach() method could end up reading from the wrong location in memory while iterating over elements. This would most likely lead to a segmentation fault, but could theoretically allow arbitrary undefined behavior.

In order for the bug to be exploitable, the process would need to be able to allocate 160GB of RAM. Due to this, the bug was never exploitable on the Cloudflare Workers platform, but could theoretically be exploitable on deployments of workerd running on machines with a huge amount of memory. Moreover, in order to be remotely exploited, an attacker would have to upload a single form-encoded HTTP request of at least tens of gigabytes in size. The application code would then have to use request.formData() to parse the request and formData.forEach() to iterate over this data. Due to these limitations, the exploitation likelihood was considered Low.

A fix that addresses this vulnerability has been released in version v1.20230419.0 and users are encouraged to update to the latest version available.

Weakness: CWE-190 (Integer Overflow or Wraparound), CWE-125 (Out-of-bounds Read)

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

2 open source packages ship an affected version, including workerd. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `workerd` | npm | All versions | 1.20230419.0 |
| `workerd` | npm | All versions | 1.20230419.0 |

Products: Cloudflare Workerd.

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

Upgrade workerd to 1.20230419.0 or later.

## Is CVE-2023-2512 being exploited?

There is no known exploitation of CVE-2023-2512 in the wild and no public exploit code.

## Fix prompt for AI coding agents

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

What it is: CVE-2023-2512 is a medium-severity vulnerability in Cloudflare workerd, published on 12 May 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2023-2512 in the wild and no public exploit code.

Affected packages and fixed versions:
- workerd (npm): affected all versions; fixed in 1.20230419.0
- workerd (npm): affected all versions; fixed in 1.20230419.0

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-2512/ (Markdown: https://insights.sbomify.com/CVE-2023-2512/index.md)
```

## Sources

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

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