CVE-2024-47220
Executive Summary
CVE-2024-47220 is an HTTP request smuggling vulnerability in the WEBrick HTTP server toolkit, which is bundled with Ruby. The flaw allows an attacker to bypass security controls and potentially access restricted resources by crafting a single HTTP request that is interpreted as two separate requests by the server. This is achieved by providing both a Content-Length and a Transfer-Encoding header, leading to a desynchronization between the front-end proxy (if any) and the WEBrick server. The vendor's position is that WEBrick should not be used in production, and no official patch has been released.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects the Ruby ecosystem, specifically the WEBrick library which is part of Ruby's standard library. Organizations using Ruby applications that rely on WEBrick in production are at risk. Since WEBrick is often used for development and testing, the supply chain risk is lower for production deployments, but any application inadvertently exposing WEBrick to untrusted networks is vulnerable.
CVSS Breakdown & Threat Level
- CVSS Score: 5.3 (Medium)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: None
- Scope: Unchanged
- Confidentiality Impact: Low
- Integrity Impact: Low
- Availability Impact: None
The threat level is medium due to the low complexity and network-based attack vector, but the impact is limited to potential access to restricted resources and minor data manipulation.
Deep Dive & Mechanics
The vulnerability exploits the HTTP request smuggling technique. When WEBrick receives a request with both Content-Length and Transfer-Encoding headers, it processes the request body based on one header while a downstream proxy might use the other. This desynchronization allows an attacker to "smuggle" a second request within the body of the first.
For example, an attacker sends a POST /user HTTP/1.1 request with a Content-Length header indicating a long body, and a Transfer-Encoding: chunked header. The body contains a complete GET /admin HTTP/1.1 request. WEBrick might interpret the entire body as part of the first request, while a proxy sees the chunked encoding and treats the embedded request as a separate, legitimate request to /admin.
This can lead to:
- Bypassing access controls (e.g., accessing
/adminwithout authentication). - Cache poisoning (if a proxy caches the smuggled response).
- Session hijacking in certain configurations.
Vulnerable vs. Patched Code
Vulnerable Code (WEBrick <= 1.8.1):
The vulnerable code is in the HTTP request parsing logic. The server does not properly handle the case where both Content-Length and Transfer-Encoding headers are present. It may process the body based on Content-Length while ignoring Transfer-Encoding, or vice versa, leading to smuggling.
# Simplified vulnerable logic
def parse_request
if headers['transfer-encoding']
# Process chunked encoding
elsif headers['content-length']
# Process fixed length
end
# No check for both headers present
end
Patched Code (Not available):
The vendor recommends not using WEBrick in production. A proper fix would involve rejecting requests that contain both headers, or strictly adhering to RFC 7230 which states that if both are present, Transfer-Encoding should take precedence and Content-Length should be ignored.
# Hypothetical patched logic
def parse_request
if headers['transfer-encoding'] && headers['content-length']
# Reject or ignore Content-Length per RFC 7230
headers.delete('content-length')
end
# Continue processing
end
Exploitation & Lab Setup
Red Team (Offensive)
Lab Setup:
- Install Ruby and WEBrick (default with Ruby).
- Create a simple WEBrick server with a protected
/adminendpoint. - Use a tool like
netcatorcurlto send a crafted request.
Exploit Example:
# Crafted request using netcat
printf "POST /user HTTP/1.1\r\nHost: target.com\r\nContent-Length: 56\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\nGET /admin HTTP/1.1\r\nHost: target.com\r\n\r\n" | nc target.com 8080
Explanation:
- The first request (
POST /user) has both headers. - The body contains a complete
GET /adminrequest. - WEBrick may process the body as part of the POST, while a proxy sees the chunked encoding and treats the embedded request as a separate request to
/admin.
Blue Team (Defensive)
Detection:
- Monitor for requests containing both
Content-LengthandTransfer-Encodingheaders. - Use WAF rules to block such requests.
- Log and alert on unusual request patterns.
Mitigation:
- Replace WEBrick with a production-ready server like Puma, Unicorn, or Passenger.
- If WEBrick must be used, place it behind a reverse proxy that normalizes headers (e.g., Nginx with
proxy_set_header). - Implement strict input validation and header sanitization.
Indicators of Compromise (IOCs)
Network IOCs:
- HTTP requests containing both
Content-LengthandTransfer-Encodingheaders. - Requests with unusual body content that includes complete HTTP requests.
- Multiple requests from the same source to different endpoints in quick succession.
- HTTP requests containing both
Log IOCs:
- WEBrick access logs showing requests with unexpected body lengths.
- Error logs indicating parsing issues or malformed requests.
File IOCs:
- No specific file-based IOCs.
Detection Engineering
YARA Rule
rule HTTP_Request_Smuggling_CVE_2024_47220 {
meta:
description = "Detects HTTP request smuggling attempts targeting WEBrick"
author = "Valters IT"
date = "2024-10-27"
reference = "CVE-2024-47220"
strings:
$content_length = "Content-Length:" nocase
$transfer_encoding = "Transfer-Encoding:" nocase
$http_request = /GET|POST|PUT|DELETE|HEAD|OPTIONS|PATCH/ nocase
condition:
all of ($content_length, $transfer_encoding) and #http_request > 1
}
Sigma Rule
title: HTTP Request Smuggling - CVE-2024-47220
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects HTTP requests with both Content-Length and Transfer-Encoding headers
author: Valters IT
date: 2024-10-27
logsource:
category: webserver
product: ruby
detection:
selection:
http.request.headers|contains:
- 'Content-Length:'
- 'Transfer-Encoding:'
condition: selection
falsepositives:
- Legitimate use of both headers in rare cases (e.g., HTTP/1.0 to HTTP/1.1 conversion)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-47220 HTTP Request Smuggling Attempt"; flow:to_server; content:"Content-Length:"; http_header; content:"Transfer-Encoding:"; http_header; classtype:attempted-recon; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate Action: Replace WEBrick with a production-ready HTTP server (e.g., Puma, Unicorn, Passenger).
- Short-term Mitigation: If WEBrick must be used, place it behind a reverse proxy (e.g., Nginx, Apache) that normalizes headers and rejects ambiguous requests.
- Long-term Fix: Monitor Ruby's official repository for a patch. Until then, follow the vendor's advice and avoid using WEBrick in production.
- Detection: Implement the provided YARA, Sigma, and Suricata rules to detect exploitation attempts.
- Monitoring: Enable detailed logging on WEBrick and any front-end proxies to identify suspicious request patterns.
Valters IT
DevSecOps & Cyber Threat Intelligence Expert