# MySQL2 unbounded zlib inflate decompression-bomb DoS

Source: https://junglewise.ai/threats/mysql2-unbounded-zlib-inflate-decompression-bomb-dos-1b8791b1  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-08-31. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

Severity: low · CVSS 3.1 · Published 2026-08-31

MySQL2 is a popular Node.js driver for connecting applications to MySQL databases, supporting bandwidth optimization through protocol compression. When compression is enabled, the library fails to limit decompressed packet size, allowing an attacker controlling or intercepting the database connection to send a tiny compressed file that expands to gigabytes in memory, crashing the client application through out-of-memory conditions.

Technologies: [mysql2 (npm)](https://junglewise.ai/threats/technologies/mysql2). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is This vulnerability exploited in the wild?** No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.

**How severe is This vulnerability?** Low severity, with a CVSS score of 3.1, published 31 August 2026.

**Which products and versions are affected?** mysql2 (npm) SEMVER:introduced=0,fixed=3.23.1.

**Is there a fix for This vulnerability?** Yes. mysql2 (npm): upgrade to 3.23.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is This vulnerability attacked?** It is attacked over the network.

**Am I affected?** Check whether you run mysql2 (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- mysql2 (npm): upgrade to 3.23.1 or later

  ```sh
  npm install mysql2@3.23.1
  ```


## Technical details

The vulnerability is an improper handling of highly compressed data (CWE-409) in the compressed protocol handler (lib/compressed_protocol.js). The handleCompressedPacket() function calls zlib.inflate() without specifying a maxOutputLength option, allowing unbounded memory allocation. An attacker who controls the MySQL server endpoint or can MITM a non-TLS connection can craft a deflate stream with extreme compression ratios (>1000:1) that decompresses to multiple gigabytes. No authentication bypass or data exposure occurs; impact is limited to denial of service of the client process. The fix adds a maxOutputLength cap to zlib.inflate() calls. Patched in version 3.23.1.

## Affected products

- Node.js MySQL2 Contributors mysql2 <= 3.23.0

## Timeline

- 2026-08-31: disclosed
- 2026-08-31: patched: Fixed in version 3.23.1

## References

- [https://github.com/sidorares/node-mysql2/security/advisories/GHSA-rgwj-5xj2-c3m3](https://github.com/sidorares/node-mysql2/security/advisories/GHSA-rgwj-5xj2-c3m3)
- [https://github.com/sidorares/node-mysql2/commit/7c48343c95ecc80d30d6ebfa67875947b7d848d2](https://github.com/sidorares/node-mysql2/commit/7c48343c95ecc80d30d6ebfa67875947b7d848d2)

## Related threats

- [MySQL2 auth plugin downgrade to mysql_clear_password leaks plaintext credentials](https://junglewise.ai/threats/mysql2-auth-plugin-downgrade-to-mysql-clear-password-leaks-plaintext-4f504449)
- [mysql2 prototype pollution in nestTables](https://junglewise.ai/threats/cve-2024-21512-mysql2-prototype-pollution-in-nesttables)
- [mysql2 for Node arbitrary code injection via timezone parameter](https://junglewise.ai/threats/cve-2024-21511-mysql2-for-node-arbitrary-code-injection-via-timezone-parameter)
- [mysql2 remote code execution in readCodeFor function](https://junglewise.ai/threats/cve-2024-21508-mysql2-remote-code-execution-in-readcodefor-function)
- [mysql2 prototype poisoning in result parser](https://junglewise.ai/threats/cve-2024-21509-mysql2-prototype-poisoning-in-result-parser)
