The vulnerability, CVE-2026-106122, in RabbitMQ's Java client (amqp-client) allows a malicious AMQP message with malformed UTF-8 in a shortstr property to permanently disable an RPC consumer. The core issue stems from a mismatch between how malformed UTF-8 is decoded and then re-encoded.
-
com.rabbitmq.client.impl.ValueReader.readShortstr: This function is responsible for reading short strings from the AMQP wire. In the vulnerable version, it used new String(b, StandardCharsets.UTF_8) to decode byte arrays. This method silently replaces malformed byte sequences with the U+FFFD replacement character. Crucially, a single U+FFFD character, while occupying one character slot, re-encodes to three bytes in UTF-8. This means a 255-byte malformed input could be decoded into a string that, when re-encoded, would exceed the 255-byte limit for short strings (e.g., 255 U+FFFD characters would become 765 bytes). This function was vulnerable because it produced a string that was valid Java but invalid for re-encoding as an AMQP shortstr, setting up the subsequent failure.
-
com.rabbitmq.client.RpcServer.mainloop: This function represents the main processing loop for RPC consumers. In the vulnerable version, this loop lacked comprehensive exception handling. Specifically, it only caught InterruptedException and ShutdownSignalException. When an application echoed back a shortstr property (like correlation-id) that had been 'expanded' by ValueReader.readShortstr, the com.rabbitmq.client.impl.ValueWriter.writeShortstr function (which is called indirectly via channel.basicPublish or similar operations) would throw an IllegalArgumentException because the string's UTF-8 encoded length exceeded 255 bytes. Since RpcServer.mainloop did not catch RuntimeException (which IllegalArgumentException extends), this exception would escape, causing the consumer thread to terminate. Because the message was never acknowledged, the broker would re-queue it, leading to a persistent denial of service as any new consumer attempting to process the message would also crash.
The patch addresses these issues by:
- Modifying
ValueReader.readShortstr to truncate any decoded string that, after U+FFFD substitutions, would exceed the maximum shortstr byte length when re-encoded. This prevents the creation of oversized strings that ValueWriter would reject.
- Adding a
try-catch block for RuntimeException within RpcServer.mainloop. This ensures that if an exception occurs during message processing (e.g., from ValueWriter.writeShortstr in other scenarios, or if the truncation in ValueReader is bypassed), the message is rejected, and the consumer thread continues to run, preventing a permanent denial of service.