2

Having MySQL using auth_socket as default authentication mechanism for the root user scares me, so I change it to password authentication with rigid controls on password quality and documentation.

If a user manage to have root access to this linux machine that has a MySQL database but doesn't have the password to log in into the service, he still can copy/modify/destroy the data?

1
  • 1
    Yes, root can do pretty much anything. Commented Jul 10, 2018 at 14:48

2 Answers 2

3

The root user will have access to, at the very least, the database file that is stored on the computer. This means reguardless of how the service is configured they can copy and delete the data. If your databse is not encrypted by some means he will be able to modify the data too.

4
  • And even if it's encrypted, the encryption key is stored on the computer and root have access to every single file.
    – ThoriumBR
    Commented Jul 10, 2018 at 15:03
  • @ThoriumBR that would be most cases, but he could use a key not from the machine too.
    – rhymsy
    Commented Jul 11, 2018 at 16:11
  • @rhymsy That key could be read from system memory in the decryption process. Even if it is on a different machine, you still need the key to read the data. Commented Jul 12, 2018 at 13:59
  • @Francisco Zanatta, yes, I hadn't thought of that. Thanks
    – rhymsy
    Commented Jul 12, 2018 at 14:01
2

You obviously know the answer now: yes. However, it is even easier than it seems. As a root user you can actually reset the root password for a MySQL installation. I've had to do this before: I had a brand new installation and I forgot to record the MySQL root password. It took less than 5 minutes to reset the root password in MySQL, and I had full access to the MySQL database after doing so - it made no changes to anything in MySQL at all (other than the root password).

Of course even that might not matter. If your database server and application server are one machine then a smart attacker can just look at your application, see how it is authenticating (typically as simple as reading credentials out of source code or an environment configuration), and login like that.

It would be very difficult to come up with a way to lock the root user out of MySQL, and if you managed to do it you would probably be more likely to hurt yourself than a malicious user. In general if an unauthorized user gains root access to your server, you're pretty much hosed.

4
  • That was also very helpful. It seems the only hope is to restrict access to the root user. Commented Jul 11, 2018 at 12:26
  • @FranciscoZanatta If you mean restrict other people's access to the root user then that is definitely the right idea - the best way to protect root is by making sure to not use root by default - just use a standard user account. What's not clear is your exact concern. Again, root has full access to everything, so the goal is to keep attackers out of root in the first place - not to keep root out of anything. What is your specific concern, or what are you trying to do Commented Jul 11, 2018 at 14:22
  • I would like to have MySQL data safe even with the llinux root account compromised. That seems to be impossible, given that root has access to the data files MySQL writes to. I still believe that using password authentication for the root MySQL user is better than using auth_socket authentication that ships with MySQL server installation in Ubuntu and possibly other Debian based systems. Do you have thougths on that? Commented Jul 11, 2018 at 21:04
  • I really doubt there is anyway to keep MySQL data safe from a root user. The example I gave shows how easy it is for the root user to change the MySQL password, specifically with password authentication. Even if you came up with some sort of way to encrypt your MySQL data files, root could still read the system memory to find results there, or replace the MySQL binary with one that auto dumps databases, etc... There is no point in trying to protected MySQL from root. You should focus on protecting root from the world. Commented Jul 12, 2018 at 9:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .