# CVE-2021-21294: Unbounded connection acceptance in http4s-blaze-server

> Attackers can cause denial of service by exhausting OS resources through unbounded connection acceptance in the http4s-blaze-server library.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/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:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 2 Feb 2021
- **Updated:** 3 Aug 2024
- **Also known as:** GHSA-xhv5-w9c5-2r2w

## What is CVE-2021-21294?

CVE-2021-21294 is a high-severity denial of service vulnerability in http4s, published on 2 Feb 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Http4s (http4s-blaze-server) is a minimal, idiomatic Scala interface for HTTP services. Http4s before versions 0.21.17, 0.22.0-M2, and 1.0.0-M14 have a vulnerability which can lead to a denial-of-service. Blaze-core, a library underlying http4s-blaze-server, accepts connections unboundedly on its selector pool. This has the net effect of amplifying degradation in services that are unable to handle their current request load, since incoming connections are still accepted and added to an unbounded queue. Each connection allocates a socket handle, which drains a scarce OS resource. This can also confound higher level circuit breakers which work based on detecting failed connections. http4s provides a general "MaxActiveRequests" middleware mechanism for limiting open connections, but it is enforced inside the Blaze accept loop, after the connection is accepted and the socket opened. Thus, the limit only prevents the number of connections which can be simultaneously processed, not the number of connections which can be held open. In 0.21.17, 0.22.0-M2, and 1.0.0-M14, a new "maxConnections" property, with a default value of 1024, has been added to the `BlazeServerBuilder`. Setting the value to a negative number restores unbounded behavior, but is strongly disrecommended. The NIO2 backend does not respect `maxConnections`. Its use is now deprecated in http4s-0.21, and the option is removed altogether starting in http4s-0.22. There are several possible workarounds described in the refrenced GitHub Advisory GHSA-xhv5-w9c5-2r2w.

Weakness: CWE-770 (Allocation of Resources Without Limits or Throttling), CWE-400 (Uncontrolled Resource Consumption)

## Which versions are affected by CVE-2021-21294?

4 open source packages ship an affected version, including org.http4s:http4s-blaze-server_2.12 and org.http4s:http4s-blaze-server_2.13. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.http4s:http4s-blaze-server_2.12` | Maven | All versions | 0.21.17 |
| `org.http4s:http4s-blaze-server_2.12` | Maven | All versions | 0.21.17 |
| `org.http4s:http4s-blaze-server_2.13` | Maven | All versions | 0.21.17 |
| `org.http4s:http4s-blaze-server_2.13` | Maven | All versions | 0.21.17 |

Products: Typelevel Http4s.

## How do I fix CVE-2021-21294?

Upgrade org.http4s:http4s-blaze-server_2.12 to 0.21.17 or later.

## Is CVE-2021-21294 being exploited?

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

## Other vulnerabilities in http4s

- [CVE-2021-39185](https://insights.sbomify.com/CVE-2021-39185/): Default CORS config allows any origin with credentials (critical 9.1)
- [CVE-2021-41084](https://insights.sbomify.com/CVE-2021-41084/): Response Splitting from unsanitized headers in http4s (high 8.7)
- [CVE-2020-5280](https://insights.sbomify.com/CVE-2020-5280/): Local file inclusion vulnerability in http4s (high 7.6)
- [CVE-2023-22465](https://insights.sbomify.com/CVE-2023-22465/): Http4s has fatal error parsing User-Agent and Server headers (high 7.5)
- [CVE-2025-59822](https://insights.sbomify.com/CVE-2025-59822/): Http4s vulnerable to HTTP Request Smuggling due to improper handling of HTTP trailer section (medium 6.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-21294 and fix it if it is affected.

What it is: CVE-2021-21294 is a high-severity denial of service vulnerability in http4s, published on 2 Feb 2021. 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-2021-21294 in the wild and no public exploit code.

Affected packages and fixed versions:
- org.http4s:http4s-blaze-server_2.12 (Maven): affected all versions; fixed in 0.21.17
- org.http4s:http4s-blaze-server_2.12 (Maven): affected all versions; fixed in 0.21.17
- org.http4s:http4s-blaze-server_2.13 (Maven): affected all versions; fixed in 0.21.17
- org.http4s:http4s-blaze-server_2.13 (Maven): affected all versions; fixed in 0.21.17

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

## Sources

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

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