CVE-2026-59401: In Spring for Apache Kafka, trusted-package allowlist bypass via java.lang.Class header type allows arbitrary class initialization
JsonKafkaHeaderMapper and the deprecated DefaultKafkaHeaderMapper check the header type requested in the springjsonheadertypes 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.
Affected Software
Event History
Frequently Asked Questions
Which deployments are exposed to this issue?
An application is affected when it consumes records from a topic to which an attacker can produce and maps inbound headers using JsonKafkaHeaderMapper or the deprecated DefaultKafkaHeaderMapper. These mappers are the default when Jackson is on the classpath.
What access does an attacker need to exploit it?
The attacker needs the ability to produce a malicious record to a topic consumed by the application. Exploitation relies on the consumer deserializing inbound headers and on a suitable class being present on the consumer classpath.
Does restricting trusted packages prevent exploitation?
No. The bypass uses java.lang.Class, which passes the trusted-package check because java.lang is trusted by default; the class name carried in the header value is not checked against the trusted-package configuration.
What is the likely impact on an affected consumer?
A malicious record can cause the consumer to load any class on its classpath and, with some Jackson versions, initialize it. Consequences depend on static initializer side effects, including resource allocation, driver registration, or blocking.