You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
The llhttp parser in the http module in Node.js (v20.3.0) does not adhere to key-points in RFC 7230 in handling HTTP requests with both Transfer-Encoding and Content-Length headers.
Description:
RFC 7230 states the following:
Section 3.3.1 - A server that receives a request message with a transfer coding it does not understand SHOULD respond with 501 (Not Implemented).
Section 3.3.3 (3) - If a message is received with both a Transfer-Encoding and a Content-Length header field, the Transfer-Encoding overrides the Content-Length. Such a message might indicate an attempt to perform request smuggling (Section 9.5) or response splitting (Section 9.4) and ought to be handled as an error.
Section 3.3.3 (3) - If a Transfer-Encoding header field is present in a request and the chunked transfer coding is not the final encoding, the message body length cannot be determined reliably; the server MUST respond with the 400 (Bad Request) status code and then close the connection.
HTTP/1.1 200 OK
Date: Sun, 18 Jun 2023 10:38:11 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 32
Body length: 10 Body: 2
AA
0
These indicate:
Server silently ignored invalid blank Transfer-Encoding values.
Content-Length header was given priority even when a Transfer-Encoding header was present.
The request was processed even when chunked was not the final encoding.
Connection is keep-alive
These clearly break the excerpted points from RFC 7230 stated above.
Response from Go Lang net/http for the same HTTP Request.
HTTP/1.1 501 Not Implemented
Content-Type: text/plain; charset=utf-8
Connection: close
Unsupported transfer encoding
It's only an empty value in Transfer-Encoding that reproduces the issue (not clear in the original post). If there's any value there, then you get Content-Length can't be present with Transfer-Encoding as expected.
Probably not really a security issue, as no application is going to do something with an empty Transfer-Encoding value. It'll either use Content-Length and see the same message, or it'll reject the message (which llhttp should probably do as well).
Summary:
The
llhttp
parser in the http module in Node.js (v20.3.0) does not adhere to key-points in RFC 7230 in handling HTTP requests with bothTransfer-Encoding
andContent-Length
headers.Description:
RFC 7230 states the following:
Steps To Reproduce:
Server:
Request
Consider the following HTTP request:
Response
The following is the stdout generated:
The following is the HTTP Response generated:
These indicate:
Transfer-Encoding
values.Content-Length
header was given priority even when aTransfer-Encoding
header was present.chunked
was not the final encoding.Connection
iskeep-alive
These clearly break the excerpted points from RFC 7230 stated above.
Response from Go Lang
net/http
for the same HTTP Request.Supporting Material/References:
The text was updated successfully, but these errors were encountered: