haproxy/reg-tests/http-messaging
Willy Tarreau 6492f1f29d BUG/MAJOR: http: reject any empty content-length header value
The content-length header parser has its dedicated function, in order
to take extreme care about invalid, unparsable, or conflicting values.
But there's a corner case in it, by which it stops comparing values
when reaching the end of the header. This has for a side effect that
an empty value or a value that ends with a comma does not deserve
further analysis, and it acts as if the header was absent.

While this is not necessarily a problem for the value ending with a
comma as it will be cause a header folding and will disappear, it is a
problem for the first isolated empty header because this one will not
be recontructed when next ones are seen, and will be passed as-is to the
backend server. A vulnerable HTTP/1 server hosted behind haproxy that
would just use this first value as "0" and ignore the valid one would
then not be protected by haproxy and could be attacked this way, taking
the payload for an extra request.

In field the risk depends on the server. Most commonly used servers
already have safe content-length parsers, but users relying on haproxy
to protect a known-vulnerable server might be at risk (and the risk of
a bug even in a reputable server should never be dismissed).

A configuration-based work-around consists in adding the following rule
in the frontend, to explicitly reject requests featuring an empty
content-length header that would have not be folded into an existing
one:

    http-request deny if { hdr_len(content-length) 0 }

The real fix consists in adjusting the parser so that it always expects a
value at the beginning of the header or after a comma. It will now reject
requests and responses having empty values anywhere in the C-L header.

This needs to be backported to all supported versions. Note that the
modification was made to functions h1_parse_cont_len_header() and
http_parse_cont_len_header(). Prior to 2.8 the latter was in
h2_parse_cont_len_header(). One day the two should be refused but the
former is also used by Lua.

The HTTP messaging reg-tests were completed to test these cases.

Thanks to Ben Kallus of Dartmouth College and Narf Industries for
reporting this! (this is in GH #2237).
2023-08-09 09:27:38 +02:00
..
common.pem
h1_host_normalization.vtc REGTESTS: h1_host_normalization : Add a barrier to not mix up log messages 2023-06-20 12:49:39 +02:00
h1_to_h1.vtc BUG/MAJOR: http: reject any empty content-length header value 2023-08-09 09:27:38 +02:00
h2_desync_attacks.vtc
h2_to_h1.vtc BUG/MAJOR: http: reject any empty content-length header value 2023-08-09 09:27:38 +02:00
http_abortonclose.vtc REGTESTS: http_abortonclose: Extend supported versions 2022-06-07 08:21:54 +02:00
http_bodyless_response.vtc REGTESTS: http: Create a dedicated script to test spliced bodyless responses 2023-08-04 15:02:19 +02:00
http_bodyless_spliced_response.vtc REGTESTS: Test SPLICE feature is enabled to execute script about splicing 2023-08-04 15:08:06 +02:00
http_msg_full_on_eom.vtc REGTESTS: extend the default I/O timeouts and make them overridable 2021-11-18 17:57:11 +01:00
http_request_buffer.vtc MAJOR: http-ana: Review error handling during HTTP payload forwarding 2023-01-13 11:18:23 +01:00
http_splicing_chunk.vtc REGTESTS: Test SPLICE feature is enabled to execute script about splicing 2023-08-04 15:08:06 +02:00
http_splicing.vtc REGTESTS: Test SPLICE feature is enabled to execute script about splicing 2023-08-04 15:08:06 +02:00
http_transfer_encoding.vtc REGTESTS: extend the default I/O timeouts and make them overridable 2021-11-18 17:57:11 +01:00
http_wait_for_body.vtc REGTESTS: extend the default I/O timeouts and make them overridable 2021-11-18 17:57:11 +01:00
protocol_upgrade.vtc REGTESTS: extend the default I/O timeouts and make them overridable 2021-11-18 17:57:11 +01:00
scheme_based_normalize.vtc REGTESTS: extend the default I/O timeouts and make them overridable 2021-11-18 17:57:11 +01:00
srv_ws.vtc REGTESTS: extend the default I/O timeouts and make them overridable 2021-11-18 17:57:11 +01:00
websocket.vtc BUG/MEDIUM: http-ana: Properly switch the request in tunnel mode on upgrade 2023-04-17 16:17:35 +02:00