{"id":"GHSA-3f6p-5ww8-9rcr","aliases":["GHSA-3f6p-5ww8-9rcr"],"related":[],"kind":"vulnerability","state":"published","title":"MySQL2: Auth Plugin Downgrade to mysql_clear_password Leaks Plaintext Credentials","summary":"## Summary\n\nA rogue MySQL server (or MITM) can force mysql2 to send credentials in **plaintext** by requesting an auth switch to `mysql_clear_password`. The driver complies without verifying that TLS is active.\n\n## Details\n\n`mysql_clear_password` is registered as a default standard plugin in `lib/commands/auth_switch.js` (line 21). When a server sends an AuthSwitchRequest (0xFE) requesting `mysql_clear_password`, the driver executes it without checking for TLS. The plugin (`lib/auth_plugins/mysql_clear_password.js`) returns `Buffer.from(password + '\\0')`.\n\nNote: `caching_sha2_password` plugin DOES check for SSL before sending cleartext (line 77). But `mysql_clear_password` has no such guard.\n\n## Attack Scenario\n\n1. Attacker operates rogue MySQL server or performs MITM\n2. Server advertises `caching_sha2_password` in handshake\n3. Client sends hashed auth response\n4. Server replies with AuthSwitchRequest to `mysql_clear_password`\n5. Client sends password in plaintext\n6. Attacker captures plaintext password\n\n## PoC\n\nRogue MySQL server (Node.js, ~80 lines) that captures plaintext passwords from mysql2 clients. Tested against mysql2 3.20.0. Full PoC available on request.\n\n## Suggested Fix\n\nRemove `mysql_clear_password` from `standardAuthPlugins`, or add a guard requiring TLS/unix socket before allowing cleartext auth.\n\n## Impact\n\n- mysql2: 9M weekly downloads\n- Any application connecting without TLS is vulnerable to credential theft\n- Cloud environments with untrusted network paths are especially at risk","summaryFormat":"markdown","summarySource":"ghsa","descriptions":[{"lang":"en","text":"## Summary\n\nA rogue MySQL server (or MITM) can force mysql2 to send credentials in **plaintext** by requesting an auth switch to `mysql_clear_password`. The driver complies without verifying that TLS is active.\n\n## Details\n\n`mysql_clear_password` is registered as a default standard plugin in `lib/commands/auth_switch.js` (line 21). When a server sends an AuthSwitchRequest (0xFE) requesting `mysql_clear_password`, the driver executes it without checking for TLS. The plugin (`lib/auth_plugins/mysql_clear_password.js`) returns `Buffer.from(password + '\\0')`.\n\nNote: `caching_sha2_password` plugin DOES check for SSL before sending cleartext (line 77). But `mysql_clear_password` has no such guard.\n\n## Attack Scenario\n\n1. Attacker operates rogue MySQL server or performs MITM\n2. Server advertises `caching_sha2_password` in handshake\n3. Client sends hashed auth response\n4. Server replies with AuthSwitchRequest to `mysql_clear_password`\n5. Client sends password in plaintext\n6. Attacker captures plaintext password\n\n## PoC\n\nRogue MySQL server (Node.js, ~80 lines) that captures plaintext passwords from mysql2 clients. Tested against mysql2 3.20.0. Full PoC available on request.\n\n## Suggested Fix\n\nRemove `mysql_clear_password` from `standardAuthPlugins`, or add a guard requiring TLS/unix socket before allowing cleartext auth.\n\n## Impact\n\n- mysql2: 9M weekly downloads\n- Any application connecting without TLS is vulnerable to credential theft\n- Cloud environments with untrusted network paths are especially at risk","format":"markdown","source":"ghsa"}],"published":"2026-09-01T16:40:34.000Z","modified":"2026-09-10T03:51:14.984Z","severity":{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N","rating":"HIGH"},"severities":[{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N","rating":"HIGH"}],"cwes":["CWE-522"],"affected":[{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"3.22.0"}],"ecosystem":"npm","package":"mysql2","purl":"pkg:npm/mysql2","source":"ghsa"}],"references":[{"url":"https://github.com/sidorares/node-mysql2/security/advisories/GHSA-3f6p-5ww8-9rcr","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/sidorares/node-mysql2/issues/1617","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/sidorares/node-mysql2/pull/4236","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/sidorares/node-mysql2/commit/884bec56288d827939d0dd3f1f4ae476fbc8dbeb","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/sidorares/node-mysql2","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/sidorares/node-mysql2/releases/tag/v3.22.0","tags":["web"],"sources":["ghsa"]}],"credits":[],"sources":[{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3f6p-5ww8-9rcr","url":"https://github.com/advisories/GHSA-3f6p-5ww8-9rcr","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:14.984Z"}],"updatedAt":"2026-11-25T22:56:43.801Z"}