BUG/MINOR: mux-h2: make sure to produce a log on invalid requests
authorWilly Tarreau <w@1wt.eu>
Thu, 19 Jan 2023 22:22:03 +0000 (23:22 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 19 Jan 2023 22:37:00 +0000 (23:37 +0100)
commitf43f36da5be06da0f08efdb496e36a0edb35206a
treecc9be6beb84c3244e75a8c973e65d0669e0749f3
parent9debe0fb2754c0c29203d50069389d2c55ca3fae
BUG/MINOR: mux-h2: make sure to produce a log on invalid requests

As reported by Dominik Froehlich in github issue #1968, some H2 request
parsing errors do not result in a log being emitted. This is annoying
for debugging because while an RST_STREAM is correctly emitted to the
client, there's no way without enabling traces to find it on the
haproxy side.

After some testing with various abnormal requests, a few places were
found where logs were missing and could be added. In this case, we
simply use sess_log() so some sample fetch functions might not be
available since the stream is not created. But at least there will
be a BADREQ in the logs. A good eaxmple of this consists in sending
forbidden headers or header syntax (e.g. presence of LF in value).
Some quick tests can be done this way:

- protocol error (LF in value):
  curl -iv --http2-prior-knowledge -H "$(printf 'a:b\na')" http://0:8001/

- too large header block after decoding:
  curl -v --http2-prior-knowledge -H "a:$(perl -e "print('a'x10000)")"  -H "a:$(perl -e "print('a'x10000)")"  http://localhost:8001/

This should be backported where needed, most likely 2.7 and 2.6 at
least for a start, and progressively to other versions.
src/mux_h2.c