CVE-2026-139877: mysql2 before 3.25.0 SQL Injection via Placeholder Escaping under NO_BACKSLASH_ESCAPES

Published Nov 30, 2026
·
Updated

mysql2 before 3.25.0 contains an sql injection vulnerability in Connection.format() and Connection.escape() because quotes are always backslash-escaped regardless of session SQL mode. When NOBACKSLASHESCAPES is enabled, attackers can pass crafted values through ? placeholders in connection.query() to close string literals and append SQL, disclosing or modifying data.

Affected Software

1 affected component
npm/mysql2<3.25.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/mysql2 to a version that resolves this vulnerability.

    Fixed in 3.25.0

Event History

Nov 30, 2026
CVE Published
via MITRE·04:20 PM
Data Sourced
via MITRE·04:20 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Which deployments are exposed to this issue?

Deployments using npm/mysql2 versions before 3.25.0 are affected when their MySQL session has NO_BACKSLASH_ESCAPES enabled and the application passes attacker-controlled values through ? placeholders in connection.query(), Connection.format(), or Connection.escape().

2

What does an attacker need to exploit it?

An attacker needs a way to supply crafted input that reaches a vulnerable mysql2 placeholder or escaping call while NO_BACKSLASH_ESCAPES is active for the database session. No authentication or user interaction is required by the vulnerability itself, but exploitability depends on reaching such an application input path.

3

What is the impact if exploitation succeeds?

Crafted values can terminate a SQL string literal and append SQL statements or clauses. This can allow disclosure or modification of database data; the provided impact information does not indicate an availability impact.

4

How can teams determine whether they are affected?

Check whether the application uses mysql2 before 3.25.0 and whether its database sessions enable NO_BACKSLASH_ESCAPES. Then identify uses of connection.query() with ? placeholders, Connection.format(), or Connection.escape() that receive untrusted values.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203