fix(auth): validate gcaptcha before password to prevent bypass

Move gcaptcha check before credential validation so a valid captcha
is required prior to any login attempt. Previously, password auth
ran first, allowing timing-based enumeration without captcha.

Signed-off-by: Travis Garrison <travis@chiraqbookstore.com>
This commit is contained in:
Travis Garrison committed 2026-08-05 11:35:07 +04:00
1 parent 8e465f9256
commit 5dea748b0c
1 file changed
+7 -7
+7 -7
View File
@@ -39,13 +39,6 @@ class OSPOSRules
return false;
}
$password = $data['password'];
if (!$employee->login($username, $password)) {
$error = lang('Login.invalid_username_and_password');
return false;
}
$gcaptcha_enabled = array_key_exists('gcaptcha_enable', $this->config) && $this->config['gcaptcha_enable'];
if ($gcaptcha_enabled) {
$g_recaptcha_response = $this->request->getPost('g-recaptcha-response');
@@ -57,6 +50,13 @@ class OSPOSRules
}
}
$password = $data['password'];
if (!$employee->login($username, $password)) {
$error = lang('Login.invalid_username_and_password');
return false;
}
return true;
}