CVE-2023-34040 Spring Kafka Deserialization Remote Code Execution
Spring Kafka's error-handling deserialiser could be made to deserialise a crafted exception header when the key or value was null, because the class check only restricted the outer exception type and not the nested cause. An attacker able to publish to a topic could therefore trigger deserialisation of a malicious class and achieve remote code execution.
Here is the explicit description about Spring Kafka deserialization vulnerability in Vmware security bulletin.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the deserialisation allow-list only validated the outer DeserializationException class while its nested cause field was deserialised without restriction.
Impact
An attacker who can publish to a topic could achieve remote code execution on the consumer, and a CommonsCollections gadget chain could also be used.
What the attacker needed
Consumer uses ErrorHandlingDeserializer; checkDeserExWhenKeyNull/ValueNull set true; attacker can publish to the topic
How it was found
- Configure the consumer with ErrorHandlingDeserializer and set checkDeserExWhenKeyNull and checkDeserExWhenValueNull to true.
- Publish a record whose key or value is null but which carries the exception header.
- Place a serialised malicious class, inheriting Throwable, in the exception header value.
- Send the request so the consumer reads the record and deserialises the header, triggering code execution.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Kafka is a message queue: programs publish messages to named topics and other programs read them. Spring Kafka can be told to look inside a special header for details of a failed message, and it turns that header back into a Java object. The check only looked at the outer object type, so a hidden inner object of any class slipped through and could run code.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.