HighGHSA-3f6p-5ww8-9rcr

MySQL2: Auth Plugin Downgrade to mysql_clear_password Leaks Plaintext Credentials

Published 1 Sept 2026 · Updated 10 Sept 2026

Is your project on an affected mysql2?

Private repo? Upload its lockfile instead, or connect GitHub to check every repo.

Affected package

Affected
<3.22.0
Fixed in
3.22.0
Update to the fixed version for your release line, for example:npm install mysql2@3.22.0

Details

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

1. Attacker operates rogue MySQL server or performs MITM 2. Server advertises caching_sha2_password in handshake 3. Client sends hashed auth response 4. Server replies with AuthSwitchRequest to mysql_clear_password 5. Client sends password in plaintext 6. 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

Is GHSA-3f6p-5ww8-9rcr in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected mysql2, and gives you the command that fixes it.

More advisories for mysql2

  • MediumGHSA-rgwj-5xj2-c3m3MySQL2: Unbounded zlib inflate in compressed MySQL protocol handler allows decompression-bomb DoS · 31 Aug 2026
  • HighCVE-2024-21512mysql2 vulnerable to Prototype Pollution · 30 May 2024
  • CriticalCVE-2024-21511MySQL2 for Node Arbitrary Code Injection · 23 Apr 2024
  • CriticalCVE-2024-21508mysql2 Remote Code Execution (RCE) via the readCodeFor function · 11 Apr 2024
  • MediumCVE-2024-21509mysql2 vulnerable to Prototype Poisoning · 10 Apr 2024
  • MediumCVE-2024-21507mysql2 cache poisoning vulnerability · 10 Apr 2024
mysql2 security overview

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.