[MDEV-23729] INFORMATION_SCHEMA Table info. about user locked due to max_password_errors Created: 2020-09-14  Updated: 2023-12-22

Status: Stalled
Project: MariaDB Server
Component/s: None
Fix Version/s: 11.5

Type: New Feature Priority: Critical
Reporter: suresh ramagiri Assignee: Nikita Malyavin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-7598 Block user accounts after failed logi... Closed
Relates
relates to MDEV-32649 Enhancement to INFORMATION_SCHEMA Tab... Open
relates to MDEV-29209 Implement connection response delay a... Stalled
relates to MDEV-32218 message to notify end-user N-days pri... Open

 Description   

Currently with the max_password_errors configured, we don't really see any tables having a flag about the blocked user account due to this reason. (i.e., user blocked with the max attempt of trying to connect db with wrong password).

https://mariadb.com/kb/en/server-system-variables/#max_password_errors

One of our customers seems like in requirement of getting the list of blocked users, due to wrong password attempts.

Like for the "Account Locking", whenever a user is locked, will have "account_lock:false or true" in JSON object of the table "mysql.global_priv table", can we implement the similar type of info available for the blocked users for the max_password_errors case?



 Comments   
Comment by Sergei Golubchik [ 2020-09-14 ]

No, we cannot have a similar information in the mysql.global_priv table, because blocking is a transient information, it is only present in memory and we do not and do not want to modify a persistent table every time such a transient event happens.

We can provide an INFORMATION_SCHEMA table that will show blocked accounts.

Comment by Daniel Black [ 2021-02-17 ]

Technically you can use fail2ban for this with an actionban to execute the sql lock the user.

Comment by Federico Razzoli [ 2021-07-09 ]

This will make brute force virtually impossible, but DoS will be trivial...

Comment by Sergei Golubchik [ 2021-07-09 ]

f_razzoli, this MDEV is only about showing the blocking information. The blocking itself was already implemented in MDEV-7598. For DoS one needs to know the user name. root is easy to guess, of course. FLUSH resets blocking information. And superuser on localhost ignores the limit, so one can always connect from localhost and FLUSH.

Comment by Federico Razzoli [ 2021-07-09 ]

I see.

There are cases where the username is known or guessable:

  • A CMS default username
  • A former/malicious employee knows the pattern for human users (eg: name_surname)

Even if the DBA unblocks the users, the attacker can re-block them.

I'd think that if we had an option to block a client instead, that would be safer.

Comment by Nikita Malyavin [ 2023-11-30 ]

serg I ran through the list of the IS table we have: USER_STATISTICS table looks like a good fit.

But note that it requires userstat variable enabled, which enables statistics gathering for USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS tables.

Comment by Sergei Golubchik [ 2023-12-01 ]

nikitamalyavin, may be PERFORMANCE_SCHEMA.ACCOUNTS table?

You can add m_password_errors to PFS_account, and a line to handle_password_errors(), like

    PSI_CALL_set_account_password_errors(u->user, u->host, u->password_errors);

As an optimization you can only do it on the wrong password and reset it to zero in PSI_CALL_set_thread_account, this way there will be no extra PSI_CALL's if the authentication is successful.

Comment by Nikita Malyavin [ 2023-12-05 ]

serg putting it into a PFS database doesn't seem logically correct – there's nothing about performance in the requested field, be it max_password_exceeded, or password_errors has nothing to do with performance. On the contrary, USER_STATISTICS already has some fields related to security, and a similar field ACCESS_DENIED.

Though it also has performance-related field TOTAL_SSL_CONNECTIONS which would fit PERFORMANCE_SCHEMA.ACCOUNTS best.

Is there any special benefit from using a PFS ACCOUNTS table, apart from no need of enabling userstat variable?

Note about MDEV-29209: following my logic, a number of failed login attempts would not be suitable for ACCOUNTS, while connection delay seems perfect to be placed there.

serg if we don't want the need to enable userstat for max-passwords violations, maybe really create a new table, like INFORMATION_SCHEMA.SECURITY, where we'd put this field and a number a failed logins overall? Also ACCESS_DENIED can be duplicated there (probably with deprecating it in the USER_STATISTICS table)?

Comment by Sergei Golubchik [ 2023-12-05 ]

PERFORMANCE_SCHEMA is not limited to performance as such, see THREADS, STATUS_VARIABLES, etc. It's simply a schema for all kind of run-time stats and data. While INFORMATION_SCHEMA is a standard schema for metadata. It's not supposed to be used for anything else, STATUS_VARIABLES, GLOBAL_VARIABLES, etc, etc — those tables don't logically belong to INFORMATION_SCHEMA, but they were added before we had PERFORMANCE_SCHEMA, and there's no easy way to remove them.

Comment by Sergei Golubchik [ 2023-12-15 ]

On the other hand, if we'll do MDEV-32218, then the same table can be used here too, even though it won't be strictly correct.

Generated at Thu Feb 08 09:24:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.