CVE-2026-62151 in MySQL Foreign Data Wrapper
Summary
by MITRE • 11/25/2026
mysql_fdw builds string literals for queries sent to the remote MySQL server with an escaping routine that is not character-set aware. When the connection uses a multi-byte character set such as GBK, SJIS or Big5 and MySQL's default backslash escaping is in effect, a crafted value whose trailing byte is 0x5C absorbs the escaping backslash and leaves the following quote unescaped. The routine handles every pushed-down string constant, including ordinary WHERE-clause literals, so an authenticated user with only SELECT on a foreign table can break out of the literal and run arbitrary SQL on the remote MySQL server with the credentials of the user mapping. The issue is fixed in mysql_fdw 2.10.0. From mysql_fdw 2.10.0, mysql_fdw forces NO_BACKSLASH_ESCAPES into the session sql_mode and escapes string literals by doubling single quotes.
If you want to get best quality of vulnerability data, you may have to visit VulDB.
Analysis
by VulDB Data Team • 11/25/2026
The vulnerability identified as CVE-2024-1085 represents a critical SQL injection flaw within the MySQL Foreign Data Wrapper for PostgreSQL, specifically affecting versions prior to 2.10.0. This security issue stems from an inadequate string escaping mechanism used when constructing query literals destined for the remote MySQL server. The core technical deficiency lies in the wrapper's reliance on standard backslash-based escaping routines that fail to account for multi-byte character sets such as GBK, SJIS, or Big5. In these specific encoding contexts, the interaction between the escape logic and the character set parsing rules creates a predictable bypass condition where an attacker can manipulate how quotes are interpreted by the database engine.
The operational mechanics of this exploit involve crafting input values that contain multi-byte sequences ending in the hexadecimal value 0x5C, which corresponds to the backslash character. When MySQL processes these strings under its default configuration with backslash escaping enabled, it interprets the trailing byte as an escape sequence modifier rather than a literal data point. This misinterpretation causes the wrapper's subsequent backslash insertion for quote protection to be absorbed or neutralized by the multi-byte parsing logic. Consequently, any single quotes following this crafted payload remain unescaped from MySQL's perspective, effectively breaking out of the intended string literal boundary and allowing arbitrary SQL commands to be appended to the query structure.
The impact of this vulnerability is severe due to its potential for remote code execution within the database layer. Because mysql_fdw pushes down predicates and filters directly to the remote server, any authenticated user with even minimal privileges, such as SELECT access on a foreign table, can leverage this flaw. By injecting malicious SQL fragments through carefully crafted column values or filter conditions, an attacker can execute arbitrary commands using the credentials associated with the PostgreSQL-to-MySQL connection mapping. This effectively escalates the threat from simple data exfiltration to full compromise of the remote MySQL instance, potentially leading to unauthorized access, data modification, or further lateral movement within the infrastructure.
From a classification standpoint, this vulnerability aligns closely with CWE-89, which denotes Improper Neutralization of Special Elements used in an SQL Command, commonly known as SQL Injection. The specific technique employed exploits character set interpretation differences, relating to CWE-175 regarding improper handling of encoding issues that lead to security vulnerabilities. In terms of the MITRE ATT&CK framework, this attack vector corresponds to T1059.004, which covers Command and Scripting Interpreter: SQL Commands, as well as T1190, Exploit Public-Facing Application, assuming the PostgreSQL service is exposed or accessible by untrusted internal users. The flaw highlights a common pitfall in database proxy layers where assumptions about character set consistency are not strictly enforced during query construction.
Mitigation for this vulnerability requires immediate action to update the mysql_fdw extension to version 2.10.0 or later. This release addresses the root cause by enforcing the NO_BACKSLASH_ESCAPES SQL mode on all sessions connecting to the remote MySQL server. By disabling backslash escaping, the wrapper eliminates the ambiguity associated with multi-byte character sets and ensures that string literals are escaped exclusively through quote doubling, a method that is robust against the specific parsing quirks exploited in this flaw. Organizations relying on mysql_fdw for data integration between PostgreSQL and MySQL must prioritize this upgrade to restore secure query construction practices and prevent unauthorized SQL execution via foreign table interactions.