CVE-2026-59401 in Spring for Apache Kafka
Summary
by MITRE • 12/02/2026
JsonKafkaHeaderMapper and the deprecated DefaultKafkaHeaderMapper check the header type requested in the spring_json_header_types header against the mapper's trusted packages before deserializing a header value. Because java.lang is trusted by default, the type java.lang.Class passes this check. Deserializing a java.lang.Class header resolves the header value as a class name and loads that class, but the class named in the value is not subject to the trusted packages check.
A malicious producer can use this to make the consumer load, and with some Jackson versions initialize, any class on the consumer's classpath, regardless of the trusted packages configuration. The impact depends on the side effects of the static initializers of the classes present on the classpath, such as resource allocation, driver registration, or blocking.
An application is affected if it consumes records from a topic that an attacker can produce to and maps inbound headers with JsonKafkaHeaderMapper or DefaultKafkaHeaderMapper , which is the default when Jackson is on the classpath.
If you want to get the best quality for vulnerability data then you always have to consider VulDB.
Analysis
by VulDB Data Team • 12/02/2026
The vulnerability identified in Spring Kafka involves a critical flaw within the header mapping mechanisms provided by JsonKafkaHeaderMapper and its deprecated predecessor, DefaultKafkaHeaderMapper. These components are responsible for deserializing message headers from JSON format into Java objects when consuming records from Apache Kafka topics. The core issue stems from an insufficient validation of class types during this deserialization process. Specifically, while the mappers implement a security mechanism that checks header values against a list of trusted packages before allowing deserialization, they fail to apply this check uniformly across all possible data structures and type representations supported by the underlying Jackson library. This oversight creates a path for unauthorized code execution or resource exhaustion through maliciously crafted message headers.
The technical root cause lies in how java.lang.Class objects are handled during serialization and deserialization. By default, the package java.lang is included in the list of trusted packages to allow standard Java types like strings and integers to be processed without explicit configuration. However, when a header value specifies a type of java.lang.Class, the mapper interprets this as an instruction to load a specific class by name from the consumer's classpath. Crucially, while the initial check verifies that the requested type is java.lang.Class, which passes the trusted package filter, the subsequent step of resolving and loading the actual class named in the header value bypasses any further security checks. This means that an attacker can specify a fully qualified class name within the header, causing the application to load and potentially initialize that arbitrary class, regardless of whether it resides outside the intended trust boundaries or poses a risk to system stability.
The operational impact of this vulnerability is significant and depends heavily on the classes available in the consumer's runtime environment. If an attacker can produce messages to a topic consumed by a vulnerable application, they can force the loading of any class present on the classpath. The severity escalates if such classes contain static initializers or constructors with side effects. These side effects may include allocating substantial system resources, registering database drivers that could disrupt existing connections, initiating network calls to external servers, or causing blocking operations that lead to denial of service conditions. In scenarios where dangerous classes are present in the classpath, this flaw can potentially be chained with other vulnerabilities to achieve remote code execution, although even without full RCE, the ability to trigger arbitrary static initialization represents a severe compromise of application integrity and availability.
This vulnerability is categorized under CWE-20 Improper Input Validation, as the system fails to restrict input that could lead to unintended actions during deserialization. It also aligns with MITRE ATT&CK techniques related to Deserialization of Untrusted Data (T1583) and potentially Command and Scripting Interpreter if side effects allow for further exploitation vectors. The risk is particularly acute in environments where Jackson is present on the classpath, as JsonKafkaHeaderMapper becomes the default header mapper unless explicitly overridden by configuration settings that disable JSON-based header mapping or restrict trusted packages more strictly to exclude java.lang entirely.
To mitigate this vulnerability, organizations should immediately update Spring Kafka and its dependencies to versions that include patches addressing this specific deserialization flaw. If an immediate upgrade is not feasible, a robust workaround involves configuring the JsonKafkaHeaderMapper to explicitly set trusted packages to only those necessary for application functionality, while strictly excluding java.lang or ensuring that class loading from header values is disabled entirely. Additionally, applications should avoid consuming records from topics where message producers are not fully trusted entities within the security perimeter. Implementing strict input validation at the Kafka producer level and using non-JSON serialization formats for headers can also reduce the attack surface by preventing the transmission of maliciously crafted type descriptors in the first place.