Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 4781344

Browse files
kaduktmshort
authored andcommitted
QUIC: 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).
1 parent 24349fa commit 4781344

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

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) {

ssl/statem/statem_lib.c

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

657657
int tls_construct_key_update(SSL *s, WPACKET *pkt)
658658
{
659+
#ifndef OPENSSL_NO_QUIC
660+
if (SSL_is_quic(s)) {
661+
/* TLS KeyUpdate is not used for QUIC, so this is an error. */
662+
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
663+
return 0;
664+
}
665+
#endif
659666
if (!WPACKET_put_bytes_u8(pkt, s->key_update)) {
660667
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
661668
return 0;
@@ -678,6 +685,13 @@ MSG_PROCESS_RETURN tls_process_key_update(SSL *s, PACKET *pkt)
678685
return MSG_PROCESS_ERROR;
679686
}
680687

688+
#ifndef OPENSSL_NO_QUIC
689+
if (SSL_is_quic(s)) {
690+
SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_R_UNEXPECTED_MESSAGE);
691+
return MSG_PROCESS_ERROR;
692+
}
693+
#endif
694+
681695
if (!PACKET_get_1(pkt, &updatetype)
682696
|| PACKET_remaining(pkt) != 0) {
683697
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_R_BAD_KEY_UPDATE);

0 commit comments

Comments
 (0)