MariaDB Connector/J: Rogue server can drive large heap allocations from server-declared lengths in OK packets
Moderate severity
GitHub Reviewed
Published
Oct 26, 2026
in
mariadb-corporation/mariadb-connector-j
•
Updated Oct 30, 2026
Package
Affected versions
>= 3.0.0, < 3.3.7
>= 3.4.0, < 3.4.5
>= 3.5.0, < 3.5.11
Patched versions
3.3.7
3.4.5
3.5.11
Description
Published by the National Vulnerability Database
Oct 29, 2026
Published to the GitHub Advisory Database
Oct 30, 2026
Reviewed
Oct 30, 2026
Last updated
Oct 30, 2026
Summary
MariaDB Connector/J sized heap allocations from lengths declared by the server
in OK packets before checking that those lengths fit in the packet. A rogue or
MitM server can make the client allocate megabytes from a packet of a few bytes.
Details
When
CLIENT_SESSION_TRACKis negotiated (the default), an OK packet carries aninfo field followed by session-state blocks, each tracked variable being sent as a
length-encoded name and value.
OkPacket.parse()andparseWithInfo()allocatednew byte[len]for the info field, the variable name and the value with theserver-declared
len, then copied the packet data into it. The copy failed with anArrayIndexOutOfBoundsExceptionwhen the packet was shorter, but only after theallocation had taken place.
A server-declared length of 8 MiB in an 18-byte packet was enough to trigger an
8 MiB allocation; the integer-range validation of length-encoded values does not
help, since such lengths are valid positive integers.
The fix validates every server-declared length against the remaining packet bytes
before any allocation (
ReadableByteBuf.checkLength()and a boundedreadBytes(int)), and stops reading the session state at the first inconsistententry.
Impact
Availability only: a malicious or compromised server, or a MitM, can drive
attacker-controlled heap allocations on every OK packet, creating GC pressure up to
OutOfMemoryErrorin the client application. Exploitation requires control of theserver side of the connection; no authentication bypass, confidentiality or
integrity impact.
Credit
Reported by fg0x0
References