Description
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.
Affected products and versions
CVSS vector, explained
CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:N/VA:N/SC:H/SI:H/SA:H
- Attack vector
- Network (from the internet)
- Attack complexity
- Low
- Attack requirements
- Present
- Privileges required
- Regular user
- User interaction
- Not required
- Confidentiality
- None
- Integrity
- None
- Availability
- None
Weakness type (CWE)
- CWE-89 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
References
- www.enterprisedb.com/docs/security/advisories/cve202662151/ vendor advisory
- github.com/EnterpriseDB/mysql_fdw/releases/tag/REL-2_10_0 patch
Sources: CVE.org (CNA and CISA ADP), CISA KEV, FIRST EPSS. Always check the vendor's official advisory.