[MDEV-22312] Bad error message for SET DEFAULT ROLE when user account is not granted the role Created: 2020-04-20 Updated: 2021-10-25 Resolved: 2020-05-28 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Authentication and Privilege System |
| Affects Version/s: | 10.1.44, 10.2.31, 10.3.22, 10.4.12, 10.5.2 |
| Fix Version/s: | 10.5.4, 10.1.46, 10.2.33, 10.3.24, 10.4.14 |
| Type: | Bug | Priority: | Major |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Anel Husakovic |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Description |
|
Let's say that we create a role and a user account:
If we try to set this role to the user's default role without first granting the role to the user, then we see this error message:
This "Invalid role specification" error message is incorrect. It would be more accurate to say something like this:
Obviously, if we grant the role to the user before executing SET DEFAULT ROLE, then everything works fine:
|
| Comments |
| Comment by Anel Husakovic [ 2020-04-22 ] | |||||||||||||||||||||
|
According to the code, the result is according to the standard, rightserg?
And in code is said that:
| |||||||||||||||||||||
| Comment by Geoff Montee (Inactive) [ 2020-04-22 ] | |||||||||||||||||||||
|
It would be pretty disappointing if the SQL standard mandated an opaque error message in a context where that does not improve security. I could possibly understand the point of having an opaque error message in the case of an unprivileged user executing SET ROLE, since there is a chance that the user could be trying to determine what roles the system has. I do not understand the point of having an opaque error message in the case of a privileged user executing SET DEFAULT ROLE for a different unprivileged user--especially if that privileged user has SELECT privileges for the mysql.global_priv or mysql.user table. Is the SET DEFAULT ROLE statement even defined by the SQL standard? I thought it was an extension to the standard. | |||||||||||||||||||||
| Comment by Sergei Golubchik [ 2020-04-23 ] | |||||||||||||||||||||
|
SET DEFAULT ROLE is not standard. The standard says (I presume, didn't check right now), that
should fail with "Invalid role specification" if it was not granted to the user. Independently from whether the role exists or not. | |||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-04-23 ] | |||||||||||||||||||||
|
So GeoffMontee we can confirm this issue and start working on implementing patch for set default role without granting
| |||||||||||||||||||||
| Comment by Sergei Golubchik [ 2020-04-30 ] | |||||||||||||||||||||
|
Let's say, SET DEFAULT ROLE xxx [FOR yyy] should say "User yyy has not been granted a role xxx" if the current user (not the user yyy in the FOR clause) can see the role xxx. Otherwise it should be "Invalid role specification". In other words, it should not be possible to use SET DEFAULT ROLE to discover whether a specific role exist or not. | |||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-05-06 ] | |||||||||||||||||||||
|
Hi serg, I started looking into this. | |||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-05-07 ] | |||||||||||||||||||||
|
Hi serg here is a patch 4312f382b6f09d373d | |||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-05-14 ] | |||||||||||||||||||||
|
Hi serg here is new patch: 9a792dea7b. | |||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-05-15 ] | |||||||||||||||||||||
|
Hi serg, | |||||||||||||||||||||
| Comment by Vicențiu Ciorbaru [ 2020-05-27 ] | |||||||||||||||||||||
|
Looks good to me, ok to push. | |||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-05-28 ] | |||||||||||||||||||||
|
Because of some failing tests in buildbot , I've tested again locally all to be sure and to report here:
Will push, thanks. | |||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-05-28 ] | |||||||||||||||||||||
|
Pushed to 10.1 with 957cb7b7ba35518 |