Potential HTTP Request Smuggling in ruby webrick
WEBrick's request body reader decides whether a request is chunked by matching the Transfer-Encoding header against a loose regular expression rather than an exact value. An attacker could send a malformed Transfer-Encoding value that still matches, letting the server and an upstream proxy disagree about where one request ends and the next begins, enabling request smuggling.
- Triaged in 3 days
- Fixed in 37 days
- Paid in 37 days
- Disclosed after 2 months
function read_body in file /lib/webrick/httprequest.rb use expression /chunked/io to decide transfer-encoding whether or not.
that is not rigorous. When using webrick as a http server, a attacker may use a Transfer-Encoding: AAAchunkedBBB header to fake a legal header. than can make a HTTP Request Smuggling attack.
def read_body(socket, block)
return unless socket
if tc = self['transfer-encoding']
case tc
when /chunked/io then read_chunked(socket, block)
else raise HTTPStatus::NotImplemented, "Transfer-Encoding: #{tc}."
end
elsif self['content-length'] || @remaining_size
@remaining_size ||= self['content-length'].to_i
while @remaining_size > 0
sz = [@buffer_size, @remaining_size].min
break unless buf = read_data(socket, sz)
@remaining_size -= buf.bytesize
block.call(buf)
end
if @remaining_size > 0 && @socket.eof?
raise HTTPStatus::BadRequest, "invalid body size."
end
elsif BODY_CONTAINABLE_METHODS.member?(@request_method)
raise HTTPStatus::LengthRequired
end
return @body
end
Impact
It is possible to smuggle the request and disrupt the user experience.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code tests the Transfer-Encoding header with a substring regular expression instead of requiring an exact, valid token, so malformed values are treated as chunked encoding.
Impact
An attacker could smuggle requests and disrupt other users' experience, though the report gives no demonstration and the effect depends on a front-end proxy being present.
What the attacker needed
Attacker can send crafted headers
The fix
The header should be parsed strictly so malformed values are not treated as chunked.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a web server sits behind a proxy, both must agree on where one HTTP request stops and the next starts. If they disagree, an attacker can hide a second request inside the first so the proxy forwards it as if it came from someone else. Here the server accepted a made-up Transfer-Encoding value as if it meant chunked encoding, which is the disagreement that makes smuggling possible.
What is Smuggling / CRLF?
A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.