CVE-2021-21294

7.5 HIGH

📋 TL;DR

CVE-2021-21294 is a denial-of-service vulnerability in http4s-blaze-server where the underlying blaze-core library accepts connections without bounds, allowing attackers to exhaust OS socket resources. This affects http4s services using blaze-server before patched versions, particularly those under high load or without connection limits.

💻 Affected Systems

Products:
  • http4s-blaze-server
  • blaze-core
Versions: http4s versions before 0.21.17, 0.22.0-M2, and 1.0.0-M14
Operating Systems: All operating systems running affected http4s versions
Default Config Vulnerable: ⚠️ Yes
Notes: NIO2 backend does not respect maxConnections and is deprecated in http4s-0.21, removed in http4s-0.22.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete service unavailability due to OS socket exhaustion, preventing legitimate connections and potentially affecting system stability.

🟠

Likely Case

Degraded service performance under connection flood attacks, with increased latency and failed requests as socket resources are consumed.

🟢

If Mitigated

Limited impact with proper connection limits, though still vulnerable to connection floods up to the configured maximum.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires only the ability to establish TCP connections to the vulnerable service.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: http4s 0.21.17, 0.22.0-M2, or 1.0.0-M14

Vendor Advisory: https://github.com/http4s/http4s/security/advisories/GHSA-xhv5-w9c5-2r2w

Restart Required: Yes

Instructions:

1. Update http4s dependency to patched version. 2. Configure maxConnections property in BlazeServerBuilder. 3. Restart the service.

🔧 Temporary Workarounds

Configure MaxActiveRequests Middleware

all

Limit simultaneous request processing, though this doesn't prevent socket allocation.

// Scala code: .withMaxActiveRequests(limit)

Use External Load Balancer

linux

Deploy reverse proxy or load balancer with connection limiting capabilities.

// Configure nginx: limit_conn_zone $binary_remote_addr zone=addr:10m;
// Configure nginx: limit_conn addr 100;

🧯 If You Can't Patch

  • Deploy network-level rate limiting or connection limiting using firewalls or load balancers.
  • Monitor socket usage and implement alerting for abnormal connection patterns.

🔍 How to Verify

Check if Vulnerable:

Check build.sbt or project dependencies for http4s-blaze-server version < 0.21.17, or check if maxConnections is not configured in BlazeServerBuilder.

Check Version:

sbt 'show http4s-blaze-server/version' or check build configuration files.

Verify Fix Applied:

Verify http4s version is >= 0.21.17 and maxConnections is set in configuration, then test with connection flood to ensure limits are enforced.

📡 Detection & Monitoring

Log Indicators:

  • High connection counts in server logs
  • Socket allocation errors
  • Increased connection timeouts

Network Indicators:

  • Abnormally high TCP connection rates to service port
  • SYN flood patterns

SIEM Query:

source="http4s-logs" AND ("connection refused" OR "too many open files")

🔗 References

📤 Share & Export