SpiderLabs Blog

MySQL/MariaDB: Trade You a Banana for Root Access? | Trustwave | SpiderLabs | Trustwave

Written by Jonathan Claudius | Jun 12, 2012 5:00:00 AM

Summary

Over the weekend, an Authentication Bypass Vulnerability for MySQL and MariaDB (CVE-2012-2122) was released by Sergei Golubchik of Monty Program Ab (link). The vulnerability is trivial to exploit and has the potential to expose root user access to the database instance if the database service is exposed. As it happens, the binary packages provided by some popular Linux variants including Ubuntu, OpenSuSE, Fedora and others are affected by this issue.

In this post, we will cover exploiting the vulnerability as well as what you should do if you are running/evaluating vulnerable MySQL or MariaDB services.

Exploiting the MySQL Vulnerability

I spent some time this morning to confirm the vulnerability on a vanilla Ubuntu 12.04 LTS Linux 64-bit VM. I downloaded the latest Ubuntu 64-bit version, installed mysql-server using apt-get and here is what I came up with…

Successful MySQL Login (root/toor on localhost)

Failed MySQL Login (root/bananas on localhost)

Successful MySQL Auth Bypass (root/bananas on localhost)


Note:
The proof of concept above was based on info provided in Metasploit blog posted here earlier today.


What You Should Do?

Please note that at the time of this writing, the community is still in the process of identifying specific OS variants and their associated binary packages and compile options that are affected by this vulnerability. As a safety precaution, it is encouraged that all MySQL and MariaDB instances be tested for the existance of the vulnerability. Additionally, both vendors have addressed this vulnerability so it is highly recommended that the associated patches are applied as soon as possible and that access to the database service and users should be restricted by IP.

Additionally, for penetration testers and security assessors, you might want to jump on this now so you help your customers/clients confirm their exposure and/or mitigate this risk. The above example will work against remote instances by simply changing the value of the ip supplied to the "-h" (host) switch.