-
Notifications
You must be signed in to change notification settings - Fork 44
Description
When a gateway server receives a message with an invalid Content-Length field value and a valid Transfer-Encoding field value, what should it do?
My interpretation of the standard is that such messages must not be forwarded. From RFC 9110, section 8.6:
Likewise, a sender MUST NOT forward a message with a Content-Length header field value that does not match the ABNF above, with one exception: a recipient of a Content-Length header field value consisting of the same decimal value repeated as a comma-separated list (e.g, "Content-Length: 42, 42") MAY either reject the message as invalid or replace that invalid field value with a single instance of the decimal value, since this likely indicates that a duplicate was generated or combined by an upstream message processor.
However, others have argued that the standard also allows intermediaries to forward such messages, so long as the invalid Content-Length header is removed. See this Squid issue thread, this Go net/http issue thread, and this H2O issue thread to see those arguments. These arguments usually appeal to RFC 9112, section 6.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 11.2) or response splitting (Section 11.1) and ought to be handled as an error. An intermediary that chooses to forward the message MUST first remove the received Content-Length field and process the Transfer-Encoding (as described below) prior to forwarding the message downstream.
EDIT: This question has been answered clearly and effectively by @mnot. If you are going to respond to this thread, please do not respond to the content of this message alone.