mirror of
https://github.com/coturn/coturn.git
synced 2026-05-05 10:46:10 +02:00
Use constant-time compare for STUN MESSAGE-INTEGRITY HMAC (#1869)
memcmp short-circuits on first differing byte, letting an attacker recover a valid HMAC byte-by-byte via response-time differences. Switch to CRYPTO_memcmp, which is constant-time regardless of the first mismatching byte.
This commit is contained in:
parent
c3a17d06fd
commit
dbc2884096
@ -1931,7 +1931,9 @@ int stun_check_message_integrity_by_key_str(turn_credential_type ct, uint8_t *bu
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 != memcmp(old_hmac, new_hmac, shasize)) {
|
||||
/* Use constant-time comparison: a short-circuiting memcmp leaks the matching prefix
|
||||
length via response timing, allowing byte-by-byte HMAC recovery. */
|
||||
if (0 != CRYPTO_memcmp(old_hmac, new_hmac, shasize)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user