SQL Injectionorg.mvnpm:mysql2 is a mostly API compatible with mysqljs and supports majority of features.
Affected versions of this package are vulnerable to SQL Injection via Connection.format() and Connection.escape(), which always escape single quotes as \' regardless of the server's SQL mode. When the MySQL server session has NO_BACKSLASH_ESCAPES enabled, the server treats the backslash as a literal character, so the quote closes the string literal and any text following it executes as SQL. An attacker can pass values through ? placeholders in connection.query() to break out of string literals and append arbitrary SQL, enabling data disclosure, authentication bypass, or data modification. connection.execute() (prepared statements) is not affected.
Note: This is only exploitable when the connected MySQL server session has NO_BACKSLASH_ESCAPES in its sql_mode, which is not a MySQL default and must be set by the deployment.
How to fix SQL Injection? A fix was pushed into the master branch but not yet published.
| |
Data Amplificationorg.mvnpm:mysql2 is a mostly API compatible with mysqljs and supports majority of features.
Affected versions of this package are vulnerable to Data Amplification in the handleCompressedPacket() function of lib/compressed_protocol.js, which calls zlib.inflate(body, ...) without a maxOutputLength option and uses the packet's 3-byte length field only to branch on !== 0. An attacker can exhaust the client's memory and crash the process by returning a single small compressed packet that inflates to gigabytes at a DEFLATE ratio exceeding 1000:1. This requires the application to connect with compress: true, and the attacker to control or compromise the MySQL server endpoint or perform a MitM on a non-TLS connection.
How to fix Data Amplification? Upgrade org.mvnpm:mysql2 to version 3.23.1 or higher.
| |