External risk intelligence

mysql2 SQL Injection Vulnerability Via Placeholder Escaping

CVE advisorySeverity: CRITICAL (CVSS 9.1)

CVE-2026-139877

The vulnerability exists in the mysql2 library, which is a database client driver used by backend applications. While it is used by internet-facing web applications to interact with databases, the library itself is an internal component of the application stack, not an internet-facing service or edge gateway. Reachability depends entirely on how the application handles input and its database configuration.

SQL Injection

Halo Surface Signal: 3 out of 5 — possibly public-facing.

External exposure likelihood

Horizon Alert

Summary of the vulnerability and why it matters

A vulnerability in the popular `mysql2` library, used for database connections, could allow attackers to manipulate SQL queries. This occurs when specific database settings are enabled, potentially leading to unauthorized data disclosure or modification through crafted inputs. The main concern is confirming if our applications use this library and are exposed to this configuration.

  • SQL injection flaw in database connection library.
  • Affects applications using specific database configurations.
  • Confirm relevance and exposure to this vulnerability.

Attack Path

How an attacker could exploit the issue

An attacker could exploit this vulnerability by sending specially crafted input to an application that uses the vulnerable mysql2 library. This input would be processed by the `Connection.format()` or `Connection.escape()` functions, which incorrectly handle string escaping when a specific SQL mode is enabled. If the application allows user-provided data to be passed through these functions, an attacker could manipulate the SQL queries, potentially leading to unauthorized access, modification, or disclosure of sensitive data.

  • Unauthenticated network access.
  • Crafted input via query placeholders.
  • SQL injection, data disclosure, or modification.

Live Threat

Current exploitation, exposure, and threat context

This vulnerability could allow an attacker to inject malicious SQL commands when a specific session SQL mode is enabled, potentially leading to unauthorized access, modification, or disclosure of database information.

  • Database data could be altered or exposed.
  • Via crafted input to query placeholders.
  • Unauthorized data access or modification.

Operational Fix

Recommended remediation, mitigation, and detection steps

Application owners and infrastructure teams are likely responsible for addressing this vulnerability in the `mysql2` library, as it affects how applications interact with databases. The first practical step is to identify all instances of the `mysql2` library within your environment, determine which of these are exposed to potentially malicious input or are business-critical, and then locate the specific application or service owner. This will allow for a risk-based remediation plan, potentially involving updates, configuration changes, or other mitigation strategies.

  • Application owners should address the issue.
  • Verify `mysql2` library usage and reachability.
  • Plan remediation based on risk assessment.

Supplementary metadata

Validate whether this threat affects your internet-facing exposure.

Halo Threat Intelligence helps prioritize remediation with Halo Surface Signal and H/A/L/O context. Start exposure validation with a free external attack surface trial.

Frequently asked questions

What is the mysql2 library?

mysql2 is a widely used Node.js database client driver. Developers use it to allow backend applications to communicate with MySQL-compatible databases. It acts as the bridge that enables your application to send queries and retrieve data, making it a fundamental piece of the software stack for many web applications.

What does this SQL injection vulnerability actually mean?

This is a CWE-89 weakness, commonly known as SQL injection. In this specific CVE, the library incorrectly treats characters as if they need backslash escaping even when the database configuration forbids it. Because of this logic error, an attacker can input special characters to break out of a intended data string and append their own SQL commands, which the database then executes.

How does an attacker trigger this bug?

An attacker needs to provide specially crafted input to an application that processes that data through mysql2's formatting or escaping functions. The vulnerability only triggers when the database session is specifically configured with NO_BACKSLASH_ESCAPES enabled. If your application does not use this specific SQL mode, this particular escaping conflict will not occur.

Do I need to worry if my database is internal?

Halo Surface Signal notes that mysql2 is an internal application component rather than a standalone internet-facing service. While your database may be internal, relevance depends on if your web application accepts user input that eventually reaches these vulnerable library functions. If your public-facing application passes unsanitized user input into these queries, it could be reachable by an attacker.

When should I update my mysql2 library?

You should plan to update as soon as you have identified where mysql2 is used in your environment. Prioritize applications that accept user-provided data and confirm if your database configurations utilize the NO_BACKSLASH_ESCAPES mode. Once identified, upgrade to version 3.25.0 or later to resolve the flawed character handling logic.

References