Merge a0053fe8a9d5bddc9d3ab8953aef4e91b5fc632d into 3bb373867917b674265067cbd38b9d252c43d014

This commit is contained in:
Naveed 2026-07-20 18:14:37 +05:30 committed by GitHub
commit 14219b1944
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,6 @@
Bugfix
* Fix a one-byte buffer over-read when parsing a TLS 1.2 ClientHello or
CertificateRequest. The length checks preceding the ciphersuite-list
length (server side) and the certificate-authorities length (client
side) reserved one byte too few, so a truncated message could cause the
two-byte length field to be read one byte past the end of the message.

View File

@ -2279,6 +2279,16 @@ static int ssl_parse_certificate_request(mbedtls_ssl_context *ssl)
n += 2 + sig_alg_len;
/* The signature-algorithms check above leaves room for only one of the two
* distinguished-name length bytes, so make sure both are in the message
* before reading them. */
if (ssl->in_hslen < mbedtls_ssl_hs_hdr_len(ssl) + 3 + n) {
MBEDTLS_SSL_DEBUG_MSG(1, ("bad certificate request message"));
mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR);
return MBEDTLS_ERR_SSL_DECODE_ERROR;
}
/* certificate_authorities */
dn_len = MBEDTLS_GET_UINT16_BE(buf, mbedtls_ssl_hs_hdr_len(ssl) + 1 + n);

View File

@ -1074,6 +1074,16 @@ static int ssl_parse_client_hello(mbedtls_ssl_context *ssl)
#endif /* MBEDTLS_SSL_PROTO_DTLS */
ciph_offset = 35 + sess_len;
/* The two-byte ciphersuite list length field must be within the message.
* The DTLS branch above reserves it via the cookie length check; the
* session id length check does not, so guard the read here. */
if (ciph_offset + 2 > msg_len) {
MBEDTLS_SSL_DEBUG_MSG(1, ("bad client hello message"));
mbedtls_ssl_send_alert_message(ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR);
return MBEDTLS_ERR_SSL_DECODE_ERROR;
}
ciph_len = MBEDTLS_GET_UINT16_BE(buf, ciph_offset);
if (ciph_len < 2 ||