A security flaw in MySQL authentication. Is your system vulnerable?

A few days ago Sergei Golubchik of Monty Program sent an e-mail to the Open Source Security mailing list informing about a security vulnerability in MySQL authentication system. Under certain circumstances a remote attacker may easily gain access to MySQL database as any user and all they need to know is a valid user name (e.g. root user exists in nearly all installations). The problem has only been addressed in the most recent database versions.

The full details are covered in Sergei’s post linked above. Not all MySQL releases are affected as the cause appears to be related to the build environment and the options used in the binary build process. For instance binaries distributed by Oracle appear to be safe as well as those available from RedHat’s repository.

We encourage you to test this against your database if you’re running MySQL versions up to 5.1.61 or 5.5.22 to see whether you need to upgrade or not. The test can be done with a simple line that can be run in bash:

for i in `seq 1 2000`; do mysql -u root --password=somerandomcharacters -h 127.0.0.1 ; done

Remember that following even the basic security practices can often save you from getting your database hacked after a new vulnerability is published:

  • never let MySQL to listen on a network interface accessible from the internet (set bind-address in my.cnf if necessary)
  • build firewall rules to filter out any addresses that do not require database access
  • always create a new privileged MySQL user under a different name to replace the default root account and remove rootafterwards
  • remove testaccount that is installed by default
  • upgrade database as soon as possible after a new vulnerability is published
[MySQL Health Check]
About Thomas

LAMP consultant with 12+ years of experience in online media industry. Enthusiast of modern web technologies, networking and databases.

Comments

  1. My system (Mac OS 10.6) knows nothing about “seq”.

    What does it do? Is there another way to do it? I think I can guess, but…

  2. Jan,

    You can do it with bash:

    for i in {1.. 2000}; do mysql -u root --password=somerandomcharacters -h 127.0.0.1 ; done

    or use native command `jot` which is pretty much the same as `seq`.

    for i in `jot - 1 2000`; do mysql -u root --password=somerandomcharacters -h 127.0.0.1 ; done

  3. Joseph says:

    Looks like some Percona binaries are affected (Debian ones).

Speak Your Mind

*