Spring Security Advisories

CVE-2023-34040: Java Deserialization vulnerability in Spring-Kafka When Improperly Configured

MEDIUM | AUGUST 23, 2023 | CVE-2023-34040

Description

In Spring for Apache Kafka 3.0.9 and earlier and versions 2.9.10 and earlier, a possible deserialization attack vector existed, but only if unusual configuration was applied. An attacker would have to construct a malicious serialized object in one of the deserialization exception record headers.

Specifically, an application is vulnerable when all of the following are true:

  • The user does not configure an ErrorHandlingDeserializer for the key and/or value of the record
  • The user explicitly sets container properties checkDeserExWhenKeyNull and/or checkDeserExWhenValueNull container properties to true.
  • The user allows untrusted sources to publish to a Kafka topic

By default, these properties are false, and the container only attempts to deserialize the headers if an ErrorHandlingDeserializer is configured. The ErrorHandlingDeserializer prevents the vulnerability by removing any such malicious headers before processing the record.

Affected Spring Products and Versions

  • Spring for Apache Kafka
    • 2.8.1 to 2.9.10
    • 3.0.0 to 3.0.9

Mitigation

  • Do not set container properties checkDeserExWhenKeyNull or checkDeserExWhenValueNull when not using ErrorHandlingDeserializers, or use ErrorHandlingDeserializers
  • 2.8.x and 2.9.x users should upgrade to 2.9.11
  • 3.0.x users should upgrade to 3.0.10

Releases that have fixed this issue include:

  • Spring for Apache Kafka
    • 3.0.10
    • 2.9.11

Spring boot 3.0.10 (or later) dependency management will automatically use Spring for Apache Kafka 3.0.10 (or later). Spring Boot 2.7.x users should override Boot's Spring for Apache Kafka 2.8.x dependency management version to 2.9.11 (or later).

Credit

This issue was identified and responsibly reported by Joseph Beeton from Contrast Security, Inc.

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

Tanzu Spring offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all