Skip to content

Commit bad1a15

Browse files
kadukjasnell
authored andcommitted
deps: cherry-pick akamai/openssl/commit/d5a13ca6e29f3ff85c731770ab0ee2f2487bf8b3
Original Commit Message: Prevent KeyUpdate for QUIC QUIC does not use the TLS KeyUpdate message/mechanism, and indeed it is an error to generate or receive such a message. Add the necessary checks (noting that the check for receipt should be redundant since SSL_provide_quic_data() is the only way to provide input to the TLS layer for a QUIC connection). PR-URL: #34033 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
1 parent 74cbfd3 commit bad1a15

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

deps/openssl/openssl/ssl/ssl_quic.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ int SSL_provide_quic_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL level,
9292
const uint8_t *data, size_t len)
9393
{
9494
size_t l;
95+
uint8_t mt;
9596

9697
if (!SSL_IS_QUIC(ssl)) {
9798
SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
@@ -131,9 +132,14 @@ int SSL_provide_quic_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL level,
131132
return 0;
132133
}
133134
/* TLS Handshake message header has 1-byte type and 3-byte length */
135+
mt = *data;
134136
p = data + 1;
135137
n2l3(p, l);
136138
l += SSL3_HM_HEADER_LENGTH;
139+
if (mt == SSL3_MT_KEY_UPDATE) {
140+
SSLerr(SSL_F_SSL_PROVIDE_QUIC_DATA, SSL_R_UNEXPECTED_MESSAGE);
141+
return 0;
142+
}
137143

138144
qd = OPENSSL_zalloc(sizeof(QUIC_DATA) + l);
139145
if (qd == NULL) {

deps/openssl/openssl/ssl/statem/statem_lib.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,14 @@ int tls_construct_finished(SSL *s, WPACKET *pkt)
630630

631631
int tls_construct_key_update(SSL *s, WPACKET *pkt)
632632
{
633+
#ifndef OPENSSL_NO_QUIC
634+
if (SSL_is_quic(s)) {
635+
/* TLS KeyUpdate is not used for QUIC, so this is an error. */
636+
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_KEY_UPDATE,
637+
ERR_R_INTERNAL_ERROR);
638+
return 0;
639+
}
640+
#endif
633641
if (!WPACKET_put_bytes_u8(pkt, s->key_update)) {
634642
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_KEY_UPDATE,
635643
ERR_R_INTERNAL_ERROR);
@@ -654,6 +662,14 @@ MSG_PROCESS_RETURN tls_process_key_update(SSL *s, PACKET *pkt)
654662
return MSG_PROCESS_ERROR;
655663
}
656664

665+
#ifndef OPENSSL_NO_QUIC
666+
if (SSL_is_quic(s)) {
667+
SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_F_TLS_PROCESS_KEY_UPDATE,
668+
SSL_R_UNEXPECTED_MESSAGE);
669+
return MSG_PROCESS_ERROR;
670+
}
671+
#endif
672+
657673
if (!PACKET_get_1(pkt, &updatetype)
658674
|| PACKET_remaining(pkt) != 0) {
659675
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_KEY_UPDATE,

0 commit comments

Comments
 (0)