mirror of
https://github.com/yuzu-emu/mbedtls
synced 2024-11-23 21:33:51 +00: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
01a96d6fd2
commit
d5c4a7cc11
1 changed files with 13 additions and 0 deletions
|
@ -1417,6 +1417,19 @@ static int ssl_parse_hello_verify_request( mbedtls_ssl_context *ssl )
|
|||
|
||||
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 {
|
||||
* ProtocolVersion server_version;
|
||||
|
|
Loading…
Reference in a new issue