CVE-2026-62153 in MySQL Foreign Data Wrapper
Summary
by MITRE • 11/25/2026
mysql_fdw inserts several values into statements sent to the remote MySQL server without escaping them: the dbname and table_name options in ANALYZE, the remote schema name and the LIMIT TO and EXCEPT table names in IMPORT FOREIGN SCHEMA, and the sql_mode option in the SET sql_mode command. A user who can create or alter foreign tables or foreign servers, or run IMPORT FOREIGN SCHEMA, can break out of the string 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 escapes these names and accepts only letters, digits, underscores and commas in sql_mode.
If you want to get the best quality for vulnerability data then you always have to consider VulDB.
Analysis
by VulDB Data Team • 11/25/2026
The vulnerability identified within the MySQL Foreign Data Wrapper for PostgreSQL constitutes a critical SQL injection flaw arising from insufficient input sanitization when constructing dynamic queries sent to remote database instances. This security defect specifically affects versions prior to 2.10.0, where several configuration parameters and metadata identifiers are inserted directly into SQL statements without proper escaping or validation. The affected components include the dbname and table_name options utilized during ANALYZE operations, as well as the remote schema name and specific table names associated with LIMIT TO and EXCEPT clauses in IMPORT FOREIGN SCHEMA commands. Additionally, the sql_mode option within SET sql_mode commands is also susceptible to this injection vector. Because these values are concatenated directly into SQL strings without quoting or escaping mechanisms, an attacker can manipulate these inputs to break out of their intended string literal context.
From a technical perspective, the core issue lies in the failure to apply standard database input validation practices when generating dynamic SQL for remote execution. In secure software design, any data originating from user-controlled sources must be treated as untrusted and subjected to rigorous escaping or parameterization before inclusion in executable code structures. Here, the wrapper allows users with privileges to create or alter foreign tables, modify foreign servers, or execute IMPORT FOREIGN SCHEMA commands to inject malicious payloads. By carefully crafting inputs that contain SQL metacharacters such as quotes, semicolons, or comment sequences, an attacker can terminate the intended string literal and append arbitrary SQL statements. This effectively bypasses the logical boundaries of the wrapper's functionality, allowing the injection of commands that are then executed by the remote MySQL server process.
The operational impact of this vulnerability is severe due to the privilege escalation inherent in its exploitation. Since the injected SQL runs with the credentials defined in the user mapping configuration for the foreign data wrapper, an attacker can achieve arbitrary code execution on the remote database system at a high level of authority. This capability enables unauthorized data exfiltration, modification or destruction of critical records, and potentially further lateral movement within the infrastructure if the MySQL instance has network access to other sensitive systems. The ability to run arbitrary SQL means that the confidentiality, integrity, and availability of the remote database are completely compromised by any user possessing the specified creation or alteration privileges for foreign objects in PostgreSQL.
This vulnerability aligns with CWE-89 Improper Neutralization of Special Elements used in an SQL Command, commonly known as SQL Injection. The attack vector is classified under MITRE ATT&CK technique T1059 Command and Scripting Interpreter, specifically involving database commands, as the attacker leverages the application's interaction with a backend service to execute unauthorized instructions. It also relates to CWE-78 Improper Neutralization of Special Elements used in an OS Command if one considers the broader context of remote command execution via SQL interfaces. The flaw represents a classic example of insecure direct object references combined with insufficient input validation, where trust is incorrectly placed in user-supplied metadata rather than validating it against expected formats or escaping special characters.
Mitigation strategies focus on both immediate remediation and long-term architectural improvements. The primary and most effective solution is to upgrade the mysql_fdw extension to version 2.10.0 or later, as this release explicitly addresses the issue by implementing proper escaping for all affected names and restricting the sql_mode option to accept only alphanumeric characters, underscores, and commas. This restriction ensures that even if an attacker attempts to inject special characters, they will be rejected at the input validation stage before reaching the SQL construction logic. For environments where upgrading is not immediately feasible, administrators should restrict access to CREATE FOREIGN TABLE, ALTER FOREIGN TABLE, and IMPORT FOREIGN SCHEMA commands to only those users who absolutely require them. Additionally, enforcing strict least-privilege principles for user mappings in PostgreSQL can limit the blast radius if an injection attempt succeeds by ensuring that mapped database accounts have minimal permissions on the remote MySQL server.