Headline
CVE-2023-40175: Merge pull request from GHSA-68xg-gqqm-vgj8 · puma/puma@690155e
Puma is a Ruby/Rack web server built for parallelism. Prior to versions 6.3.1 and 5.6.7, puma exhibited incorrect behavior when parsing chunked transfer encoding bodies and zero-length Content-Length headers in a way that allowed HTTP request smuggling. Severity of this issue is highly dependent on the nature of the web site using puma is. This could be caused by either incorrect parsing of trailing fields in chunked transfer encoding bodies or by parsing of blank/zero-length Content-Length headers. Both issues have been addressed and this vulnerability has been fixed in versions 6.3.1 and 5.6.7. Users are advised to upgrade. There are no known workarounds for this vulnerability.
Expand Up
@@ -49,7 +49,8 @@ class Client # :nodoc:
# chunked body validation
CHUNK_SIZE_INVALID = /[^\h]/.freeze
CHUNK_VALID_ENDING = "\r\n".freeze
CHUNK_VALID_ENDING = Const::LINE_END
CHUNK_VALID_ENDING_SIZE = CHUNK_VALID_ENDING.bytesize
# Content-Length header value validation
CONTENT_LENGTH_VALUE_INVALID = /[^\d]/.freeze
Expand Down Expand Up
@@ -382,8 +383,8 @@ def setup_body
cl = @env[CONTENT_LENGTH]
if cl
# cannot contain characters that are not \d
if CONTENT_LENGTH_VALUE_INVALID.match? cl
# cannot contain characters that are not \d, or be empty
if CONTENT_LENGTH_VALUE_INVALID.match?(cl) || cl.empty?
raise HttpParserError, “Invalid Content-Length: #{cl.inspect}”
end
else
Expand Down Expand Up
@@ -544,7 +545,7 @@ def decode_chunk(chunk)
while !io.eof?
line = io.gets
if line.end_with?(“\r\n”)
if line.end_with?(CHUNK_VALID_ENDING)
# Puma doesn’t process chunk extensions, but should parse if they’re
# present, which is the reason for the semicolon regex
chunk_hex = line.strip[/\A[^;]+/]
Expand All
@@ -556,13 +557,19 @@ def decode_chunk(chunk)
@in_last_chunk = true
@body.rewind
rest = io.read
last_crlf_size = "\r\n".bytesize
if rest.bytesize < last_crlf_size
if rest.bytesize < CHUNK_VALID_ENDING_SIZE
@buffer = nil
@partial_part_left = last_crlf_size - rest.bytesize
@partial_part_left = CHUNK_VALID_ENDING_SIZE - rest.bytesize
return false
else
@buffer = rest[last_crlf_size…-1]
# if the next character is a CRLF, set buffer to everything after that CRLF
start_of_rest = if rest.start_with?(CHUNK_VALID_ENDING)
CHUNK_VALID_ENDING_SIZE
else # we have started a trailer section, which we do not support. skip it!
rest.index(CHUNK_VALID_ENDING*2) + CHUNK_VALID_ENDING_SIZE*2
end
@buffer = rest[start_of_rest…-1]
@buffer = nil if @buffer.empty?
set_ready
return true
Expand Down
Related news
Ubuntu Security Notice 6682-1 - ZeddYu Lu discovered that Puma incorrectly handled parsing certain headers. A remote attacker could possibly use this issue to perform an HTTP Request Smuggling attack. This issue only affected Ubuntu 20.04 LTS. It was discovered that Puma incorrectly handled parsing certain headers. A remote attacker could possibly use this issue to perform an HTTP Request Smuggling attack. This issue only affected Ubuntu 20.04 LTS.
Red Hat Security Advisory 2024-0797-03 - Updated Satellite 6.14 packages that fixes Important security bugs and several regular bugs are now available for Red Hat Satellite. Issues addressed include HTTP request smuggling, buffer overflow, denial of service, and memory leak vulnerabilities.
Ubuntu Security Notice 6399-1 - It was discovered that Puma incorrectly handled parsing certain headers. A remote attacker could possibly use this issue to perform an HTTP request Smuggling attack.
### Impact Prior to version 6.3.1, puma exhibited incorrect behavior when parsing chunked transfer encoding bodies and zero-length Content-Length headers in a way that allowed HTTP request smuggling. The following vulnerabilities are addressed by this advisory: * Incorrect parsing of trailing fields in chunked transfer encoding bodies * Parsing of blank/zero-length Content-Length headers ### Patches The vulnerability has been fixed in 6.3.1 and 5.6.7. ### Workarounds No known workarounds. ### References [HTTP Request Smuggling](https://portswigger.net/web-security/request-smuggling) ### For more information If you have any questions or comments about this advisory: Open an issue in [Puma](https://github.com/puma/puma) See our [security policy](https://github.com/puma/puma/security/policy)