MySQL Databases Subject to Password Verification Flaw
The flaw, reported this week, could allow an incorrect password to be verified as correct due to an error in the token calculation, according to Sergei Golubchik, security coordinator for MariaDB, in a posted statement. It could give remote attackers access the contents of the databases by bypassing the password authentication process in unpatched systems.
"When a user connects to MariaDB/MySQL, a token (SHA over a password and a random scramble string) is calculated and compared with the expected value," said Golubchik. "Because of incorrect casting, it might've happened that the token and the expected value were considered equal, even if the memcmp() returned a non-zero value. In this case MySQL/MariaDB would think that the password is correct, even while it is not. Because the protocol uses random strings, the probability of hitting this bug is about 1/256."
Golubchik explained that by using a legitimate username and repeating connection attempts with any password, hackers can gain access in seconds, making any password protection protocol in place "as good as nonexistent."
While a large majority of MariaDB and MySQL databases use the flawed code, HD Moore, Rapid7's CSO, said that only a few select systems running these databases are vulnerable to attack.
"It boils down to whether the memcmp() routine returns values outside of the unsigned character range," said Moore in a blog post. "According to Sergei, this is normally not the case, and the routine is normally compiled into the server as an inline function."
Those systems that have been confirmed to be vulnerable include Ubuntu Linux 64-bit, Debian unstable 64-bit 5.5.23-2, Fedora, Arch Linux and OpenSuSE 12.1 64-bit MySQL 5.5.23-log.
Official builds from MySQL and MariaDB on Windows, and versions found on Red Hat Enterprise Linux 4, 5 and 6, are all safe from the flaw. As for the vulnerable builds, once MySQL patches 5.1.63 and 5.5.24 are applied, the systems should be secured, officials claim.
Moore has also provided a workaround for those who cannot patch.
"If you are responsible for a MySQL server that is currently exposed to the network unnecessarily, the easiest thing to do is to modify the my.cnf file in order to restrict access to the local system," Moore explained in his blog post. "Open my.cnf with the editor of your choice, find the section labeled [mysqld] and change (or add a new line to set) the 'bind-address' parameter to "127.0.0.1". Restart the MySQL service to apply this setting."