Skip to content

Commit 7cb9bfd

Browse files
tobiasbrunnerferasbi
authored andcommitted
charon-tkm: Validate DH public key to fix potential buffer overflow
Seems this was forgotten in the referenced commit and actually could lead to a buffer overflow. Since charon-tkm is untrusted this isn't that much of an issue but could at least be easily exploited for a DoS attack as DH public values are set when handling IKE_SA_INIT requests. Fixes: 0356089 ("diffie-hellman: Verify public DH values in backends") Fixes: CVE-2023-41913
1 parent 3b20264 commit 7cb9bfd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/charon-tkm/src/tkm/tkm_diffie_hellman.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ METHOD(key_exchange_t, get_shared_secret, bool,
7070
return TRUE;
7171
}
7272

73-
7473
METHOD(key_exchange_t, set_public_key, bool,
7574
private_tkm_diffie_hellman_t *this, chunk_t value)
7675
{
7776
dh_pubvalue_type othervalue;
77+
78+
if (!key_exchange_verify_pubkey(this->group, value) ||
79+
value.len > sizeof(othervalue.data))
80+
{
81+
return FALSE;
82+
}
7883
othervalue.size = value.len;
7984
memcpy(&othervalue.data, value.ptr, value.len);
8085

0 commit comments

Comments
 (0)