Skip to content

fix(deps): update dependency mysql2 to v3 [security] - #74

Open
renovate[bot] wants to merge 1 commit into
masterfrom
renovate/npm-mysql2-vulnerability
Open

fix(deps): update dependency mysql2 to v3 [security]#74
renovate[bot] wants to merge 1 commit into
masterfrom
renovate/npm-mysql2-vulnerability

Conversation

@renovate

@renovate renovate Bot commented Apr 12, 2024

Copy link
Copy Markdown
Contributor

ℹ️ Note

This PR body was truncated due to platform limits.

This PR contains the following updates:

Package Change Age Confidence
mysql2 (source) ^2.3.2^3.0.0 age confidence

mysql2 cache poisoning vulnerability

CVE-2024-21507 / GHSA-mqr2-w7wj-jjgr

More information

Details

Versions of the package mysql2 before 3.9.3 are vulnerable to Improper Input Validation through the keyFromFields function, resulting in cache poisoning. An attacker can inject a colon : character within a value of the attacker-crafted key.

Severity

  • CVSS Score: 6.9 / 10 (Medium)
  • Vector String: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:L/SC:N/SI:N/SA:N

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


mysql2 Remote Code Execution (RCE) via the readCodeFor function

CVE-2024-21508 / GHSA-fpw7-j2hg-69v5

More information

Details

Versions of the package mysql2 before 3.9.4 are vulnerable to Remote Code Execution (RCE) via the readCodeFor function due to improper validation of the supportBigNumbers and bigNumberStrings values.

Severity

  • CVSS Score: 9.8 / 10 (Critical)
  • Vector String: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


mysql2 vulnerable to Prototype Poisoning

CVE-2024-21509 / GHSA-49j4-86m8-q2jw

More information

Details

Versions of the package mysql2 before 3.9.4 are vulnerable to Prototype Poisoning due to insecure results object creation and improper user input sanitization passed through parserFn in text_parser.js and binary_parser.js.

Severity

  • CVSS Score: 6.9 / 10 (Medium)
  • Vector String: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:L/SC:N/SI:N/SA:N

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


MySQL2 for Node Arbitrary Code Injection

CVE-2024-21511 / GHSA-4rch-2fh8-94vw

More information

Details

Versions of the package mysql2 before 3.9.7 are vulnerable to Arbitrary Code Injection due to improper sanitization of the timezone parameter in the readCodeFor function by calling a native MySQL Server date/time function.

Severity

  • CVSS Score: 9.8 / 10 (Critical)
  • Vector String: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


mysql2 vulnerable to Prototype Pollution

CVE-2024-21512 / GHSA-pmh2-wpjm-fj45

More information

Details

Versions of the package mysql2 before 3.9.8 are vulnerable to Prototype Pollution due to improper user input sanitization passed to fields and tables when using nestTables.

Severity

  • CVSS Score: 8.2 / 10 (High)
  • Vector String: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


MySQL2: Auth Plugin Downgrade to mysql_clear_password Leaks Plaintext Credentials

GHSA-3f6p-5ww8-9rcr

More information

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

Severity

  • CVSS Score: 8.2 / 10 (High)
  • Vector String: 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

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


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

GHSA-rgwj-5xj2-c3m3

More information

Details

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) errconnection._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 }) victim client — which never issues any query — had its RSS grow from 74.3 MB to 1115.0 MB after receiving that single packet, before erroring out with PROTOCOL_UNEXPECTED_PACKET once the client tried to parse the inflated zero-filled buffer as MySQL packets. The memory allocation happens unconditionally before any content validation.

Severity

  • CVSS Score: 5.9 / 10 (Medium)
  • Vector String: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Release Notes

sidorares/node-mysql2 (mysql2)

v3.23.1

Compare Source

Bug Fixes
  • security: fix unbounded decompression of server-supplied compressed packets, reported by alanturing881 (7c48343)
  • parser: call typeCast for NULL values in the binary protocol (#​4394) (01f1092)

v3.23.0

Compare Source

Features
  • return unsafe integers inside JSON columns as exact strings with supportBigNumbers (#​4388) (a26ff14)
  • sql-escaper: add Temporal support when escaping values (#​4392) (6b933f6)
  • support MariaDB data types (UUID, INET4, INET6, VECTOR, JSON) via extended type metadata; run CI against MariaDB (#​4373) (5034e57)

v3.22.6

Compare Source

Bug Fixes
  • sql-escaper: resolve multi statement and expand object regressions (#​4380) (1b927a9)

v3.22.5

Compare Source

Bug Fixes
  • keep 00:00:00 time for TIMESTAMP in binary protocol with dateStrings (#​4327) (2af33a1)

v3.22.4

Compare Source

Bug Fixes

v3.22.3

Compare Source

Bug Fixes
  • allow resetOnRelease in connection config validation (#​4278) (e72f923)

v3.22.2

Compare Source

Bug Fixes
  • promise: point rejection stacks at caller for promise API (#​4267) (c79a3f3)

v3.22.1

Compare Source

Bug Fixes

v3.22.0

Compare Source

Features
Performance Improvements
  • defer Error object creation to error handlers in promise wrappers (#​4257) (ab131de)

v3.21.1

Compare Source

Bug Fixes

v3.21.0

Compare Source

Features
  • add support for query attributes (#​4223) (d732f78)
  • types: export ExecuteValues and QueryValues from entry point (9fafd6f)

v3.20.0

Compare Source

Features
  • add TracingChannel support for native APM instrumentation (#​4178) (c06afc2)
Bug Fixes

v3.19.1

Compare Source

Bug Fixes
  • bound null-terminated string read to packet end (fixes a potential OOB read reported by Doruk Tan Ozturk (peaktwilight)) (#​4161) (91c5229)
  • handle malformed geometry payloads (fixes a potential DoS vulnerability reported by Doruk Tan Ozturk (peaktwilight)) (#​4164) (1869215)
  • prevent query param override of URL-defined connection options (fixes a potential config injection vulnerability reported by Doruk Tan Ozturk (peaktwilight)) (#​4162) (3123b4e)
  • validate buffer bounds in geometry parser (fixes a potential DoS vulnerability reported by Doruk Tan Ozturk (peaktwilight)) (#​4159) (7c2ae00)

v3.19.0

Compare Source

Features
  • use server's preferred auth method to eliminate auth switch roundtrip (#​4140) (b57c671)
Bug Fixes

v3.18.2

Compare Source

Bug Fixes
  • types: add supportBigNumbers, bigNumberStrings, dateStrings, and timezone options to QueryOptions (#​4127) (b274e72)
  • types: extend QueryValues to callback-based methods (#​4129) (2ad5f0b)
  • types: improve ExecuteValues "nested" params (#​4133) (3f94950)
  • types: support Raw and Uint8Array params (#​4132) (bde9aec)

v3.18.1

Compare Source

Bug Fixes
  • types: ensure optional params in query and execute methods (#​4123) (3f4bbca)

v3.18.0

Compare Source

Features
  • add Symbol.dispose and Symbol.asyncDispose support for Connections, Pools, and Pool Clusters (#​4112) (1e612dc)

v3.17.5

Compare Source

Bug Fixes

v3.17.4

Compare Source

Bug Fixes

v3.17.3

Compare Source

Bug Fixes
  • fix PoolConnection.end callback and promise resolution (#​3937) (18ff2c6)

v3.17.2

Compare Source

Bug Fixes
  • distinguish delimiters in queries from SQL comments (#​4084) (454ba10)
  • pool: discard connection on error 1290 (Aurora read-only failure) (#​4075) (9188963)
  • pool: handle all read-only errors during Aurora failover (#​4082) (ce98d8e)

v3.17.1

Compare Source

Bug Fixes
  • expand object params after ON DUPLICATE KEY UPDATE preceded by SET (#​4076) (4d2b930)

v3.17.0

Compare Source

Bug Fixes
  • security: resolve a potential SQL injection bypass through objects (#​4054) (7f133cc)

v3.16.3

Compare Source

Bug Fixes
  • constants: remove unsupported CLIENT_DEPRECATE_EOF flag from constants (#​4033) (46c3f60)

v3.16.2

Compare Source

Bug Fixes
  • types: add missing ConnectionState type to Promise Connection interface (#​4034) (2927949)

v3.16.1

Compare Source

Bug Fixes
  • named-placeholders: improve handling of mixed/nested quotes in query parsing (#​4011) (3e00cd7)

v3.16.0

Compare Source

Features
  • BaseConnection: add state getter to track connection lifecycle (#​3958) (a394487)

v3.15.3

Compare Source

Bug Fixes

v3.15.2

Compare Source

Bug Fixes
  • fix sha256_password to work correctly over a TLS connection (#​3809) (fb9eae1)

v3.15.1

Compare Source

Bug Fixes

v3.15.0

Compare Source

Features

v3.14.5

Compare Source

Bug Fixes

v3.14.4

Compare Source

Bug Fixes

v3.14.3

Compare Source

Bug Fixes
  • resolve parser cache collision with dual typeCast connections (#​3644) (ce2ad75)

v3.14.2

Compare Source

Bug Fixes

v3.14.1

Compare Source

Miscellaneous Chores

v3.14.0

Compare Source

Features

v3.13.0

Compare Source

Features
Bug Fixes
  • PromisePoolCluster.of returns PromisePoolCluster instead of PoolNamespace (#​3261) (be22202)
  • query: support VECTOR packets in static parser (#​3379) (603c246)

v3.12.0

Compare Source

Features

v3.11.5

Compare Source

Bug Fixes

v3.11.4

Compare Source

Bug Fixes
  • types: correct TypeCast's Next callback to return unknown (#​3129) (401db79)

v3.11.3

Compare Source

Bug Fixes

v3.11.2

Compare Source

Bug Fixes
  • resolve LRU conflicts, cache loss and premature engine breaking change (#​2988) (2c3c858)

v3.11.1

Compare Source

Bug Fixes
  • createPoolCluster: add pattern and selector to promise-based getConnection (#​3017) (ab7c49f), closes #​1381
  • update connection cleanup process to handle expired connections and exceeding config.maxIdle (#​3022) (b091cf4)

v3.11.0

Compare Source

Features
  • fully support VECTOR type results (9576742)

v3.10.3

Compare Source

Bug Fixes

v3.10.2

Compare Source

Bug Fixes
  • typeCast: ensure the same behavior for field.string() with query and execute (#​2820) (27e38ea)

v3.10.1

Compare Source

Bug Fixes

v3.10.0

Compare Source

Features
Bug Fixes
  • stream: reads should emit the dataset number for each dataset (#​2628) (4dab4ca)

v3.9.9

Compare Source

Bug Fixes
  • connection config: remove keepAliveInitialDelay default value (#​2712) (688ebab)

v3.9.8

Compare Source

Bug Fixes
  • security: sanitize fields and tables when using nestTables (#​2702) (efe3db5)
  • support deno + caching_sha2_password FULL_AUTHENTICATION_PACKET flow (#​2704) (2e03694)
  • typings: typo from jonServerPublicKey to onServerPublicKey (#​2699) (8b5f691)

v3.9.7

Compare Source

Bug Fixes
  • security: sanitize timezone parameter value to prevent code injection (#​2608) (7d4b098)

v3.9.6

Compare Source

Bug Fixes
  • binary parser sometimes reads out of packet bounds when results contain null and typecast is false (#​2601) (705835d)

v3.9.5

Compare Source

Bug Fixes

v3.9.4

Compare Source

Bug Fixes

v3.9.3

Compare Source

Bug Fixes
  • security: improve cache key formation (#​2424) (0d54b0c)
    • Fixes a potential parser cache poisoning attack vulnerability reported by Vsevolod Kokorin (Slonser) of Solidlab
  • update Amazon RDS SSL CA cert (#​2131) (d9dccfd)

v3.9.2

Compare Source

Bug Fixes

v3.9.1

Compare Source

Bug Fixes

v3.9.0

Compare Source

Features

v3.8.0

Compare Source

Features
Bug Fixes

Important

✂ PR body was truncated to here.


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate Bot changed the title fix(deps): update dependency mysql2 to v3 [security] Update dependency mysql2 to v3 [SECURITY] Apr 24, 2024
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from 8d9a005 to 293bcad Compare October 13, 2024 18:51
@renovate renovate Bot changed the title Update dependency mysql2 to v3 [SECURITY] Update dependency mysql2 to v3 [SECURITY] - autoclosed Dec 8, 2024
@renovate renovate Bot closed this Dec 8, 2024
@renovate
renovate Bot deleted the renovate/npm-mysql2-vulnerability branch December 8, 2024 19:01
@renovate renovate Bot changed the title Update dependency mysql2 to v3 [SECURITY] - autoclosed Update dependency mysql2 to v3 [SECURITY] Dec 8, 2024
@renovate renovate Bot reopened this Dec 8, 2024
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from 293bcad to 1cb892b Compare August 10, 2025 12:40
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from 1cb892b to 6f01f24 Compare September 25, 2025 14:47
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from 6f01f24 to 64a1d88 Compare October 23, 2025 07:46
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from 64a1d88 to 5d1f077 Compare November 18, 2025 14:04
@renovate renovate Bot changed the title Update dependency mysql2 to v3 [SECURITY] fix(deps): update dependency mysql2 to v3 [security] Nov 30, 2025
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from 5d1f077 to a2d734c Compare December 3, 2025 18:43
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from a2d734c to fccc63b Compare December 31, 2025 14:58
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from fccc63b to 969da19 Compare January 8, 2026 20:33
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from 969da19 to 1327ff0 Compare January 19, 2026 18:28
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from 1327ff0 to dea7e4c Compare February 2, 2026 17:53
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch 2 times, most recently from 180c412 to be6ed2a Compare February 17, 2026 16:03
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from be6ed2a to 4739e1b Compare March 5, 2026 15:51
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from 4739e1b to d06d4e3 Compare March 13, 2026 11:04
@renovate renovate Bot changed the title fix(deps): update dependency mysql2 to v3 [security] fix(deps): update dependency mysql2 to v3 [security] - autoclosed Mar 27, 2026
@renovate renovate Bot closed this Mar 27, 2026
@renovate renovate Bot changed the title fix(deps): update dependency mysql2 to v3 [security] - autoclosed fix(deps): update dependency mysql2 to v3 [security] Mar 30, 2026
@renovate renovate Bot reopened this Mar 30, 2026
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch 2 times, most recently from d06d4e3 to 298f9d9 Compare March 30, 2026 22:26
@renovate renovate Bot changed the title fix(deps): update dependency mysql2 to v3 [security] fix(deps): update dependency mysql2 to v3 [security] - autoclosed Apr 27, 2026
@renovate renovate Bot closed this Apr 27, 2026
@renovate renovate Bot changed the title fix(deps): update dependency mysql2 to v3 [security] - autoclosed fix(deps): update dependency mysql2 to v3 [security] Apr 27, 2026
@renovate renovate Bot reopened this Apr 27, 2026
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch 2 times, most recently from 298f9d9 to cd13b4f Compare April 27, 2026 21:34
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from cd13b4f to dc3610b Compare May 28, 2026 18:14
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from dc3610b to 4da5106 Compare June 11, 2026 18:08
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch 2 times, most recently from 114d0e7 to b369b3c Compare July 16, 2026 15:43
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from b369b3c to b885414 Compare July 20, 2026 21:36
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from b885414 to 3f9a58a Compare July 30, 2026 16:39
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from 3f9a58a to fc152d5 Compare August 11, 2026 23:58
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch 3 times, most recently from 1737e4b to e485fd0 Compare September 2, 2026 19:36
@renovate
renovate Bot force-pushed the renovate/npm-mysql2-vulnerability branch from e485fd0 to d7d448b Compare September 9, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants