You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iggy.apache.org by hg...@apache.org on 2026/07/02 22:08:38 UTC

(iggy) 31/43: fix(server-ng): stop leaking account status on inactive login

This is an automated email from the ASF dual-hosted git repository.

hubcio pushed a commit to branch http-listener-rebased
in repository https://gitbox.apache.org/repos/asf/iggy.git

commit 6d856ab001ce2862f554faa58b679aec0f648539
Author: Hubert Gruszecki <h....@gmail.com>
AuthorDate: Thu Jul 2 21:22:12 2026 +0200

    fix(server-ng): stop leaking account status on inactive login
    
    Login against an inactive user returned a distinct UserInactive error
    without paying the Argon2 verify, so an attacker could tell inactive
    accounts apart from nonexistent ones by error shape and timing. Verify
    the password first and return InvalidCredentials either way; the PAT
    path keeps UserInactive since a valid token already proves existence.
---
 core/server-ng/src/auth.rs | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/core/server-ng/src/auth.rs b/core/server-ng/src/auth.rs
index 9dd5d5413..7fa03af06 100644
--- a/core/server-ng/src/auth.rs
+++ b/core/server-ng/src/auth.rs
@@ -83,10 +83,13 @@ pub(crate) fn verify_login_credentials(
             let _ = crypto::verify_password(password, DUMMY_PASSWORD_HASH.as_str());
             return Err(LoginRegisterError::InvalidCredentials);
         };
-        if user.status != UserStatus::Active {
-            return Err(LoginRegisterError::UserInactive);
-        }
-        if !crypto::verify_password(password, user.password_hash.as_ref()) {
+        // Verify before the status check and collapse inactive to
+        // InvalidCredentials: an inactive account must answer exactly like a
+        // wrong password (same error, same Argon2 cost), or login could probe
+        // which accounts exist but are disabled.
+        if !crypto::verify_password(password, user.password_hash.as_ref())
+            || user.status != UserStatus::Active
+        {
             return Err(LoginRegisterError::InvalidCredentials);
         }
         Ok(user.id)