Executive brief
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.
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