Skip to content

Commit dab5fe4

Browse files
committed
fix: Zero out stack-allocated secret key before return.
Issue found by iphydf (no tools for this, yet).
1 parent f058103 commit dab5fe4

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

toxcore/group_chats.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4029,6 +4029,10 @@ static int handle_gc_key_exchange(const GC_Chat *chat, GC_Connection *gconn, con
40294029
memcpy(response + 1, new_session_pk, ENC_PUBLIC_KEY_SIZE);
40304030

40314031
if (!send_lossless_group_packet(chat, gconn, response, sizeof(response), GP_KEY_ROTATION)) {
4032+
// Don't really care about zeroing the secret key here, because we failed, but
4033+
// we're doing it anyway for symmetry with the memzero+munlock below, where we
4034+
// really do care about it.
4035+
crypto_memzero(new_session_sk, sizeof(new_session_sk));
40324036
return -3;
40334037
}
40344038

@@ -4038,6 +4042,7 @@ static int handle_gc_key_exchange(const GC_Chat *chat, GC_Connection *gconn, con
40384042

40394043
gcc_make_session_shared_key(gconn, sender_public_session_key);
40404044

4045+
crypto_memzero(new_session_sk, sizeof(new_session_sk));
40414046
crypto_memunlock(new_session_sk, sizeof(new_session_sk));
40424047

40434048
gconn->last_key_rotation = mono_time_get(chat->mono_time);

0 commit comments

Comments
 (0)