cbcvebase.
CVE-2016-6662
published 2016-09-20

CVE-2016-6662: Oracle MySQL through 5.5.52, 5.6.x through 5.6.33, and 5.7.x through 5.7.15; MariaDB before 5.5.51, 10.0.x before 10.0.27, and 10.1.x before 10.1.17; and…

PriorityP188critical9.8CVSS 3.0
AVNACLPRNUINSUCHIHAH
ITWEXPLOITVulnCheck KEV
Exploited in the wild
EPSS
67.73%
99.2th percentile
Oracle MySQL through 5.5.52, 5.6.x through 5.6.33, and 5.7.x through 5.7.15; MariaDB before 5.5.51, 10.0.x before 10.0.27, and 10.1.x before 10.1.17; and Percona Server before 5.5.51-38.1, 5.6.x before 5.6.32-78.0, and 5.7.x before 5.7.14-7 allow local users to create arbitrary configurations and bypass certain protection mechanisms by setting general_log_file to a my.cnf configuration. NOTE: this can be leveraged to execute arbitrary code with root privileges by setting malloc_lib. NOTE: the affected MySQL version information is from Oracle's October 2016 CPU. Oracle has not commented on third-party claims that the issue was silently patched in MySQL 5.5.52, 5.6.33, and 5.7.15.

Affected

32 ranges· showing 25
VendorProductVersion rangeFixed in
debiandebian_linux
mariadbmariadb>= 0 < 5.5.51-r05.5.51-r0
mariadbmariadb>= 0 < 10.1.17-r010.1.17-r0
mariadbmariadb>= 10.0.0 < 10.0.2710.0.27
mariadbmariadb>= 10.1.0 < 10.1.1710.1.17
mariadbmariadb>= 5.5.20 < 5.5.515.5.51
oraclemysql5.5.0 – 5.5.52
oraclemysql5.6.0 – 5.6.33
oraclemysql5.7.0 – 5.7.15
perconapercona_server>= 5.5 < 5.5.51-38.15.5.51-38.1
perconapercona_server>= 5.6 < 5.6.32-78.05.6.32-78.0
perconapercona_server>= 5.7 < 5.7.14-75.7.14-7
redhatenterprise_linux
redhatenterprise_linux_desktop
redhatenterprise_linux_desktop
redhatenterprise_linux_server
redhatenterprise_linux_server_aus
redhatenterprise_linux_server_aus
redhatenterprise_linux_server_aus
redhatenterprise_linux_server_eus
redhatenterprise_linux_server_eus
redhatenterprise_linux_server_eus
redhatenterprise_linux_server_eus
redhatenterprise_linux_server_tus
redhatenterprise_linux_server_tus

Detection & IOCsextracted from sources · hover to see the quote

port3306
port6033
path/var/lib/mysql/mysql_hookandroot_lib.so
filenamemysql_hookandroot_lib.so
path/var/lib/mysql/%s/poctable.TRG
path/tmp/privesclib.so
path/tmp/mysqlrootsh
path/etc/ld.so.preload
path/tmp/mysql_privesc_exploit
path/tmp/mysql_privesc_exploit/mysql_suid_shell.MYD
commandSELECT unhex(...) INTO DUMPFILE '/var/lib/mysql/...'
snort
alert tcp any any -> $HOME_NET 3306 (msg:"ET EXPLOIT Possible MySQL CVE-2016-6662 Attempt"; flow:established,to_server; content:"|03|"; offset:4; content:"unhex"; nocase; distance:0; content:"67656e6572616c5f6c6f675f66696c65"; distance:0; nocase; content:"2e636e66"; nocase; content:"6e6d616c6c6f635f6c6962"; reference:cve,2016-6662; reference:url,legalhackers.com/advisories/MySQL-Exploit-Remote-Root-Code-Execution-Privesc-CVE-2016-6662.html; classtype:attempted-admin; sid:2023201; rev:1; metadata:affected_product MySQL, attack_target Server, created_at 2016_09_13, cve CVE_2016_6662, deployment Datacenter, confidence Medium, signature_severity Major, updated_at 2019_07_26;)
bytes
67656e6572616c5f6c6f675f66696c65
bytes
2e636e66
bytes
6e6d616c6c6f635f6c6962
  • Detect MySQL traffic on port 3306 containing 'unhex' combined with hex-encoded strings for 'general_log_file' (67656e6572616c5f6c6f675f66696c65), '.cnf' (2e636e66), and 'malloc_lib' (6e6d616c6c6f635f6c6962) — the core exploit write-to-config pattern.
  • Monitor for creation of or writes to /etc/ld.so.preload by the mysql user, which is the privilege escalation mechanism used by the exploit chain.
  • Detect presence of poctable.TRG trigger file written into MySQL data directory (/var/lib/mysql/<db>/poctable.TRG), which is used to inject the malloc_lib setting into my.cnf.
  • Monitor for mysql_hookandroot_lib.so or privesclib.so appearing in /var/lib/mysql/ or /tmp/, as these are the malicious shared libraries dropped by the exploit.
  • Watch for a netcat listener spawned on port 6033 (inverted MySQL port 3306) following MySQL restart, indicating successful remote root shell establishment.
  • Detect MySQL SQL statements that set general_log_file to a path ending in .cnf (e.g., my.cnf), which is the core config-injection technique.
  • ·Red Hat/CentOS default installs are partially mitigated: my.cnf in /etc is root-owned and not writable by the mysql user, blocking the published exploit vector.
  • ·On RHEL 7, mysqld_safe runs as the mysql user (not root), limiting exploit impact to code execution as the mysql system user rather than full root.
  • ·MySQL 5.1 on RHEL 6 does not support library preloading, completely preventing the malloc_lib remote attack vector.
  • ·Granting FILE privilege to non-administrative database users (e.g., web app accounts) enables exploitation; restrict FILE privilege and use secure_file_priv to limit file write locations.

CVSS provenance

nvdv3.09.8CRITICALCVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
nvdv2.010.0CRITICALAV:N/AC:L/Au:N/C:C/I:C/A:C
osv9.8CRITICAL
vulncheck9.8CRITICAL
vendor_redhat9.8CRITICAL
CVEs like this are exactly what “Exploited This Week” covers.

Every Monday: what got weaponized or added to CISA KEV in the last seven days — each CVE cross-linked to its PoC, Nuclei template, and detection rule. Free, one email a week, unsubscribe in one click.