1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-10 03:33:12 +02:00

relay: fix timing attack on password authentication (GHSA-vhv8-g2r9-cwcc)

The relay authentication used non-constant-time comparisons (strcasecmp,
strcmp) to verify password hashes and plaintext passwords, allowing an
attacker to derive the expected hash byte-by-byte from response timing
and then authenticate without knowing the password.

- SHA/PBKDF2 hex hash comparisons: normalize the client-supplied hash to
  uppercase and compare in constant time over the fixed expected length.
- Plaintext password comparison: HMAC-SHA256 both passwords with a fresh
  per-call random key and compare the fixed-size MACs in constant time,
  hiding both per-byte timing and the password length.

Add string_memcmp_constant_time helper in core, exposed via the plugin
API. Bump WEECHAT_PLUGIN_API_VERSION accordingly.
This commit is contained in:
Sébastien Helleu
2026-05-30 19:00:59 +02:00
parent 405707d544
commit a17a80f1d0
7 changed files with 158 additions and 11 deletions
+6 -1
View File
@@ -74,7 +74,7 @@ struct t_weelist_item;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
#define WEECHAT_PLUGIN_API_VERSION "20250215-01"
#define WEECHAT_PLUGIN_API_VERSION "20260530-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -346,6 +346,8 @@ struct t_weechat_plugin
int max, int range);
int (*strcmp_ignore_chars) (const char *string1, const char *string2,
const char *chars_ignored, int case_sensitive);
int (*string_memcmp_constant_time) (const void *area1, const void *area2,
size_t size);
const char *(*strcasestr) (const char *string, const char *search);
int (*strlen_screen) (const char *string);
int (*string_match) (const char *string, const char *mask,
@@ -1342,6 +1344,9 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
(weechat_plugin->strcmp_ignore_chars)(__string1, __string2, \
__chars_ignored, \
__case_sensitive)
#define weechat_string_memcmp_constant_time(__area1, __area2, __size) \
(weechat_plugin->string_memcmp_constant_time)(__area1, __area2, \
__size)
#define weechat_strcasestr(__string, __search) \
(weechat_plugin->strcasestr)(__string, __search)
#define weechat_strlen_screen(__string) \