If you have ever built a website, chances are you took care of security. Securing web applications does have its own caveats though – did you take care of the security of the database? In this post we will look at the options that can make MySQL perform at the very best of its ability security-wise. Keep in mind that this is not a very comprehensive guide (certain topics such as backup security etc. will not be touched) and some of the aspects discussed here are not even limited to MySQL, but it should provide some insight into the security of this relational database management system.
MySQL uses security-based Access Control Lists (ACLs) for all operations that users attempt to perform – that’s why accounts are one of the key parts of securing it. To keep your MySQL accounts secure, follow these steps:
mysql -u user -ppassword db_name
ps
, for example, displays information about running processes.-p
without the actual password (you will be prompted for the password afterwards), but there’s a way to avoid the password being provided in such a way altogether – on Unix, you can provide your password in a my.cnf
file (different files can also be used):[client]
password=password
--defaults-file
option specifying the full path to the file:mysql --defaults-file=/var/lib/mysql/my.cnf
root
user of the system – if you do so, any user with the FILE
privilege could create or modify any files on the server as root
.root
user access to the user table in the mysql
database.PROCESS
or SUPER
privileges to everyone. To read more about GRANT
and SUPER
privileges, take a look at the MySQL documentation.max_user_connections
variable in mysqld
.However, the security of MySQL does not end with securing MySQL accounts. The following things should also not be ignored:
GRANT
and REVOKE
statements to give and take away privileges from MySQL users, only grant as much privileges as absolutely necessary and never grant them to all of the hosts – regularly check which accounts have access to what using the SHOW GRANTS
statement and REVOKE
privileges that are not necessary.binlog_encryption
is set to ON
.secure_file_priv
variable to a directory where SELECT
writes can run safely – by doing so you will avoid the scenario of a user writing executable code to a file in the plugin directory using SELECT … INTO DUMPFILE
.In order to ensure the security of your MySQL installation you have to take some steps that are not limited to MySQL and can be applied to pretty much all kinds of software. These steps include requiring all MySQL accounts to have a password, not providing the MySQL password over the command line, avoiding to grant far-reaching privileges etc.
If you’ve followed all (or most) of the steps outlined above, your database should be well on the way to a more secure future.
This blog will walk you through some lessons for conference speakers who speak remotely no…
Insecure data storage is the second vulnerability in the OWASP Mobile Top 10 list. Insecure…
The improper platform usage vulnerability is the first vulnerability in the OWASP Mobile Top 10.…
If you ever heard of web application security, you probably heard of OWASP. And if…
It's November. For some developers it's just an ordinary month - for some of them…
You noticed your keyboard has dirt, some keys are stuck, some keys are not registering…