GHSA-3f6p-5ww8-9rcr: MySQL2 Auth Plugin Downgrade To Mysql_clear_password Vulnerability

HIGH
CWE-522
Published
Advisory Summary

GHSA-3f6p-5ww8-9rcr is a HIGH auth plugin downgrade to mysql_clear_password vulnerability (CWE-522: Insufficiently Protected Credentials) affecting MySQL2 libraries in the npm ecosystem. The issue involves auth plugin downgrade to mysql_clear_password leaks plaintext credentials. Remediation is available by upgrading affected packages to version 3.22.0.

GHSA-3f6p-5ww8-9rcr at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-3f6p-5ww8-9rcr
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-522: Insufficiently Protected Credentials
Affected Product MySQL2
Package Ecosystem npm
Published Date
Last Updated

How to Fix GHSA-3f6p-5ww8-9rcr

To remediate this vulnerability, upgrade all affected MySQL2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

mysql2 fixed: 3.22.0
npm install mysql2@3.22.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls mysql2

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-3f6p-5ww8-9rcr, inspect your project dependencies using npm:

npm ls mysql2

Analyze the terminal output to locate any version of MySQL2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.22.0), your application is affected.

Note: The npm ls mysql2 command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-522: Insufficiently Protected Credentials, where the product transmits or stores authentication credentials, but it uses an insecure method that is susceptible to unauthorized interception and/or retrieval. In MySQL2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## 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

GHSA-3f6p-5ww8-9rcr Affected MySQL2 Versions

1 component(s)
Fixed Versions:
3.22.0
Product / Package Ecosystem Affected Versions Fixed Version
mysql2
npm
< 3.22.0
3.22.0

References

Frequently Asked Questions

What is GHSA-3f6p-5ww8-9rcr?
GHSA-3f6p-5ww8-9rcr is a security vulnerability in MySQL2 involving Auth Plugin Downgrade to mysql_clear_password Leaks Plaintext Credentials under CWE-522: Insufficiently Protected Credentials.
Which MySQL2 versions are affected?
Affected versions include releases prior to 3.22.0 across affected packages: mysql2.
What version fixes GHSA-3f6p-5ww8-9rcr?
Upgrading to 3.22.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is mysql2 affected?
Yes, mysql2 is affected in releases prior to 3.22.0. Upgrade your dependency to 3.22.0 or later.
What CWE is associated with GHSA-3f6p-5ww8-9rcr?
GHSA-3f6p-5ww8-9rcr is classified under CWE-522: Insufficiently Protected Credentials (The product transmits or stores authentication credentials, but it uses an insecure method that is susceptible to unauthorized interception and/or retrieval.).
How can I check npm dependencies for GHSA-3f6p-5ww8-9rcr?
Run the dependency tree command: 'npm ls mysql2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-3f6p-5ww8-9rcr",
  "modified" : "2026-09-01T16:40:34Z",
  "published" : "2026-09-01T16:40:34Z",
  "aliases" : [ ],
  "summary" : "MySQL2: Auth Plugin Downgrade to mysql_clear_password Leaks Plaintext Credentials",
  "details" : "## 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",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "mysql2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.22.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/sidorares/node-mysql2/security/advisories/GHSA-3f6p-5ww8-9rcr"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sidorares/node-mysql2/issues/1617"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sidorares/node-mysql2/pull/4236"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sidorares/node-mysql2/commit/884bec56288d827939d0dd3f1f4ae476fbc8dbeb"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sidorares/node-mysql2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sidorares/node-mysql2/releases/tag/v3.22.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-522" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-01T16:40:34Z",
    "nvd_published_at" : null
  }
}