mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-22974: mysql_native_password make "invalid" valid
Per b9f3f06857
, mysql_system_tables_data.sql creates
a mysql_native_password with a salted hash of "invalid" so that `set password`
will detect a native password can be applied:.
SHOW CREATE USER; diligently uses this value in its output
generating the SQL:
MariaDB [(none)]> show create user;
+---------------------------------------------------------------------------------------------------+
| CREATE USER for dan@localhost |
+---------------------------------------------------------------------------------------------------+
| CREATE USER `dan`@`localhost` IDENTIFIED VIA mysql_native_password USING 'invalid' OR unix_socket |
+---------------------------------------------------------------------------------------------------+
Attempting to execute this before this patch results in:
MariaDB [(none)]> CREATE USER `dan2`@`localhost` IDENTIFIED VIA mysql_native_password USING 'invalid' OR unix_socket;
ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number
As such, deep the implementation of mysql_native_password we make "invalid" valid (pun intended)
such that the above create user will succeed. We do this by storing
"*THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE" (credit: Oracle MySQL), that is of an INCORRECT
length for a scramble.
In native_password_authenticate we check the length of this cached value
and immediately fail if it is anything other than the scramble length.
native_password_get_salt is only called in the context of set_user_salt, so all setting of native
passwords to hashed content of 'invalid', quite literally create an invalid password.
So other forms of "invalid" are valid SQL in creating invalid passwords:
MariaDB [(none)]> set password = 'invalid';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> alter user dan@localhost IDENTIFIED BY PASSWORD 'invalid';
Query OK, 0 rows affected (0.000 sec)
closes #1628
Reviewer: serg@mariadb.com
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
set global secure_auth=0;
|
||||
create user natauth@localhost identified via 'mysql_native_password' using '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29';
|
||||
create user invalidauth@localhost identified via 'mysql_native_password' using 'invalid';
|
||||
create user newpass@localhost identified by password '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29';
|
||||
create user invalidpass@localhost identified by password 'invalid';
|
||||
create user newpassnat@localhost identified via 'mysql_native_password';
|
||||
set password for newpassnat@localhost = '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29';
|
||||
create user invalidpassnat@localhost identified by password 'invalid';
|
||||
set password for invalidpassnat@localhost = 'invalid';
|
||||
create user oldauth@localhost identified with 'mysql_old_password' using '378b243e220ca493';
|
||||
create user oldpass@localhost identified by password '378b243e220ca493';
|
||||
create user oldpassold@localhost identified with 'mysql_old_password';
|
||||
set password for oldpassold@localhost = '378b243e220ca493';
|
||||
select user, host, password, plugin, authentication_string from mysql.user where user != 'root';
|
||||
User Host Password plugin authentication_string
|
||||
invalidauth localhost invalid mysql_native_password invalid
|
||||
invalidpass localhost invalid mysql_native_password invalid
|
||||
invalidpassnat localhost invalid mysql_native_password invalid
|
||||
mariadb.sys localhost mysql_native_password
|
||||
natauth localhost *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 mysql_native_password *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
|
||||
newpass localhost *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 mysql_native_password *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
|
||||
@@ -87,6 +94,9 @@ set password for oldpass@localhost = PASSWORD('test2');
|
||||
set password for oldpassold@localhost = PASSWORD('test2');
|
||||
select user, host, password, plugin, authentication_string from mysql.user where user != 'root';
|
||||
User Host Password plugin authentication_string
|
||||
invalidauth localhost invalid mysql_native_password invalid
|
||||
invalidpass localhost invalid mysql_native_password invalid
|
||||
invalidpassnat localhost invalid mysql_native_password invalid
|
||||
mariadb.sys localhost mysql_native_password
|
||||
natauth localhost *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E mysql_native_password *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E
|
||||
newpass localhost *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E mysql_native_password *7CEB3FDE5F7A9C4CE5FBE610D7D8EDA62EBE5F4E
|
||||
@@ -141,6 +151,15 @@ select current_user();
|
||||
current_user()
|
||||
newpassnat@localhost
|
||||
disconnect con;
|
||||
connect(localhost,invalidauth,invalid,test,MASTER_PORT,MASTER_SOCKET);
|
||||
connect con,localhost,invalidauth,invalid,;
|
||||
ERROR 28000: Access denied for user 'invalidauth'@'localhost' (using password: YES)
|
||||
connect(localhost,invalidpass,invalid,test,MASTER_PORT,MASTER_SOCKET);
|
||||
connect con,localhost,invalidpass,invalid,;
|
||||
ERROR 28000: Access denied for user 'invalidpass'@'localhost' (using password: YES)
|
||||
connect(localhost,invalidpassnat,invalid,test,MASTER_PORT,MASTER_SOCKET);
|
||||
connect con,localhost,invalidpassnat,invalid,;
|
||||
ERROR 28000: Access denied for user 'invalidpassnat'@'localhost' (using password: YES)
|
||||
connect con,localhost,oldauth,test2,;
|
||||
select current_user();
|
||||
current_user()
|
||||
@@ -158,6 +177,7 @@ oldpassold@localhost
|
||||
disconnect con;
|
||||
connection default;
|
||||
drop user natauth@localhost, newpass@localhost, newpassnat@localhost;
|
||||
drop user invalidauth@localhost, invalidpass@localhost, invalidpassnat@localhost;
|
||||
drop user oldauth@localhost, oldpass@localhost, oldpassold@localhost;
|
||||
set global secure_auth=default;
|
||||
# switching from mysql.global_priv to mysql.user
|
||||
|
Reference in New Issue
Block a user