mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-18 05:42:35 +00:00
Fix buffer overflow in TLS 1.2 ClientKeyExchange parsing
Fix a buffer overflow in TLS 1.2 ClientKeyExchange parsing. When MBEDTLS_USE_PSA_CRYPTO is enabled, the length of the public key in an ECDH or ECDHE key exchange was not validated. This could result in an overflow of handshake->xxdh_psa_peerkey, overwriting further data in the handshake structure or further on the heap. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
12c5aaae57
commit
c8df898204
@ -3734,6 +3734,11 @@ static int ssl_parse_client_key_exchange(mbedtls_ssl_context *ssl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Store peer's ECDH public key. */
|
/* Store peer's ECDH public key. */
|
||||||
|
MBEDTLS_SSL_DEBUG_MSG(3, ("data_len=%zu sizeof(handshake->xxdh_psa_peerkey)=%zu", data_len, sizeof(handshake->xxdh_psa_peerkey)));
|
||||||
|
if (data_len > sizeof(handshake->xxdh_psa_peerkey)) {
|
||||||
|
MBEDTLS_SSL_DEBUG_MSG(1, ("Invalid data length"));
|
||||||
|
return MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE;
|
||||||
|
}
|
||||||
memcpy(handshake->xxdh_psa_peerkey, p, data_len);
|
memcpy(handshake->xxdh_psa_peerkey, p, data_len);
|
||||||
handshake->xxdh_psa_peerkey_len = data_len;
|
handshake->xxdh_psa_peerkey_len = data_len;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user