CVE-2026-55858
Patch Available.
This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.
Overview
MariaDB Connector/J is MariaDB's JDBC driver: a JDBC 4.2 compatible driver used to connect applications developed in Java to MariaDB and MySQL databases. It is published to Maven Central as org.mariadb.jdbc:mariadb-java-client, and Spring Boot 2.7.18 manages its 3.1.4 release.
A command injection vulnerability (CVE-2026-55858) has been identified in MariaDB Connector/J, which allows attackers who can change the session's character_set_client to a non-UTF-8 character set to make the driver and the server interpret the same bytes under different encodings. This silently corrupts data, and the charset confusion can defeat the byte-wise quoting and escaping the driver applies to SQL text, which can lead to SQL injection.
Per OWASP: A SQL injection attack consists of insertion or "injection" of a SQL query via the input data from the client to the application.
This issue affects multiple versions of MariaDB Connector/J.
Details
Module Info
- Product: MariaDB Connector/J
- Affected packages:
org.mariadb.jdbc:mariadb-java-client - Affected versions: <2.7.14, >=3.0.0 <3.3.5, >=3.4.0 <3.4.3, >=3.5.0 <3.5.9
- GitHub repository: https://github.com/mariadb-corporation/mariadb-connector-j
- Published packages: https://central.sonatype.com/artifact/org.mariadb.jdbc/mariadb-java-client
- Package manager: Maven
- Fixed in:
- OSS MariaDB Connector/J 2.7.14, 3.3.5, 3.4.3, 3.5.9
- NES for MariaDB Connector/J v3.1.7
Vulnerability Info
This Medium-severity vulnerability is found in the org.mariadb.jdbc:mariadb-java-client package in multiple versions of MariaDB Connector/J. The driver encodes and decodes all character data on the assumption that the connection character set is UTF-8. Outgoing strings are always converted with UTF-8, for example in PacketWriter.writeString:
byte[] arr = str.getBytes(StandardCharsets.UTF_8);
writeBytes(arr, 0, arr.length);and incoming strings are always decoded with UTF-8 in StandardReadableByteBuf.readString:
return new String(buf, pos - length, length, StandardCharsets.UTF_8);The connection character set can be changed during the session, for example by a SET NAMES statement. When the server reports the change through session-state tracking in an OK packet, the driver parses the system variable but only logs it, so it never notices that character_set_client is no longer UTF-8:
case StateChange.SESSION_TRACK_SYSTEM_VARIABLES:
buf.readIntLengthEncodedNotNull();
String variable = buf.readString(buf.readIntLengthEncodedNotNull());
Integer len = buf.readLength();
String value = len == null ? null : buf.readString(len);
logger.debug("System variable change: {} = {}", variable, value);
break;From then on the driver keeps writing and reading UTF-8 while the server interprets the same bytes under a different encoding. Data exchanged on the connection is silently corrupted. Because the driver's quoting and escaping of string values assumes UTF-8 bytes, a multi-byte server character set can consume an escape byte as part of a multi-byte character, the charset-confusion primitive that can defeat escaping and lead to SQL injection.
Mitigation
MariaDB plc's Engineering Policy lists MariaDB Connector/J 2.7, 3.3, 3.4 and 3.5 as its supported release series. Upstream has made no 3.1.x release since 3.1.4 (April 2023), so no 3.1.x release is available to address this issue. For more information, see here.
Users of the affected components should apply one of the following mitigations:
- Upgrade affected applications to a currently supported release of MariaDB Connector/J that contains the fix.
- Leverage a commercial support partner like HeroDevs for post-EOL security support.
Credits
- Yalguun Tumenkhuu (finder)