]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
dtls_get_reassembled_message(): Fix potential use-after-realloc
authorTomas Mraz <tomas@openssl.org>
Mon, 1 Dec 2025 16:14:21 +0000 (17:14 +0100)
committerTomas Mraz <tomas@openssl.org>
Wed, 3 Dec 2025 14:28:43 +0000 (15:28 +0100)
Fortunately due to the initial size of the allocated
buffer and the limit for unfragmented DTLS record size
the use-after-realloc cannot be triggered.

But we fix the potentially problematic code anyway.

Reported Joshua Rogers. It was found with the ZeroPath security
tooling.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/29278)

ssl/statem/statem_dtls.c

index 78baeed90319d7b4e33fa8ea1dc9ea27702b06f3..b26ecf42ae231f17e69a1b413681c3b8933d9d4d 100644 (file)
@@ -946,7 +946,8 @@ static int dtls_get_reassembled_message(SSL_CONNECTION *s, int *errtype,
     }
 
     if (frag_len > 0) {
-        p += DTLS1_HM_HEADER_LENGTH;
+        /* dtls1_preprocess_fragment() above could reallocate init_buf */
+        p = (unsigned char *)s->init_buf->data + DTLS1_HM_HEADER_LENGTH;
 
         i = ssl->method->ssl_read_bytes(ssl, SSL3_RT_HANDSHAKE, NULL,
                                         &p[frag_off], frag_len, 0, &readbytes);