CVE-2021-40346

7.5 HIGH

📋 TL;DR

CVE-2021-40346 is an integer overflow vulnerability in HAProxy's HTTP header processing that enables HTTP request smuggling attacks. This allows attackers to bypass HAProxy's security ACLs (access control lists) and potentially smuggle malicious requests to backend servers. Organizations using HAProxy 2.0 through 2.5 as a reverse proxy or load balancer are affected.

💻 Affected Systems

Products:
  • HAProxy
Versions: 2.0 through 2.5
Operating Systems: All platforms running HAProxy
Default Config Vulnerable: ⚠️ Yes
Notes: Any configuration using HTTP processing with HTX enabled (default in affected versions) is vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers bypass all HAProxy security controls, smuggle malicious HTTP requests to backend servers, potentially leading to data theft, privilege escalation, or backend compromise.

🟠

Likely Case

HTTP request smuggling that bypasses HAProxy ACLs, allowing unauthorized access to protected resources or manipulation of backend application behavior.

🟢

If Mitigated

Limited impact if backend applications have their own robust security controls and input validation, though HAProxy's security layer is compromised.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: MEDIUM

Exploitation requires sending specially crafted HTTP requests; public proof-of-concept exists in security advisories.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 2.0.24, 2.2.17, 2.3.14, 2.4.4, 2.5.0

Vendor Advisory: https://git.haproxy.org/?p=haproxy.git

Restart Required: Yes

Instructions:

1. Download patched version from haproxy.org. 2. Stop HAProxy service. 3. Install new version. 4. Restart HAProxy service. 5. Verify version and functionality.

🔧 Temporary Workarounds

Disable HTX mode

all

Switch from HTX to legacy HTTP mode which is not affected by this vulnerability

Add 'no option http-use-htx' to global section of haproxy.cfg

🧯 If You Can't Patch

  • Implement WAF (Web Application Firewall) in front of HAProxy to detect and block HTTP smuggling attempts
  • Strengthen backend application security controls and input validation to mitigate impact of smuggled requests

🔍 How to Verify

Check if Vulnerable:

Check HAProxy version: if between 2.0 and 2.5 inclusive, and not patched to fixed versions, system is vulnerable.

Check Version:

haproxy -v

Verify Fix Applied:

Verify HAProxy version matches patched versions (2.0.24, 2.2.17, 2.3.14, 2.4.4, or 2.5.0+) and test HTTP request processing.

📡 Detection & Monitoring

Log Indicators:

  • Unusual HTTP request patterns, malformed headers, ACL bypass attempts in HAProxy logs

Network Indicators:

  • HTTP requests with abnormal header sizes or structures that could trigger integer overflow

SIEM Query:

Search for HAProxy logs containing 'htx_add_header' errors or abnormal HTTP status codes from backend mismatches

🔗 References

📤 Share & Export