mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 23:25:43 +01:00
Parse HelloVerifyRequest: avoid buffer overread at the start
In ssl_parse_hello_verify_request, we read 3 bytes (version and cookie length) without checking that there are that many bytes left in ssl->in_msg. This could potentially read from memory outside of the ssl->receive buffer (which would be a remotely exploitable crash).
This commit is contained in:
parent
99b6777b72
commit
2414ce1a5e
@ -1411,6 +1411,19 @@ static int ssl_parse_hello_verify_request( mbedtls_ssl_context *ssl )
|
|||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse hello verify request" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse hello verify request" ) );
|
||||||
|
|
||||||
|
/* Check that there is enough room for:
|
||||||
|
* - 2 bytes of version
|
||||||
|
* - 1 byte of cookie_len
|
||||||
|
*/
|
||||||
|
if( mbedtls_ssl_hs_hdr_len( ssl ) + 3 > ssl->in_msglen )
|
||||||
|
{
|
||||||
|
MBEDTLS_SSL_DEBUG_MSG( 1,
|
||||||
|
( "incoming HelloVerifyRequest message is too short" ) );
|
||||||
|
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
|
||||||
|
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
|
||||||
|
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* struct {
|
* struct {
|
||||||
* ProtocolVersion server_version;
|
* ProtocolVersion server_version;
|
||||||
|
Loading…
Reference in New Issue
Block a user