Vulnerability record · CVE-2012-2122 · published 26 June 2012
CVE-2012-2122: MySQL and MariaDB authentication bypass via repeated wrong password
Oracle · Mysql
Oracle MySQL and MariaDB compare password tokens with memcmp in certain environments, and the return value is not checked properly. Repeatedly authenticating with the same incorrect password can eventually make the token comparison succeed, bypassing authentication entirely.
Description
sql/password.c in Oracle MySQL 5.1.x before 5.1.63, 5.5.x before 5.5.24, and 5.6.x before 5.6.6, and MariaDB 5.1.x before 5.1.62, 5.2.x before 5.2.12, 5.3.x before 5.3.6, and 5.5.x before 5.5.23, when running in certain environments with certain implementations of the memcmp function, allows remote attackers to bypass authentication by repeatedly authenticating with the same incorrect password, which eventually causes a token comparison to succeed due to an improperly-checked return value.
AV:N/AC:H/Au:N/C:P/I:P/A:P
Automated analysis
high priorityPublic exploit code exists and EPSS is very high, but the CVSS 2.0 base score is only 5.1 and exploitation requires a specific memcmp environment.
What it is
Oracle MySQL and MariaDB compare password tokens with memcmp in certain environments, and the return value is not checked properly. Repeatedly authenticating with the same incorrect password can eventually make the token comparison succeed, bypassing authentication entirely.
Impact
An attacker gains authenticated access to the database server without valid credentials, potentially reading or modifying data and executing SQL with the privileges of the targeted account.
Attack surface
Reachable remotely over the MySQL protocol (AV:N) with no authentication required (Au:N) and no user interaction. Exploitation depends on the target running in an environment with a memcmp implementation that triggers the flawed comparison (AC:H).
Exploitation
CISA KEV does not list it, but EPSS is 0.965 (99.879th percentile) and multiple references are tagged Exploit, including Exploit-DB and Metasploit coverage, indicating public exploit code exists.
What to do
- Upgrade MySQL to 5.1.63, 5.5.24, or 5.6.6 and later, or MariaDB to 5.1.62, 5.2.12, 5.3.6, or 5.5.23 and later.
- If immediate patching is not possible, restrict network access to the database port to trusted hosts only.
- Disable or tightly control remote root and other privileged account logins from untrusted networks.
- Monitor for and block repeated failed authentication attempts from the same source.
- Apply vendor advisories for OpenSUSE and Gentoo where the affected packages are used.
Detection
- Alert on bursts of failed authentication attempts from a single source followed by a successful login.
- Review MySQL/MariaDB authentication logs for repeated identical incorrect-password attempts.
- Hunt for known exploit tooling or Metasploit module traffic against the database port.
- Baseline and monitor successful logins from unexpected hosts or accounts.
This assessment is produced automatically and is not human-reviewed. Verify against the vendor advisory before acting on it.
Affected products
2 vulnerable configurations from NVD's CPE data, grouped by vendor and product.
References
Track CVE-2012-2122 inside VULONE
Watch it alongside the ransomware crews, C2 infrastructure and forum chatter that reference it, query it through the API and pull it into your SIEM over TAXII.
Related vulnerabilities
Same products first, then exploited flaws of the same weakness class.
Source: NIST National Vulnerability Database (record CVE-2012-2122), CISA KEV, FIRST EPSS (scores of 2026-09-25). This page is refreshed as NVD updates the record.