CVE-2026-62151: mysql_fdw SQL injection through a multi-byte character set escaping bypass
mysqlfdw 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 mysqlfdw 2.10.0. From mysqlfdw 2.10.0, mysqlfdw forces NOBACKSLASHESCAPES into the session sqlmode and escapes string literals by doubling single quotes.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
mysql_fdwto a version that resolves this vulnerability.Fixed in 2.10.0
Event History
Frequently Asked Questions
Who can exploit this issue?
An authenticated user who has only SELECT permission on an affected foreign table can exploit it by supplying a crafted value in a pushed-down string constant, such as a WHERE-clause literal. The injected SQL executes on the remote MySQL server using the credentials configured in the foreign server's user mapping.
What configurations are affected?
The vulnerable behavior requires a connection using a multi-byte character set such as GBK, SJIS, or Big5, with MySQL's default backslash escaping in effect. The affected escaping routine is used for every pushed-down string constant.
What should be done if an immediate upgrade is not possible?
The provided information identifies mysql_fdw 2.10.0 as the fix, which forces NO_BACKSLASH_ESCAPES for the session and uses doubled single quotes for string escaping. No alternative mitigation for earlier versions is provided.
How can I determine whether the foreign-server connection is exposed?
Review the character set used by the mysql_fdw connection and the remote MySQL session SQL mode. Connections using GBK, SJIS, Big5, or another relevant multi-byte character set while default backslash escaping remains enabled meet the described affected conditions.