Every CVESearch/Get API key

GHSA-3f6p-5ww8-9rcr

MySQL2: Auth Plugin Downgrade to mysql_clear_password Leaks Plaintext Credentials

8.2 HighFix available

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

Attack profile

How easy it is to exploit

Attack vector
Network
Complexity
Low
Privileges needed
None
User interaction
None

What an attacker can affect

Confidentiality
High
Integrity
None
Availability
None

What each source reports

GitHub Advisories Score used8.2

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 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
Record
GHSA-3f6p-5ww8-9rcr
CVSS 4.0
8.2 HighCVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N
Weakness
CWE-522
Updated
2026-11-02
GitHub AdvisoriesGHSA-rgwj-5xj2-c3m35.9

MySQL2: Unbounded zlib inflate in compressed MySQL protocol handler allows decompression-bomb DoS

Vulnerability Details

File: lib/compressed_protocol.js Line: 43 (zlib.inflate(body, (err, data) => { ... }) inside handleCompressedPacket)

Root Cause

When a connection is created with compress: true (and the server advertises CLIENT_COMPRESS), every incoming packet is unwrapped by handleCompressedPacket() in lib/compressed_protocol.js, which calls:

zlib.inflate(body, (err, data) => { ... });

No options object (in particular, no maxOutputLength) is passed. Node's zlib convenience methods default maxOutputLength to buffer.kMaxLength, which on this platform is Number.MAX_SAFE_INTEGER — i.e. effectively unbounded until the process runs out of memory. The 3-byte "length of payload before compression" field in the compressed-packet header is read (packet.readInt24()) but is only used to branch on !== 0; it is never used to cap or validate the actual inflate output size, and the real decompressed size is determined purely by the attacker-supplied deflate stream.

Because DEFLATE can reach compression ratios over 1000:1 for crafted repetitive input, an attacker who controls (or MITMs, on a non-TLS connection) the MySQL server endpoint can send a single small compressed packet that expands to gigabytes in the client's memory — a classic decompression-bomb / "zip bomb" applied to MySQL's client-compression protocol.

Attack Scenario

  1. Application connects with mysql2/mysql2/promise using compress: true (a documented option for reducing bandwidth, commonly used for cloud/WAN DB connections).
  2. The connection target is attacker-controlled or attacker-compromised, or an attacker MITMs a non-TLS connection.
  3. Right after authentication succeeds, the malicious endpoint sends one crafted compressed packet whose deflate stream is small on the wire (hundreds of KB) but decompresses to several GB.
  4. zlib.inflate() starts allocating memory for the full decompressed output with no ceiling.
  5. The Node.js process's RSS grows uncontrolled until OOM-kill or crash — no query needs to be issued by the client; the malicious packet alone is enough.

Impact

Denial of Service of the client application (process crash / OOM) — not the database itself. No authentication bypass or data exposure. Requires compress: true plus a malicious/compromised server or MITM position.

Vulnerable Code

function handleCompressedPacket(packet) {
  const connection = this;
  const deflatedLength = packet.readInt24();
  const body = packet.readBuffer();

  if (deflatedLength !== 0) {
    connection.inflateQueue.push((task) => {
      zlib.inflate(body, (err, data) => {
        if (err) {
          connection._handleNetworkError(err);
          return;
        }
        connection._bumpCompressedSequenceId(packet.numPackets);
        connection._inflatedPacketsParser.execute(data);
        task.done();
      });
    });
  } else {
    ...
  }
}

Recommended Fix

const MAX_INFLATED_PACKET_SIZE = 1 * 1024 * 1024 * 1024; // e.g. 1 GiB, ideally configurable

zlib.inflate(body, { maxOutputLength: MAX_INFLATED_PACKET_SIZE }, (err, data) => {
  if (err) {
    connection._handleNetworkError(err);
    return;
  }
  ...
});

maxOutputLength makes zlib.inflate abort with ERR_BUFFER_TOO_LARGE as soon as the decompressed size would exceed the cap, routing into the exact same (already-existing) err → connection._handleNetworkError(err) path, so no new error-handling logic is required.

Verification

Dynamically confirmed on v3.23.0 (HEAD) using a minimal rogue "MySQL server" built on node-mysql2's own server-mode helpers (mysql.createServer, Packets.Handshake, connection.writeOk()). The rogue server completes a real handshake advertising CLIENT_COMPRESS, then writes one raw compressed frame (509,604 bytes on the wire — a zlib deflate of 500 MB of zero bytes, ratio 1028.8:1) directly to the socket. A normal mysql.createConnection({ ..., compress: true })…

Record
GHSA-rgwj-5xj2-c3m3
CVSS 3.1
5.9 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H
Weakness
CWE-409
Updated
2026-11-02
OSV8.2

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 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
Record
GHSA-3f6p-5ww8-9rcr
CVSS 4.0
8.2 HighCVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N
Weakness
CWE-522
Updated
2026-11-02
OSVGHSA-rgwj-5xj2-c3m35.9

MySQL2: Unbounded zlib inflate in compressed MySQL protocol handler allows decompression-bomb DoS

Vulnerability Details

File: lib/compressed_protocol.js Line: 43 (zlib.inflate(body, (err, data) => { ... }) inside handleCompressedPacket)

Root Cause

When a connection is created with compress: true (and the server advertises CLIENT_COMPRESS), every incoming packet is unwrapped by handleCompressedPacket() in lib/compressed_protocol.js, which calls:

zlib.inflate(body, (err, data) => { ... });

No options object (in particular, no maxOutputLength) is passed. Node's zlib convenience methods default maxOutputLength to buffer.kMaxLength, which on this platform is Number.MAX_SAFE_INTEGER — i.e. effectively unbounded until the process runs out of memory. The 3-byte "length of payload before compression" field in the compressed-packet header is read (packet.readInt24()) but is only used to branch on !== 0; it is never used to cap or validate the actual inflate output size, and the real decompressed size is determined purely by the attacker-supplied deflate stream.

Because DEFLATE can reach compression ratios over 1000:1 for crafted repetitive input, an attacker who controls (or MITMs, on a non-TLS connection) the MySQL server endpoint can send a single small compressed packet that expands to gigabytes in the client's memory — a classic decompression-bomb / "zip bomb" applied to MySQL's client-compression protocol.

Attack Scenario

  1. Application connects with mysql2/mysql2/promise using compress: true (a documented option for reducing bandwidth, commonly used for cloud/WAN DB connections).
  2. The connection target is attacker-controlled or attacker-compromised, or an attacker MITMs a non-TLS connection.
  3. Right after authentication succeeds, the malicious endpoint sends one crafted compressed packet whose deflate stream is small on the wire (hundreds of KB) but decompresses to several GB.
  4. zlib.inflate() starts allocating memory for the full decompressed output with no ceiling.
  5. The Node.js process's RSS grows uncontrolled until OOM-kill or crash — no query needs to be issued by the client; the malicious packet alone is enough.

Impact

Denial of Service of the client application (process crash / OOM) — not the database itself. No authentication bypass or data exposure. Requires compress: true plus a malicious/compromised server or MITM position.

Vulnerable Code

function handleCompressedPacket(packet) {
  const connection = this;
  const deflatedLength = packet.readInt24();
  const body = packet.readBuffer();

  if (deflatedLength !== 0) {
    connection.inflateQueue.push((task) => {
      zlib.inflate(body, (err, data) => {
        if (err) {
          connection._handleNetworkError(err);
          return;
        }
        connection._bumpCompressedSequenceId(packet.numPackets);
        connection._inflatedPacketsParser.execute(data);
        task.done();
      });
    });
  } else {
    ...
  }
}

Recommended Fix

const MAX_INFLATED_PACKET_SIZE = 1 * 1024 * 1024 * 1024; // e.g. 1 GiB, ideally configurable

zlib.inflate(body, { maxOutputLength: MAX_INFLATED_PACKET_SIZE }, (err, data) => {
  if (err) {
    connection._handleNetworkError(err);
    return;
  }
  ...
});

maxOutputLength makes zlib.inflate abort with ERR_BUFFER_TOO_LARGE as soon as the decompressed size would exceed the cap, routing into the exact same (already-existing) err → connection._handleNetworkError(err) path, so no new error-handling logic is required.

Verification

Dynamically confirmed on v3.23.0 (HEAD) using a minimal rogue "MySQL server" built on node-mysql2's own server-mode helpers (mysql.createServer, Packets.Handshake, connection.writeOk()). The rogue server completes a real handshake advertising CLIENT_COMPRESS, then writes one raw compressed frame (509,604 bytes on the wire — a zlib deflate of 500 MB of zero bytes, ratio 1028.8:1) directly to the socket. A normal mysql.createConnection({ ..., compress: true })…

Record
GHSA-rgwj-5xj2-c3m3
CVSS 3.1
5.9 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H
Weakness
CWE-409
Updated
2026-11-02
OSVCLSA-2026-1788255454No score

TuxCare security update for mysql2 (1 CVE)

TuxCare rebuilt mysql2 to address 1 CVE. Fixed in 2.3.3-tuxcare.6.

Record
CLSA-2026-1788255454
Updated
2026-11-02
OSVCLSA-2026-1790622749No score

TuxCare security update for mysql2 (2 CVEs)

TuxCare rebuilt mysql2 to address 2 CVEs. Fixed in 3.20.0-tuxcare.1.

Record
CLSA-2026-1790622749
Updated
2026-11-02
Show 7 moreShow less
OSVCLSA-2026-1792163478No score

TuxCare security update for mysql2 (1 CVE)

TuxCare rebuilt mysql2 to address 1 CVE. Fixed in 3.22.6-tuxcare.1.

Record
CLSA-2026-1792163478
Updated
2026-11-02
OSVCLSA-2026-1792472736No score

TuxCare security update for mysql2 (1 CVE)

TuxCare rebuilt mysql2 to address 1 CVE. Fixed in 3.22.4-tuxcare.1.

Record
CLSA-2026-1792472736
Updated
2026-11-02
OSVCLSA-2026-1792486376No score

TuxCare security update for mysql2 (1 CVE)

TuxCare rebuilt mysql2 to address 1 CVE. Fixed in 3.22.3-tuxcare.1.

Record
CLSA-2026-1792486376
Updated
2026-11-02
OSVCLSA-2026-1792489443No score

TuxCare security update for mysql2 (2 CVEs)

TuxCare rebuilt mysql2 to address 2 CVEs. Fixed in 3.15.3-tuxcare.1.

Record
CLSA-2026-1792489443
Updated
2026-11-02
OSVCLSA-2026-1792495278No score

TuxCare security update for mysql2 (1 CVE)

TuxCare rebuilt mysql2 to address 1 CVE. Fixed in 3.22.2-tuxcare.1.

Record
CLSA-2026-1792495278
Updated
2026-11-02
OSVCLSA-2026-1792506023No score

TuxCare security update for mysql2 (1 CVE)

TuxCare rebuilt mysql2 to address 1 CVE. Fixed in 3.22.1-tuxcare.1.

Record
CLSA-2026-1792506023
Updated
2026-11-02
OSVROOT-APP-NPM-GHSA-3f6p-5ww8-9rcrNo score

GHSA-3f6p-5ww8-9rcr in mysql2 - Patched by Root

Root has patched GHSA-3f6p-5ww8-9rcr in the mysql2 package for Root:npm. Multiple fixed versions available.

Record
ROOT-APP-NPM-GHSA-3f6p-5ww8-9rcr
Updated
2026-11-02

Affected packages

Affected packages
PackageAffectedFixed
mysql2
npm
before 3.22.0
3.22.0
mysql2
npm
through 3.23.0
3.23.1
mysql2
TuxCare:npm
2.3.3-tuxcare.0 up to 2.3.3-tuxcare.6, plus listed versions
2.3.32.3.3-tuxcare.12.3.3-tuxcare.22.3.3-tuxcare.32.3.3-tuxcare.42.3.3-tuxcare.5
2.3.3-tuxcare.6
mysql2
TuxCare:npm
3.20.0-tuxcare.0 up to 3.20.0-tuxcare.1, plus listed versions
3.20.0
3.20.0-tuxcare.1
mysql2
TuxCare:npm
3.22.6-tuxcare.0 up to 3.22.6-tuxcare.1, plus listed versions
3.22.6
3.22.6-tuxcare.1
mysql2
TuxCare:npm
3.22.4-tuxcare.0 up to 3.22.4-tuxcare.1, plus listed versions
3.22.4
3.22.4-tuxcare.1
mysql2
TuxCare:npm
3.22.3-tuxcare.0 up to 3.22.3-tuxcare.1, plus listed versions
3.22.3
3.22.3-tuxcare.1
mysql2
TuxCare:npm
3.15.3-tuxcare.0 up to 3.15.3-tuxcare.1, plus listed versions
3.15.3
3.15.3-tuxcare.1
mysql2
TuxCare:npm
3.22.2-tuxcare.0 up to 3.22.2-tuxcare.1, plus listed versions
3.22.2
3.22.2-tuxcare.1
mysql2
TuxCare:npm
3.22.1-tuxcare.0 up to 3.22.1-tuxcare.1, plus listed versions
3.22.1
3.22.1-tuxcare.1
mysql2
npm
before 3.23.1
3.23.1
mysql2
Root:npm
before 3.9.8-aikido.1
3.9.8-aikido.13.7.1-aikido.43.17.0-aikido.1
@rootio/mysql2
Root:npm
before 3.9.8-root.io.1
3.9.8-root.io.13.7.1-root.io.43.17.0-root.io.1

History

History
RecordedChangedSources
first indexedGitHub Advisories, OSV

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

GHSA-3f6p-5ww8-9rcr is a high vulnerability (CVSS 8.2) in mysql2, published August 31, 2026. No source lists public exploit code. Fixed in mysql2 3.22.0.

References

Show 5 moreShow less
This page doesn't list everything

Left out here: the rest of 2 source descriptions. The JSON record has them.

MoveEnter Open