From 75dedeff28d09f5445fcfab88ee4ca58f837968c Mon Sep 17 00:00:00 2001 From: Nirmal Khanal Date: Fri, 24 Jul 2026 15:00:00 +0300 Subject: [PATCH] Fix: short CL cleartext passwords failed authentication strongauth() compared short CL passwords over pwl_table.recsize-1 bytes, reading past the client password buffer (strdup of pwlen+1) and rejecting valid passwords whenever trailing heap bytes were non-zero. Zero-pad the provided password to the record width and compare in constant time, like the long-password BLAKE2 path. Fixes #1254 --- src/auth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/auth.c b/src/auth.c index 72ae332..d591f49 100644 --- a/src/auth.c +++ b/src/auth.c @@ -247,7 +247,9 @@ int strongauth(struct clientparam * param){ int pwlen = strlen((char *)param->password); if(pwlen > 255) pwlen = 255; if((unsigned)pwlen < pwl_table.recsize) { - if(strlen(pass + 1) == strlen((char *)param->password) && !ctmemcmp(pass + 1, param->password, pwl_table.recsize - 1)) return 0; + memset(buf, 0, pwl_table.recsize - 1); + memcpy(buf, param->password, pwlen); + if(!ctmemcmp(pass + 1, buf, pwl_table.recsize - 1)) return 0; } else { mdh_ctx *bctx; unsigned hashsz;