]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
psk: fix read buffer overrun in the "pre_shared_key" extension
authorAndrew Hamilton <adhamilt@gmail.com>
Mon, 7 Jul 2025 01:31:55 +0000 (10:31 +0900)
committerDaiki Ueno <ueno@gnu.org>
Mon, 7 Jul 2025 21:57:29 +0000 (06:57 +0900)
While processing the "pre_shared_key" extension in TLS 1.3, if there
are certain malformed data in the extension headers, then the code may
read uninitialized memory (2 bytes) beyond the received TLS extension
buffer. Spotted by oss-fuzz at:
https://issues.oss-fuzz.com/issues/42513990

Signed-off-by: Andrew Hamilton <adhamilt@gmail.com>
Signed-off-by: Daiki Ueno <ueno@gnu.org>
fuzz/gnutls_psk_client_fuzzer.repro/5477db1bb507a35e8833c758ce344f4b5b246d8e [new file with mode: 0644]
lib/ext/pre_shared_key.c

diff --git a/fuzz/gnutls_psk_client_fuzzer.repro/5477db1bb507a35e8833c758ce344f4b5b246d8e b/fuzz/gnutls_psk_client_fuzzer.repro/5477db1bb507a35e8833c758ce344f4b5b246d8e
new file mode 100644 (file)
index 0000000..009d44c
Binary files /dev/null and b/fuzz/gnutls_psk_client_fuzzer.repro/5477db1bb507a35e8833c758ce344f4b5b246d8e differ
index 51c4891d51075c58a9d2b8e316fa37cda5ee7993..2cb83e6707746fff36f5bcf8dd7152d8f0fa1893 100644 (file)
@@ -1170,6 +1170,8 @@ static int _gnutls_psk_recv_params(gnutls_session_t session,
 
        if (session->security_parameters.entity == GNUTLS_CLIENT) {
                if (session->internals.hsk_flags & HSK_PSK_KE_MODES_SENT) {
+                       DECR_LEN(len, 2);
+
                        uint16_t selected_identity = _gnutls_read_uint16(data);
 
                        for (i = 0; i < sizeof(session->key.binders) /