[MDEV-13402] mysqld should create its PID file before dropping privileges Created: 2017-07-28 Updated: 2020-12-01 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Server |
| Affects Version/s: | 5.5, 10.0, 10.1, 10.2 |
| Fix Version/s: | 10.2 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Michael Orlitzky | Assignee: | Sergei Golubchik |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Summary The database server daemon should create its PID file before dropping Description The purpose of the PID file is to hold the PID of the running daemon, This is commonly exploitable by init scripts that are run as root and Exploitation There is only a risk of exploitation when some other user relies on |
| Comments |
| Comment by Sergei Golubchik [ 2017-08-02 ] | ||||||||||||||||||||||||||
|
PID file is created as a mysql user, which normally nobody has access to. It's the user that mysqld process is running at, so this user has full access to all tables in all databases. Which practically means that only root can modify PID file. | ||||||||||||||||||||||||||
| Comment by Michael Orlitzky [ 2017-08-02 ] | ||||||||||||||||||||||||||
|
The main risk is that the mysqld daemon runs on the network, and that a vulnerability in the daemon allows the mysql user to gain some root privileges – namely, the ability to send signals to root-owned process. On many installations, the mysql databases contain unimportant stuff like Wordpress data, but even partial root privileges could be a lot more dangerous. As an example, consider the following scenario: 1. I run "/etc/init.d/mysqld start" to start the daemon. 2. mysqld drops to the "mysql" user. 3. mysqld writes its PID file, now owned by the "mysql" user. 4. Someone compromises the daemon, which sits on the network. 5. The attacker is generally limited in what he can do because the 6. I run "/etc/init.d/mysqld stop" to stop the daemon while I investigate 7. The machine reboots, because I killed PID 1 (this is normally restricted to root). This is admittedly a minor risk because it requires someone to compromise the daemon already, but if they do, they shouldn't be able to gain any root privileges (like signalling root processes). | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2017-08-03 ] | ||||||||||||||||||||||||||
|
Yes, agree. If mysqld would have an RCE kind of a vulnerability, then, yes, it could be exploited like that to fool root to send a signal to any other process. | ||||||||||||||||||||||||||
| Comment by Michael Orlitzky [ 2018-04-22 ] | ||||||||||||||||||||||||||
|
Oracle assigned this CVE-2018-2773, and it was supposed to be fixed in their April 2018 critical patch update. However, I don't see that anything has changed w.r.t. the PID file handling. I've notified them via email. | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2018-04-22 ] | ||||||||||||||||||||||||||
|
MySQL 5.5.60 has this commit:
I'm sorry, but I don't see how it is MySQL vulnerability if one of the path | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2018-04-22 ] | ||||||||||||||||||||||||||
|
By the way, thanks for the CVE id. In April 2018 CPU CVE-2018-2773 is attributed to you (mjo) and is listed as having
How's that "Client program", I wonder. And how can it affect availability of MySQL Server... | ||||||||||||||||||||||||||
| Comment by Michael Orlitzky [ 2018-04-22 ] | ||||||||||||||||||||||||||
|
Ah, thanks. My original report had nothing to do with world-writable directories... makes you wonder =) | ||||||||||||||||||||||||||
| Comment by Tomas Hoger [ 2018-10-31 ] | ||||||||||||||||||||||||||
|
The original problem was fixed in October 2018 CPU as CVE-2018-3174. mjo is credited as reporter, and Client programs is again listed as the affected component. MySQL fix: Re-implemented MariaDB fix: mjo can you confirm CVE-2018-3174 really is for this issue? You either should have received the info from Oracle, or they should confirm the CVE id assignment if you ask. Thank you! | ||||||||||||||||||||||||||
| Comment by Michael Orlitzky [ 2018-10-31 ] | ||||||||||||||||||||||||||
|
It's not really fixed, but I've given up. The fix that they shipped is to use
in the init scripts that are shipped with MySQL. It's not a good fix: 1. It doesn't address the design flaw... why is the PID file being created after dropping privileges in the first place? The sole purpose of the PID file is to aid SysV-style init scripts (if you're also using it as e.g. a lockfile: don't do that). There's no cross-platform way to drop privileges in an init script, so they all kill the process as root. Thus, the PID file should be root-owned. I've already explained the issue to Oracle like 5 times and they don't get it. They go silent for 6 months and then come back with something like a hardcoded "su mysql" command that only works on Redhat. |