BUG/MEDIUM: quic: Possible buffer overflow when building TLS records
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 7 Dec 2023 20:12:02 +0000 (21:12 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 8 Dec 2023 13:28:20 +0000 (14:28 +0100)
commita8ffac55a11293d94522fd0ffa0aff93e3d8b57f
tree8585e650620466541ba66afa76e30374c9c61fe9
parentf2ce92bc16c4abde7eb98a5abf8c9279770a9e82
BUG/MEDIUM: quic: Possible buffer overflow when building TLS records

This bug impacts only the OpenSSL QUIC compatibility module (USE_QUIC_OPENSSL_COMPAT).

This may happen only when the TLS stack has to be provided with more than 1024+1+5+16
bytes of CRYPTO data. In this case several TLS records have to be built in one
call to SSL_provide_quic_data(). A 5-bytes header is created at the head
of these records. This header is used as AAD to cipher the record. But
the length of this AAD was counted two times. One time here in
quic_tls_compat_create_record() (initialization):

 adlen = quic_tls_compat_create_header(qc, rec, ad, 0);

and a second time here in the same function after quic_tls_tls_seal() return:

     ret = aad_len + outlen;

This addition is useless. Note that this bug could be reproduced when haproxy has
to authenticate the client.

Thank you to @vifino for having reported this issue in GH #2381.

Must be backported to 2.8.

(cherry picked from commit c075e4f2fc9e662459f7ab0ce8e13b70c059334a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/quic_openssl_compat.c