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.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
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.
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 | 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 include Typelevel Http4s.
How do I fix CVE-2021-21294?
Upgrade org.http4s:http4s-blaze-server_2.12 to 0.21.17 or later.
Upgrade, then put limits on request size, rate and nesting depth so one client cannot exhaust the service. More about Denial of service.
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 Default CORS config allows any origin with credentials
- CVE-2021-41084 Response Splitting from unsanitized headers in http4s
- CVE-2020-5280 Local file inclusion vulnerability in http4s
- CVE-2023-22465 Http4s has fatal error parsing User-Agent and Server headers
- CVE-2025-59822 Http4s vulnerable to HTTP Request Smuggling due to improper handling of HTTP trailer section
Sources
Also known as GHSA-xhv5-w9c5-2r2w.