Details
-
New Feature
-
Status: In Testing (View Workflow)
-
Critical
-
Resolution: Unresolved
Description
SET USER privilege gives the ability to specify an arbitrary definer for views and stored routines. That basically means that a SET USER user can execute commands as any other user.
To make this functionality more convenient to use, the server could allow SET USER user to "sudo" directly into any other user without authentication.
We'll implement a standard SET SESSION AUTHORIZATION statement that will do that. It should allow everything that is achievable in SP with an arbitrary definer. In particular, it'll bypass account lock, expired password, authentication, REQUIRE SSL checks, etc.
The standard syntax is:
<set session user identifier statement> ::=
|
SET SESSION AUTHORIZATION <value specification>
|
The important part of the specs is
1) If a <set session user identifier statement> is executed and an SQL-transaction is currently active, then an exception condition is raised: invalid transaction state — active SQL-transaction.
(it's sqlstate 25001), and
4) If V is not equal to the current value of the SQL-session user identifier of the current SQL-session context, then the restrictions on the permissible values for V are implementation-defined.
That is, one can always set session authorization to themselves, and it's implementation-defined when one can change to another user. We'll define it as "if granted SET USER privilege"
It won't work inside transactions (standard specs), won't work in PS and in SP (because changing the user resets all PS and SP in the connection, so none can survive this statement)
Attachments
Issue Links
- blocks
-
MXS-5130 Support for PARSEC auth plugin from MDEV-32618
-
- Closed
-
-
MXS-5524 Use new SESSION AUTHORIZATION feature from 12.0
-
- Closed
-
- causes
-
MDEV-36384 Command-line client keeps showing database in prompt after changing user
-
- Open
-
-
MDEV-36395 SET SESSION AUTHORIZATION is written in server audit log under the new user
-
- Open
-
-
MDEV-36399 SET SESSION AUTHORIZATION allows an unrpivileged user to bypass resource limits
-
- Closed
-
-
MDEV-36401 Access denied errors produced by SET SESSION AUTHORIZATION not reflected in status values
-
- Closed
-
-
MDEV-36415 ER_NO_SUCH_USER for empty user name in SET SESSION AUTHORIZATION looks inconsistent
-
- Open
-
-
MDEV-36430 User cannot SET SESSION AUTHORIZATION into its current_user if the host is a wildcard
-
- Open
-
-
MDEV-36431 User identified via proxy cannot do SET SESSION AUTHORIZATION into itself
-
- Open
-
-
MDEV-36589 Garbage written into slow log for SET SESSION AUTHORIZATION command, assertion fails
-
- Closed
-
- is blocked by
-
MDEV-21743 Split up SUPER privilege to smaller privileges
-
- Closed
-
- relates to
-
MDEV-36396 MTR view protocol does not notice a change of user
-
- Open
-
-
MDEV-36405 Session tracking does not report changes from COM_CHANGE_USER
-
- Open
-
-
MDEV-34386 Make SQL proxy authentication easier and safer
-
- Open
-
One thing that I think might be a minor issue in using this as a "proxy authentication mechanism" is the connection attributes. I assume that the SET SESSION AUTHORIZATION <user> will reset those as well. They are often quite useful for debugging complex topologies where client applications are connecting through a proxy like MaxScale. Otherwise figuring out the real source IP is quite difficult, especially as proxy protocol would not always be usable in this sort of a scenario.