Explorar el Código

Serve consistent error responses on failed logins (#9568)

Fixes #4095

Follow-up of #9566

Although no separate error message for disabled users yet (will be done in another PR).
Inverle hace 4 horas
padre
commit
77e74e81b7
Se han modificado 2 ficheros con 5 adiciones y 5 borrados
  1. 2 1
      CHANGELOG.md
  2. 3 4
      app/Controllers/authController.php

+ 2 - 1
CHANGELOG.md

@@ -15,7 +15,8 @@ See also [the FreshRSS releases](https://github.com/FreshRSS/FreshRSS/releases).
 	* Fix saved search references with overlapping IDs or names [#9484](https://github.com/FreshRSS/FreshRSS/pull/9484)
 	* Fix saved search references with overlapping IDs or names [#9484](https://github.com/FreshRSS/FreshRSS/pull/9484)
 	* Fix non-ASCII characters in scripts of fetched HTML pages [#9384](https://github.com/FreshRSS/FreshRSS/pull/9384)
 	* Fix non-ASCII characters in scripts of fetched HTML pages [#9384](https://github.com/FreshRSS/FreshRSS/pull/9384)
 * Security
 * Security
-	* 💥 Replace bcrypt challenge auth with direct password comparison [#9358](https://github.com/FreshRSS/FreshRSS/pull/9358), [#9550](https://github.com/FreshRSS/FreshRSS/pull/9550)
+	* 💥 Replace bcrypt challenge auth with direct password comparison [#9358](https://github.com/FreshRSS/FreshRSS/pull/9358), [#9550](https://github.com/FreshRSS/FreshRSS/pull/9550), [#9566](https://github.com/FreshRSS/FreshRSS/pull/9566)
+	* Fix user enumeration by probing inconsistent error responses on failed logins [#9568](https://github.com/FreshRSS/FreshRSS/pull/9568)
 	* WebSub security: Implement support for `hub.secret` [#9430](https://github.com/FreshRSS/FreshRSS/pull/9430)
 	* WebSub security: Implement support for `hub.secret` [#9430](https://github.com/FreshRSS/FreshRSS/pull/9430)
 	* Fix escape labels during JSON import and render tag dropdown as text [#9504](https://github.com/FreshRSS/FreshRSS/pull/9504)
 	* Fix escape labels during JSON import and render tag dropdown as text [#9504](https://github.com/FreshRSS/FreshRSS/pull/9504)
 	* Document threat model for security scanners [#9509](https://github.com/FreshRSS/FreshRSS/pull/9509)
 	* Document threat model for security scanners [#9509](https://github.com/FreshRSS/FreshRSS/pull/9509)

+ 3 - 4
app/Controllers/authController.php

@@ -150,15 +150,13 @@ class FreshRSS_auth_Controller extends FreshRSS_ActionController {
 
 
 			FreshRSS_Context::initUser($username);
 			FreshRSS_Context::initUser($username);
 			if (!FreshRSS_Context::hasUserConf()) {
 			if (!FreshRSS_Context::hasUserConf()) {
-				// Initialise the default user to be able to display the error page
-				FreshRSS_Context::initUser(FreshRSS_Context::systemConf()->default_user);
-				Minz_Error::error(403, _t('feedback.auth.login.invalid'), false);
+				self::loginFailed(403, _t('feedback.auth.login.invalid'));
 				return;
 				return;
 			}
 			}
 
 
 			if (!FreshRSS_Context::userConf()->enabled || FreshRSS_Context::userConf()->passwordHash == '') {
 			if (!FreshRSS_Context::userConf()->enabled || FreshRSS_Context::userConf()->passwordHash == '') {
 				usleep(random_int(100, 5000));	// Primitive mitigation of timing attacks, in μs
 				usleep(random_int(100, 5000));	// Primitive mitigation of timing attacks, in μs
-				Minz_Error::error(403, _t('feedback.auth.login.invalid'), false);
+				self::loginFailed(403, _t('feedback.auth.login.invalid'));
 				return;
 				return;
 			}
 			}
 
 
@@ -205,6 +203,7 @@ class FreshRSS_auth_Controller extends FreshRSS_ActionController {
 			} else {
 			} else {
 				Minz_Log::warning("Password mismatch for user={$username}, ip_address={$ip_address}");
 				Minz_Log::warning("Password mismatch for user={$username}, ip_address={$ip_address}");
 				self::loginFailed(403, _t('feedback.auth.login.invalid'));
 				self::loginFailed(403, _t('feedback.auth.login.invalid'));
+				return;
 			}
 			}
 		} else {
 		} else {
 			Minz_Session::deleteLegacyCookie('FreshRSS');	// Delete legacy cookie (before 1.29.0)
 			Minz_Session::deleteLegacyCookie('FreshRSS');	// Delete legacy cookie (before 1.29.0)