@@ -0,0 +1,316 @@
+From 3094861849fb2efecebfe9bf92252e5ead73e531 Mon Sep 17 00:00:00 2001
+From: Pavol Zacik <pzacik@redhat.com>
+Date: Mon, 9 Nov 2026 15:42:33 +0100
+Subject: [PATCH] tls1_enc: Do not report a fatal error on undersized AEAD
+ records
+
+This is a simplified backport of upstream commit 04728a2.
+
+In tls1_enc(), the receive path invokes EVP_CTRL_AEAD_TLS1_AAD and
+raises SSL_AD_INTERNAL_ERROR if it fails. This would cause a DoS
+vulnerability where the attacker can terminate a DTLS 1.2 association
+with a single unauthenticated datagram whose encrypted fragment
+is shorther than the AEAD overhead.
+
+Do not raise an internal error on the receive path. Instead, make the
+caller handle the record as a publicly invalid one (DTLS discards it).
+
+Fixes CVE-2026-75806.
+---
+ ssl/record/ssl3_record.c | 12 +++
+ test/build.info | 2 +-
+ test/recordlentest.c | 221 +++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 234 insertions(+), 1 deletion(-)
+
+diff --git a/ssl/record/ssl3_record.c b/ssl/record/ssl3_record.c
+index ab5d22aa10..b1f813ef4f 100644
+--- a/ssl/record/ssl3_record.c
++++ b/ssl/record/ssl3_record.c
+@@ -1062,6 +1062,18 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int sending)
+ pad = EVP_CIPHER_CTX_ctrl(ds, EVP_CTRL_AEAD_TLS1_AAD,
+ EVP_AEAD_TLS1_AAD_LEN, buf[ctr]);
+ if (pad <= 0) {
++ /*
++ * On the receive path the AEAD ciphers only reject the
++ * AAD if the record is too short to even contain the
++ * mandatory AEAD overhead, i.e. the explicit IV and the
++ * authentication tag. Such a record is publicly invalid,
++ * so do not raise an internal error alert here. Returning
++ * 0 leaves alert handling to the caller, which means TLS
++ * reports bad_record_mac and DTLS silently discards the
++ * record.
++ */
++ if (!sending)
++ return 0;
+ SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_ENC,
+ ERR_R_INTERNAL_ERROR);
+ return -1;
+diff --git a/test/build.info b/test/build.info
+index 9e2136ad34..71e0271602 100644
+--- a/test/build.info
++++ b/test/build.info
+@@ -347,7 +347,7 @@ INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN
+ DEPEND[x509_time_test]=../libcrypto libtestutil.a
+
+ SOURCE[recordlentest]=recordlentest.c ssltestlib.c
+- INCLUDE[recordlentest]=../include
++ INCLUDE[recordlentest]=../include ..
+ DEPEND[recordlentest]=../libcrypto ../libssl libtestutil.a
+
+ SOURCE[drbgtest]=drbgtest.c
+diff --git a/test/recordlentest.c b/test/recordlentest.c
+index 457335d308..fe0a38e8b9 100644
+--- a/test/recordlentest.c
++++ b/test/recordlentest.c
+@@ -9,6 +9,9 @@
+
+ #include <string.h>
+
++#include <openssl/evp.h>
++
++#include "internal/nelem.h"
+ #include "ssltestlib.h"
+ #include "testutil.h"
+
+@@ -60,6 +63,35 @@ static int write_record(BIO *b, size_t len, int rectype, int recversion)
+ return 1;
+ }
+
++#ifndef OPENSSL_NO_DTLS1_2
++static int write_dtls_record(BIO *b, size_t len, int rectype, int recversion,
++ unsigned int epoch, unsigned long seq)
++{
++ unsigned char record[DTLS1_RT_HEADER_LENGTH + 256];
++ size_t written, i;
++
++ if (len > sizeof(record) - DTLS1_RT_HEADER_LENGTH)
++ return 0;
++
++ memset(record, 0, sizeof(record));
++
++ record[0] = rectype;
++ record[1] = (recversion >> 8) & 0xff;
++ record[2] = recversion & 0xff;
++ record[3] = (epoch >> 8) & 0xff;
++ record[4] = epoch & 0xff;
++ for (i = 0; i < 6; i++) {
++ record[10 - i] = (unsigned char)(seq & 0xff);
++ seq >>= 8;
++ }
++ record[11] = (len >> 8) & 0xff;
++ record[12] = len & 0xff;
++
++ return BIO_write_ex(b, record, DTLS1_RT_HEADER_LENGTH + len, &written)
++ && written == DTLS1_RT_HEADER_LENGTH + len;
++}
++#endif
++
+ static int fail_due_to_record_overflow(int enc)
+ {
+ long err = ERR_peek_error();
+@@ -181,6 +213,188 @@ static int test_record_overflow(int idx)
+ return testresult;
+ }
+
++static int write_and_read_app_data(SSL *serverssl, SSL *clientssl)
++{
++ static const unsigned char msg = 0xa5;
++ unsigned char buf = 0;
++ size_t readbytes = 0, written = 0;
++
++ return TEST_true(SSL_write_ex(clientssl, &msg, sizeof(msg), &written))
++ && TEST_size_t_eq(written, sizeof(msg))
++ && TEST_true(SSL_read_ex(serverssl, &buf, sizeof(buf), &readbytes))
++ && TEST_size_t_eq(readbytes, sizeof(msg))
++ && TEST_uchar_eq(buf, msg);
++}
++
++typedef enum {
++ SHORT_AEAD_RECORD_AES,
++ SHORT_AEAD_RECORD_ARIA,
++ SHORT_AEAD_RECORD_CHACHA
++} SHORT_AEAD_RECORD_CIPHER;
++
++typedef struct {
++ const char *cipher;
++ size_t record_len;
++ SHORT_AEAD_RECORD_CIPHER cipher_type;
++} SHORT_AEAD_RECORD_TEST;
++
++#ifndef OPENSSL_NO_TLS1_2
++static const SHORT_AEAD_RECORD_TEST short_aead_record_tests[] = {
++ { TLS1_TXT_RSA_WITH_AES_128_CCM, 0, SHORT_AEAD_RECORD_AES },
++ { TLS1_TXT_RSA_WITH_AES_128_CCM,
++ EVP_CCM_TLS_EXPLICIT_IV_LEN + EVP_CCM_TLS_TAG_LEN - 1,
++ SHORT_AEAD_RECORD_AES },
++ { TLS1_TXT_RSA_WITH_AES_128_CCM_8,
++ EVP_CCM_TLS_EXPLICIT_IV_LEN + EVP_CCM8_TLS_TAG_LEN - 1,
++ SHORT_AEAD_RECORD_AES },
++ { TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256,
++ EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN - 1,
++ SHORT_AEAD_RECORD_AES },
++ { TLS1_TXT_RSA_WITH_ARIA_128_GCM_SHA256,
++ EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN - 1,
++ SHORT_AEAD_RECORD_ARIA },
++ { TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305,
++ EVP_CHACHAPOLY_TLS_TAG_LEN - 1, SHORT_AEAD_RECORD_CHACHA },
++};
++#endif
++
++static void alert_cb(int write_p, int version, int content_type,
++ const void *buf, size_t len, SSL *ssl, void *arg)
++{
++ unsigned char *alert = arg;
++ const unsigned char *alert_data = buf;
++
++ if (write_p && content_type == SSL3_RT_ALERT && len == 2) {
++ alert[0] = alert_data[0];
++ alert[1] = alert_data[1];
++ }
++}
++
++#ifndef OPENSSL_NO_TLS1_2
++static int test_tls12_short_aead_record(int idx)
++{
++ const SHORT_AEAD_RECORD_TEST *test = &short_aead_record_tests[idx];
++ SSL_CTX *cctx = NULL, *sctx = NULL;
++ SSL *clientssl = NULL, *serverssl = NULL;
++ int testresult = 0;
++ size_t readbytes;
++ unsigned char buf, alert[2] = { 0 };
++
++# ifdef OPENSSL_NO_ARIA
++ if (test->cipher_type == SHORT_AEAD_RECORD_ARIA) {
++ TEST_info("ARIA is disabled");
++ return 1;
++ }
++# endif
++# if defined(OPENSSL_NO_CHACHA) || defined(OPENSSL_NO_POLY1305) \
++ || defined(OPENSSL_NO_EC)
++ if (test->cipher_type == SHORT_AEAD_RECORD_CHACHA) {
++ TEST_info("ChaCha20-Poly1305 or EC is disabled");
++ return 1;
++ }
++# endif
++
++ if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(),
++ TLS_client_method(),
++ TLS1_2_VERSION, TLS1_2_VERSION,
++ &sctx, &cctx, cert, privkey)))
++ goto end;
++
++ /* CCM-8 is not available at the default security level. */
++ SSL_CTX_set_security_level(sctx, 0);
++ SSL_CTX_set_security_level(cctx, 0);
++
++ if (!TEST_true(SSL_CTX_set_cipher_list(sctx, test->cipher))
++ || !TEST_true(SSL_CTX_set_cipher_list(cctx, test->cipher))
++ || !TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
++ &clientssl, NULL, NULL)))
++ goto end;
++
++ SSL_set_msg_callback(serverssl, alert_cb);
++ SSL_set_msg_callback_arg(serverssl, &alert);
++
++ if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))
++ || !TEST_true(write_and_read_app_data(serverssl, clientssl))
++ || !TEST_true(write_record(SSL_get_rbio(serverssl),
++ test->record_len,
++ SSL3_RT_APPLICATION_DATA,
++ TLS1_2_VERSION))
++ || !TEST_false(SSL_read_ex(serverssl, &buf, sizeof(buf),
++ &readbytes))
++ || !TEST_uchar_eq(alert[0], SSL3_AL_FATAL)
++ || !TEST_uchar_eq(alert[1], SSL_AD_BAD_RECORD_MAC))
++ goto end;
++
++ testresult = 1;
++ end:
++ SSL_free(serverssl);
++ SSL_free(clientssl);
++ SSL_CTX_free(sctx);
++ SSL_CTX_free(cctx);
++ return testresult;
++}
++#endif
++
++#ifndef OPENSSL_NO_DTLS1_2
++static int test_dtls12_short_aead_record(void)
++{
++ SSL_CTX *cctx = NULL, *sctx = NULL;
++ SSL *clientssl = NULL, *serverssl = NULL;
++ int testresult = 0, ret;
++ size_t readbytes = 0;
++ unsigned char buf = 0, alert[2] = { 0 };
++
++ if (!TEST_true(create_ssl_ctx_pair(DTLS_server_method(),
++ DTLS_client_method(),
++ DTLS1_2_VERSION, DTLS1_2_VERSION,
++ &sctx, &cctx, cert, privkey)))
++ goto end;
++
++ SSL_CTX_set_security_level(sctx, 0);
++ SSL_CTX_set_security_level(cctx, 0);
++
++ if (!TEST_true(SSL_CTX_set_cipher_list(sctx,
++ TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256))
++ || !TEST_true(SSL_CTX_set_cipher_list(cctx,
++ TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256))
++ || !TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
++ &clientssl, NULL, NULL)))
++ goto end;
++
++ SSL_set_msg_callback(serverssl, alert_cb);
++ SSL_set_msg_callback_arg(serverssl, &alert);
++
++ /*
++ * The forged record uses the first application-data sequence number. A
++ * valid client write after this must still be accepted.
++ */
++ if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))
++ || !TEST_true(write_dtls_record(SSL_get_rbio(serverssl),
++ EVP_GCM_TLS_EXPLICIT_IV_LEN
++ + EVP_GCM_TLS_TAG_LEN - 1,
++ SSL3_RT_APPLICATION_DATA, DTLS1_2_VERSION,
++ 1, 1)))
++ goto end;
++
++ ERR_clear_error();
++ ret = SSL_read_ex(serverssl, &buf, sizeof(buf), &readbytes);
++ if (!TEST_false(ret)
++ || !TEST_int_eq(SSL_get_error(serverssl, ret), SSL_ERROR_WANT_READ)
++ || !TEST_uchar_eq(alert[0], 0)
++ || !TEST_uchar_eq(alert[1], 0)
++ || !TEST_true(write_and_read_app_data(serverssl, clientssl)))
++ goto end;
++
++ testresult = 1;
++ end:
++ SSL_free(serverssl);
++ SSL_free(clientssl);
++ SSL_CTX_free(sctx);
++ SSL_CTX_free(cctx);
++ return testresult;
++}
++#endif
++
+ int setup_tests(void)
+ {
+ if (!TEST_ptr(cert = test_get_argument(0))
+@@ -188,6 +402,13 @@ int setup_tests(void)
+ return 0;
+
+ ADD_ALL_TESTS(test_record_overflow, TOTAL_RECORD_OVERFLOW_TESTS);
++#ifndef OPENSSL_NO_TLS1_2
++ ADD_ALL_TESTS(test_tls12_short_aead_record,
++ OSSL_NELEM(short_aead_record_tests));
++#endif
++#ifndef OPENSSL_NO_DTLS1_2
++ ADD_TEST(test_dtls12_short_aead_record);
++#endif
+ return 1;
+ }
+
+--
+2.56.0
+