[MDEV-17950] SHOW GRANTS FOR does not work for a user identified with non-existing plugin Created: 2018-12-09  Updated: 2019-02-04  Resolved: 2019-02-04

Status: Closed
Project: MariaDB Server
Component/s: Authentication and Privilege System
Affects Version/s: 10.4
Fix Version/s: 10.4.3

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-18290 Users identified via ed25519 are brok... Closed
Problem/Incident
is caused by MDEV-12321 authentication plugin: SET PASSWORD s... Closed

 Description   

INSTALL SONAME 'auth_socket';
CREATE USER foo IDENTIFIED WITH unix_socket;
SHOW GRANTS FOR foo;
UNINSTALL SONAME 'auth_socket';
FLUSH PRIVILEGES;
SHOW GRANTS FOR foo;
 
# Cleanup
DROP USER foo;

10.4 fac997feef

MariaDB [test]> SHOW GRANTS FOR foo;
ERROR 1141 (42000): There is no such grant defined for user 'foo' on host '%'

On 10.3 the grants are still shown, and I think it makes more sense.



 Comments   
Comment by Sergei Golubchik [ 2018-12-11 ]

It was an intentional behavior change. Users with non-existing plugins are skipped during the load (just as users with host names if skip-name-resolve is used), so, practically, they don't exist.

Comment by Sergei Golubchik [ 2018-12-11 ]

The warning from FLUSH PRIVILEGES could've been better, though. Currently it does not say "user was skipped"

Comment by Elena Stepanova [ 2018-12-11 ]

It seems to be a pretty bad behavior change, why would we do that, what are we trying to achieve?

Instead of a rather clear message "plugin not loaded" the user will start getting obscure "Access denied", which can be caused by a number of reasons. It makes things more difficult for an account admin and more obscure for a user who can't login. What's the gain?

Even worse if you have a "stronger" and a "weaker" account for the same username, e.g. `foo@localhost` and `foo@'%'` (not mentioning anonymous account, which can be declared bad practice). Then, skipping the first one will cause the next one be picked up silently, which can be both unexpected and unwanted.

Making it as bad as skip-name-resolve doesn't seem to be a valid reason. Besides, skip-name-resolve is an active configuration, an admin at least makes it so intentionally (although I wouldn't blame them for not expecting such obscure side-effects). Non-existing plugin is a passive configuration, it's something somebody hasn't done, or even worse, something went wrong on a server/plugin side upon loading the plugin.

A better warning on FLUSH PRIVILEGES won't solve anything, it was just there for simpler reproducing. In reality most problems will happen upon server restart.

On a separate yet related note, how is it going to play along with the planned multiple authentication methods? If you are going to ignore the account completely because the plugin is not loaded, how can other methods be used?

Comment by Sergei Golubchik [ 2018-12-12 ]

Why: because before MDEV-12321 the server could load a user without a plugin and later, during an authentication attempt, to find out that a plugin wasn't available. After MDEV-12321, the server needs a plugin to load the user, without a plugin it doesn't know how to interpret the authentication string and whether it needs to be pre-processed on load. The easy solution was to skip users with an unknown plugin — installing a new plugin is a rare operation, uninstalling a plugin that has existing accounts using it is ever rarer.

Another solution would be to implement "lazy initialization" — mark an account as incomplete and finish the pre-processing on the first authentication attempt. I don't know if it's an important use case to cover, though.

Comment by Elena Stepanova [ 2018-12-12 ]

It does seem strange that we forsake usability in an unfortunately rather common scenario as a result of internal implementation of some rather obscure feature which we don't even know whether anybody needs or going to use.

And yes, the scenario with a missing plugin appears to be fairly common – a big part of my stackoverlow activity was devoted to explaining why users can't login when unix_socket is not loaded.

Please at least have the change documented explicitly somewhere. It won't help users, but it will give us a permanent link to refer to, instead of explaining every time again that it was done intentionally and why.

Comment by Sergei Golubchik [ 2018-12-13 ]

If it's a fairly common scenario, it needs to be covered. I'll reopen the issue.

Comment by Elena Stepanova [ 2019-01-16 ]

I didn't mention another fancy side-effect of the same change:

...
MariaDB [test]> SHOW CREATE USER foo;
ERROR 1133 (28000): Can't find any matching row in the user table
MariaDB [test]> CREATE USER foo;
ERROR 1133 (28000): Can't find any matching row in the user table

Generated at Thu Feb 08 08:40:22 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.