GHSA-3F6P-5WW8-9RCR

GHSA-3F6P-5WW8-9RCR is a high-severity security vulnerability in mysql2 (npm), affecting versions < 3.22.0. It is fixed in 3.22.0.

Does this CVE actually affect you?

Kodem shows which CVEs are reachable and running in your applications, so you fix what's exploitable, not just what's listed.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Runtime intelligence, not another scanner.

Summary

MySQL2: Auth Plugin Downgrade to mysqlclearpassword Leaks Plaintext Credentials

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.

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

Affected versions

mysql2 (< 3.22.0)

Security releases

mysql2 → 3.22.0 (npm)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

Already deployed Kodem?

See it in your environmentNew to Kodem? Get a demo →

Remediation advice

Remove mysql_clear_password from standardAuthPlugins, or add a guard requiring TLS/unix socket before allowing cleartext auth.

Frequently Asked Questions

  1. What is GHSA-3F6P-5WW8-9RCR? GHSA-3F6P-5WW8-9RCR is a high-severity security vulnerability in mysql2 (npm), affecting versions < 3.22.0. It is fixed in 3.22.0.
  2. Which versions of mysql2 are affected by GHSA-3F6P-5WW8-9RCR? mysql2 (npm) versions < 3.22.0 is affected.
  3. Is there a fix for GHSA-3F6P-5WW8-9RCR? Yes. GHSA-3F6P-5WW8-9RCR is fixed in 3.22.0. Upgrade to this version or later.
  4. Is GHSA-3F6P-5WW8-9RCR exploitable, and should I be worried? Whether GHSA-3F6P-5WW8-9RCR is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  5. What actually determines whether GHSA-3F6P-5WW8-9RCR is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  6. How do I fix GHSA-3F6P-5WW8-9RCR? Upgrade mysql2 to 3.22.0 or later.

Other vulnerabilities in mysql2

Stop the waste.
Protect your environment with Kodem.