CVE-2022-22707 Overview
CVE-2022-22707 is a stack-based buffer overflow vulnerability affecting lighttpd versions 1.4.46 through 1.4.63. The vulnerability exists in the mod_extforward_Forwarded function within the mod_extforward plugin, where improper handling of the Forwarded header can cause a 4-byte buffer overflow representing -1. This flaw can be exploited remotely to cause a denial of service through daemon crash, though it requires a non-default configuration that handles the Forwarded header in an unusual manner. Systems running 32-bit architectures are significantly more susceptible to exploitation than 64-bit systems.
Critical Impact
Remote attackers can crash the lighttpd daemon causing service disruption on affected web servers with non-default mod_extforward configurations, particularly on 32-bit systems.
Affected Products
- lighttpd versions 1.4.46 through 1.4.63
- Debian Linux 10.0
- Debian Linux 11.0
Discovery Timeline
- 2022-01-06 - CVE CVE-2022-22707 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2022-22707
Vulnerability Analysis
This vulnerability is classified as CWE-787 (Out-of-bounds Write), specifically a stack-based buffer overflow condition. The flaw resides in the mod_extforward plugin, which is used to extract and trust client IP addresses from proxy headers like X-Forwarded-For and Forwarded. When processing specially crafted Forwarded headers, the mod_extforward_Forwarded function fails to properly validate input boundaries, resulting in a 4-byte stack buffer overflow.
The overflow writes the value -1 (0xFFFFFFFF in 32-bit representation) beyond the allocated stack buffer. On 32-bit systems, this overflow is more likely to corrupt adjacent stack memory in a meaningful way due to the smaller address space and memory layout, making exploitation for denial of service more reliable. On 64-bit systems, the impact is typically reduced due to larger stack frame sizes and different memory alignment.
The network-based attack vector allows remote exploitation without authentication, though the high attack complexity stems from the requirement for specific non-default server configurations to be vulnerable.
Root Cause
The root cause is improper bounds checking in the mod_extforward_Forwarded function when parsing Forwarded header values. The function allocates a fixed-size buffer on the stack and fails to validate that incoming data fits within the allocated space before writing. When an attacker supplies a malformed Forwarded header, the function writes beyond the buffer boundary, corrupting adjacent stack memory with a 4-byte value representing -1.
Attack Vector
The attack is conducted over the network by sending HTTP requests with specially crafted Forwarded headers to a lighttpd server running a vulnerable version with the mod_extforward plugin enabled and configured in a specific non-default manner. The attacker does not require authentication or user interaction to trigger the vulnerability.
The attack flow involves:
- Identifying a lighttpd server with mod_extforward enabled in a vulnerable configuration
- Crafting an HTTP request with a malformed Forwarded header designed to trigger the overflow
- Sending the request to the target server
- The overflow corrupts stack memory, causing the daemon to crash
For technical details on the vulnerability mechanism, refer to the Lighttpd Issue #3134 which contains the vendor's analysis and fix discussion.
Detection Methods for CVE-2022-22707
Indicators of Compromise
- Unexpected lighttpd daemon crashes or restarts without apparent cause
- Core dumps from lighttpd processes showing stack corruption
- Unusual HTTP requests with malformed or oversized Forwarded headers in access logs
- Repeated connection attempts from specific IPs followed by service unavailability
Detection Strategies
- Monitor lighttpd process stability and implement alerting on unexpected daemon crashes
- Analyze HTTP access logs for requests containing abnormally long or malformed Forwarded headers
- Deploy web application firewall rules to inspect and limit Forwarded header content
- Use intrusion detection systems configured to detect buffer overflow attack patterns in HTTP traffic
Monitoring Recommendations
- Configure log aggregation to capture and analyze lighttpd crash events across infrastructure
- Implement process monitoring to detect rapid restart cycles indicative of exploitation attempts
- Set up network traffic analysis to identify suspicious patterns targeting the Forwarded header
How to Mitigate CVE-2022-22707
Immediate Actions Required
- Upgrade lighttpd to version 1.4.64 or later which contains the fix for this vulnerability
- If immediate upgrade is not possible, disable the mod_extforward plugin if not required
- Review lighttpd configuration to determine if mod_extforward is configured to handle Forwarded headers
- Prioritize remediation on 32-bit systems as they are more susceptible to exploitation
Patch Information
The lighttpd development team has addressed this vulnerability in versions after 1.4.63. Users should upgrade to the latest stable release. Detailed patch information is available in the Lighttpd Issue #3134. Debian users can refer to DSA-5040 for distribution-specific patching guidance.
Workarounds
- Disable the mod_extforward plugin entirely if it is not essential for your deployment
- Remove or comment out Forwarded header handling from the mod_extforward configuration
- Deploy a reverse proxy or WAF in front of lighttpd to filter malicious Forwarded headers
- Restrict network access to the lighttpd server to trusted sources where possible
# Disable mod_extforward in lighttpd configuration
# Comment out or remove the following line in lighttpd.conf:
# server.modules += ( "mod_extforward" )
# Or remove Forwarded header handling specifically:
# extforward.headers = ("X-Forwarded-For")
# Remove "Forwarded" from the headers list if present
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

