CVE-2026-59399
Patch Available.
This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.
Overview
The Spring for Apache Kafka (spring-kafka) project applies core Spring concepts to the development of Kafka-based messaging solutions. It provides a "template" as a high-level abstraction for sending messages, and support for message-driven POJOs with @KafkaListener annotations and a "listener container".
A resource injection vulnerability (CVE-2026-59399) has been identified in the DelegatingDeserializer of Spring for Apache Kafka, which allows attackers who can produce records to a topic to choose how those records are deserialized, regardless of the configured delegates, and to make the consumer load any class on its classpath. Listeners can then receive data of an unexpected type, and the same header lets an attacker apply a configured delegate to data it was not intended for.
Per OWASP: This attack consists of changing resource identifiers used by an application in order to perform a malicious task. When an application defines a resource type or location based on user input, such as a file name or port number, this data can be manipulated to execute or access different resources.
This issue affects multiple versions of Spring for Apache Kafka.
Details
Module Info
- Product: Spring for Apache Kafka
- Affected packages:
org.springframework.kafka:spring-kafka - Affected versions: <=2.8.13, >=2.9.0 <=2.9.15, >=3.0.0 <=3.3.17, >=4.0.0 <=4.0.8, >=4.1.0 <=4.1.2
- GitHub repository: https://github.com/spring-projects/spring-kafka
- Published packages: https://central.sonatype.com/artifact/org.springframework.kafka/spring-kafka
- Package manager: Maven
- Fixed in:
- OSS Spring for Apache Kafka 4.0.9, 4.1.3
- NES for Spring for Apache Kafka
Vulnerability Info
This Medium-severity vulnerability is found in the org.springframework.kafka:spring-kafka package in multiple versions of Spring for Apache Kafka. Its CVSS 3.1 base score is 6.8 (AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:N).
DelegatingDeserializer picks the deserializer for each record from the spring.kafka.serialization.selector header (for values) or the spring.kafka.key.serialization.selector header (for keys). These headers are set by the producer of the record. When the selector does not match a configured delegate, the deserializer falls back to trySerdes, which treats the header value as a class name:
private Deserializer<?> getDeserializerByHeaders(Headers headers) {
...
String selector = new String(value).replaceAll("\"", "");
Deserializer<?> deserializer = this.delegates.get(selector);
if (deserializer == null) {
deserializer = trySerdes(selector);
}
return deserializer;
}
Deserializer<?> trySerdes(String key) {
try {
Class<?> clazz = ClassUtils.forName(key, ClassUtils.getDefaultClassLoader());
Serde<?> serdeFrom = Serdes.serdeFrom(clazz);
Deserializer<?> deserializer = serdeFrom.deserializer();
deserializer.configure(this.autoConfigs, this.forKeys);
this.delegates.put(key, deserializer);
return deserializer;
}
catch (IllegalStateException | IllegalArgumentException | ClassNotFoundException | LinkageError e) {
return null;
}
}ClassUtils.forName loads whatever class the header names, with no allow list, so a producer can make the consumer load any class on its classpath. When the class is one of the standard types supported by Kafka's Serdes (such as String or Long), the matching deserializer is created, cached in the delegate map and used for the record. The producer therefore decides how the record is deserialized, even when the application configured no delegate for that type, and listeners receive objects of a type they do not expect. Because the configured delegates are selected by the same header, an attacker can also apply any of them to data it was not meant for. An application is exposed when it uses DelegatingDeserializer as its key or value deserializer and consumes records from a topic that an attacker can produce to.
Steps To Reproduce
- Add
org.springframework.kafka:spring-kafkafrom an affected version (for example 3.3.16) and itskafka-clientsdependency to the classpath. - Run the following program, which configures no delegates and sends a selector header naming
java.lang.Long:
import java.util.Map;
import org.apache.kafka.common.header.internals.RecordHeaders;
import org.apache.kafka.common.serialization.LongSerializer;
import org.springframework.kafka.support.serializer.DelegatingDeserializer;
import org.springframework.kafka.support.serializer.DelegatingSerializer;
public class Repro {
public static void main(String[] args) {
// No delegates are configured
DelegatingDeserializer deserializer = new DelegatingDeserializer(Map.of());
deserializer.configure(Map.of(), false);
// The producer names a class in the selector header
RecordHeaders headers = new RecordHeaders();
headers.add(DelegatingSerializer.VALUE_SERIALIZATION_SELECTOR, "java.lang.Long".getBytes());
byte[] data = new LongSerializer().serialize("topic", 42L);
Object value = deserializer.deserialize("topic", headers, data);
System.out.println(value.getClass().getName() + ": " + value);
}
}- On an affected version the program prints
java.lang.Long: 42: the header alone made the consumer load the class and deserialize the record as a Long. A deserializer that only uses its configured delegates returns the rawbyte[]instead.
Mitigation
Only recent versions of Spring for Apache Kafka receive community support. Older lines are End-of-Life and will not receive public updates to address this issue.
Users of the affected components should apply one of the following mitigations:
- Upgrade to a currently supported version of Spring for Apache Kafka.
- Leverage a commercial support partner like HeroDevs for post-EOL security support.
Credits
- Yu Bao from PayPal Cyber Security Team (finder)