MySQL, MariaDB Flaw Allows Root Access with Wrong Passwords
A critical vulnerability in the MySQL and MariaDB database servers allows attackers to gain root access with wrong passwords – if they are persistent enough. This flaw affects one of the most popular database systems in the world and can result in significant data loss when successfully exploited. To add insult to injury, the exploitation technique is a no-brainer, as all the attacker has to do is keep trying passwords.
The responsibility for this major failure seems to reside in the fact that the server expects the memcmp() function to return a value between -127 and 127. However, some server setups often return a value outside the boundary, which confuses the routines that compare the entered password with its hashed value. This, in turn, validates the wrong password against the stored hash. Shortly put, there is a 1 in 256 chance that any password would be accepted as valid.
“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,” wrote Sergei Golubchik in a post on the OS-Sec mailing list. “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.”
MySQL database servers are used in nearly all areas, ranging from personal and commercial to the military. Fortunately though, some Linux distributions bind the MySQL daemon to localhost, preventing remote access to the service. This means that an attacker won’t be able to access the server without access to the machine.