Closed jkuwaha closed 1 year ago
Hi,
We think we found the root cause of the issue.
Settings
Observation
On calling nx_secure_tls_session_start()
, BusFault happens.
One of the certificates NetX sent has extra zeros in the middle of it.
Root cause
In _nx_secure_tls_send_certificate()
, an out-of-array access happens,
which may destroy a value of nx_packet_pool_owner
member of NX_PACKET.
This may cause BusFault when the pointer is used at _nx_packet_release()
.
When the certificates do not fit in one NX_PACKET, new NX_PACKET is allocated and linked to the original.
In that case, send_packet -> nx_packet_append_ptr
does not point to the end of valid data, but the next address of the end of the data area of the first NX_PACKET. Writing through this pointer causes out of bounds access.
Tentative fix
I tried following and confirmed working.
#if (NX_SECURE_TLS_TLS_1_3_ENABLED)
/* Check for TLS 1.3 extensions following each certificate. */
if(tls_session->nx_secure_tls_1_3)
{
extensions_length = 0;
UCHAR extensions_length_be[2];
extensions_length_be[0] = (UCHAR)((extensions_length & 0xFF00) >> 8);
extensions_length_be[1] = (UCHAR)(extensions_length & 0x00FF);
/* Add extension length to packet. */
status = nx_packet_data_append(send_packet,
extensions_length_be,
sizeof(extensions_length_be),
tls_session -> nx_secure_tls_packet_pool,
wait_option);
if (status != NX_SUCCESS)
{
return(status);
}
total_length += 2;
}
#endif
Does this fix look okay?
Thanks for reporting this bug. Your fix looks good.
Thank you for checking my code! I'll use this solution until the bug is fixed in the future release.
Hi,
We are using NetX Duo 6.1.10, and experiencing BusFault when trying to connect with 'TLS 1.3 with client authentication'.
We use
openssl s_server
as a server, and it works fine with 'TLS 1.2 with/without client authentication' and 'TLS 1.3 without client authentication'.BusFault happens in _nx_packet_release(), but its line numbers and call paths vary.
Could you please let us know what we need to check? Is this related to other issues already reported?
Settings: