BUG/MINOR: quic: Avoid crashing with unsupported cryptographic algos
authorFrédéric Lécaille <flecaille@haproxy.com>
Wed, 11 Oct 2023 07:28:36 +0000 (09:28 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Wed, 11 Oct 2023 09:52:22 +0000 (11:52 +0200)
commitbd83b6effb8a15c24509c462cc19e029d6db5893
tree8a6c48dc496d32794b25f155f3523b33998436a5
parentcc743b698f7a4a6d08c29e031c57c58f26e07fa0
BUG/MINOR: quic: Avoid crashing with unsupported cryptographic algos

This bug was detected when compiling haproxy against aws-lc TLS stack
during QUIC interop runner tests. Some algorithms could be negotiated by haproxy
through the TLS stack but not fully supported by haproxy QUIC implentation.
This leaded tls_aead() to return NULL (same thing for tls_md(), tls_hp()).
As these functions returned values were never checked, they could triggered
segfaults.

To fix this, one closes the connection as soon as possible with a
handshake_failure(40) TLS alert. Note that as the TLS stack successfully
negotiates an algorithm, it provides haproxy with CRYPTO data before entering
->set_encryption_secrets() callback. This is why this callback
(ha_set_encryption_secrets() on haproxy side) is modified to release all
the CRYPTO frames before triggering a CONNECTION_CLOSE with a TLS alert. This is
done calling qc_release_pktns_frms() for all the packet number spaces.
Modify some quic_tls_keys_hexdump to avoid crashes when the ->aead or ->hp EVP_CIPHER
are NULL.
Modify qc_release_pktns_frms() to do nothing if the packet number space passed
as parameter is not intialized.

This bug does not impact the QUIC TLS compatibily mode (USE_QUIC_OPENSSL_COMPAT).

Thank you to @ilia-shipitsin for having reported this issue in GH #2309.

Must be backported as far as 2.6.
include/haproxy/quic_tls.h
src/quic_ssl.c
src/quic_tls.c