In this continuing series of posts of fundamental DBA security tasks, we will look at passwords again, the good, the bad and the outright ugly.
This group of tasks will help you find insecure users with poor passwords and provide recommendations on how to fix them.
Note:
For most new installations a lot of the checks are going to return nothing.
If however you are running an older version of MySQL say for that legacy app written back in 2007, then these kind of security problems can still occur.
Task 3: Find users with the same password as username
The problem:
The first password to guess is the username. Can it be any easier to hack your db…
SQL to check:
SELECT user,authentication_string,host FROM mysql.user WHERE authentication_string=CONCAT('*', UPPER(SHA1(UNHEX(SHA1(user)))));
The Fix:
- Discuss with the owner of the application/database.
- Change the password to a strong password (minimum length 16, Uppercase, numbers and special characters as well) using ALTER USER or SET PASSWORD FOR.
Task 4: Find users without a password set
The problem:
Users without passwords are a joy for hackers (external or internal). The easiest password to guess is no password.
SQL to check:
SELECT User,host FROM mysql.user WHERE authentication_string='';
The Fix:
- Discuss with the owner of the application/database.
- Add a strong password (minimum length 16, Uppercase, numbers and special characters as well) using ALTER USER or SET PASSWORD FOR.
Task 5: Set the password expiry policy for non-application users to 90 days.
The problem:
You know that posted note with “Str0ngP@55w0rd!” you stuck on your monitor 3 years ago which you are still using and everyone knows… yeh that is a problem.
Changing passwords every 90 days is good security practice.
This is the reason your LAN/LDAP/corporate login password prompts you after 90 days.
The SQL to check:
SELECT user, host, password_lifetime from mysql.user where password_lifetime IS NULL;
The Fix:
- Add a password expire interval to non-application users.
Example: For username, SecureSam
ALTER USER 'securesam'@'localhost' PASSWORD EXPIRE INTERVAL 90 DAY;
How to apply the fixes:
- Prepare a security audit report/review.
- Present or email to stakeholders (developers, reporting users, managers)
- Prepare a maintenance plan and gain approval to change.
- Organize maintenance window with specific time and date and gain approval for change.
- Follow the maintenance plan, which will be something like this
– Announce start of maintenance window in your chat/communication channel.
– run the fixes you have listed in the maintenance plan.
– Get developers or report users to test to make sure their application works
– Confirm good.
– Announce the end of the maintenance window in your chat/communication channel.