GHSA-3f6p-5ww8-9rcr: MySQL2: Auth Plugin Downgrade to mysql_clear_password Leaks Plaintext Credentials
Summary A rogue MySQL server (or MITM) can force mysql2 to send credentials in plaintext by requesting an auth switch to mysqlclearpassword. The driver complies without verifying that TLS is active. Details mysqlclearpassword is registered as a default standard plugin in lib/commands/authswitch.js (line 21).
Published Sep 1, 2026
Affected packages
mysql2
- Ecosystem
- npm
- Affected
- < 3.22.0
- Fixed in
- 3.22.0
- Check
npm ls mysql2
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
A 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.
Details
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').
Note: caching_sha2_password plugin DOES check for SSL before sending cleartext (line 77). But mysql_clear_password has no such guard.
Attack Scenario
- Attacker operates rogue MySQL server or performs MITM
- Server advertises
caching_sha2_passwordin handshake - Client sends hashed auth response
- Server replies with AuthSwitchRequest to
mysql_clear_password - Client sends password in plaintext
- Attacker captures plaintext password
PoC
Rogue MySQL server (Node.js, ~80 lines) that captures plaintext passwords from mysql2 clients. Tested against mysql2 3.20.0. Full PoC available on request.
Suggested Fix
Remove mysql_clear_password from standardAuthPlugins, or add a guard requiring TLS/unix socket before allowing cleartext auth.
Impact
- mysql2: 9M weekly downloads
- Any application connecting without TLS is vulnerable to credential theft
- Cloud environments with untrusted network paths are especially at risk
References
- https://github.com/sidorares/node-mysql2/security/advisories/GHSA-3f6p-5ww8-9rcr
- https://github.com/sidorares/node-mysql2/issues/1617
- https://github.com/sidorares/node-mysql2/pull/4236
- https://github.com/sidorares/node-mysql2/commit/884bec56288d827939d0dd3f1f4ae476fbc8dbeb
- https://github.com/sidorares/node-mysql2/releases/tag/v3.22.0
- https://github.com/advisories/GHSA-3f6p-5ww8-9rcr
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More npm vulnerabilities
All npm entriesGHSA-rgwj-5xj2-c3m3
MySQL2: Unbounded zlib inflate in compressed MySQL protocol handler allows decompression-bomb DoS
medium5.9Aug 31, 2026CVE-2024-21512
mysql2 vulnerable to Prototype Pollution
high8.2May 30, 2024CVE-2024-21511
MySQL2 for Node Arbitrary Code Injection
critical9.8Apr 23, 2024CVE-2024-21508
mysql2 Remote Code Execution (RCE) via the readCodeFor function
critical9.8Apr 11, 2024CVE-2024-21507
mysql2 cache poisoning vulnerability
medium6.5Apr 10, 2024CVE-2024-21509
mysql2 vulnerable to Prototype Poisoning
medium6.5Apr 10, 2024
