# CVE-2024-40642: Absent Input Validation in BinaryHttpParser in the netty incubator codec.bhttp

> Attackers can exploit missing input validation in the Netty binary HTTP parser to perform injection attacks, request smuggling, and SSRF.

- **Severity:** High 8.1 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/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:** 18 Jul 2024
- **Updated:** 2 Aug 2024
- **Also known as:** GHSA-q8f2-hxq5-cp4h

## What is CVE-2024-40642?

CVE-2024-40642 is a high-severity vulnerability in netty-incubator-codec-ohttp, published on 18 Jul 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

The netty incubator codec.bhttp is a java language binary http parser. In affected versions the `BinaryHttpParser` class does not properly validate input values thus giving attackers almost complete control over the HTTP requests constructed from the parsed output. Attackers can abuse several issues individually to perform various injection attacks including HTTP request smuggling, desync attacks, HTTP header injections, request queue poisoning, caching attacks and Server Side Request Forgery (SSRF). Attacker could also combine several issues to create well-formed messages for other text-based protocols which may result in attacks beyond the HTTP protocol. The BinaryHttpParser class implements the readRequestHead method which performs most of the relevant parsing of the received request. The data structure prefixes values with a variable length integer value. The parsing code below first gets the lengths of the values from the prefixed variable length integer. After it has all of the lengths and calculates all of the indices, the parser casts the applicable slices of the ByteBuf to String. Finally, it passes these values into a new `DefaultBinaryHttpRequest` object where no further parsing or validation occurs. Method is partially validated while other values are not validated at all. Software that relies on netty to apply input validation for binary HTTP data may be vulnerable to various injection and protocol based attacks. This issue has been addressed in version 0.0.13.Final. Users are advised to upgrade. There are no known workarounds for this vulnerability.

Weakness: CWE-20 (Improper Input Validation)

## Which versions are affected by CVE-2024-40642?

2 open source packages ship an affected version, including io.netty.incubator:netty-incubator-codec-bhttp. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `io.netty.incubator:netty-incubator-codec-bhttp` | Maven | All versions | 0.0.13.Final |
| `io.netty.incubator:netty-incubator-codec-bhttp` | Maven | All versions | 0.0.13.Final |

Products: Netty Netty-Incubator-Codec-Ohttp.

## How do I fix CVE-2024-40642?

Upgrade io.netty.incubator:netty-incubator-codec-bhttp to 0.0.13.Final or later.

## Is CVE-2024-40642 being exploited?

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

## Other vulnerabilities in netty-incubator-codec-ohttp

- [CVE-2026-41207](https://insights.sbomify.com/CVE-2026-41207/): netty-incubator-codec-ohttp's HPKEContext operations may produce empty byte[] on failures (medium 6.9)
- [CVE-2026-48040](https://insights.sbomify.com/CVE-2026-48040/): netty-incubator-codec-ohttp's Incorrect Native Pointer Derivation in Pooled Direct ByteBuf Fallback Leads to Out-of-Bounds Native Memory Access (medium 6.8)
- [CVE-2024-36121](https://insights.sbomify.com/CVE-2024-36121/): netty-incubator-codec-ohttp's BoringSSLAEADContext Repeats Nonces (medium 5.9)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-40642 and fix it if it is affected.

What it is: CVE-2024-40642 is a high-severity vulnerability in netty-incubator-codec-ohttp, published on 18 Jul 2024. 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-2024-40642 in the wild and no public exploit code.

Affected packages and fixed versions:
- io.netty.incubator:netty-incubator-codec-bhttp (Maven): affected all versions; fixed in 0.0.13.Final
- io.netty.incubator:netty-incubator-codec-bhttp (Maven): affected all versions; fixed in 0.0.13.Final

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

## Sources

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

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