Skip to content

[backport camel-4.18.x] CAMEL-24421: camel-spring-redis - apply a deserialization filter to the default JDK serializer - #25589

Merged
oscerd merged 1 commit into
apache:camel-4.18.xfrom
oscerd:fix/CAMEL-24421-4.18.x
Aug 24, 2026
Merged

[backport camel-4.18.x] CAMEL-24421: camel-spring-redis - apply a deserialization filter to the default JDK serializer#25589
oscerd merged 1 commit into
apache:camel-4.18.xfrom
oscerd:fix/CAMEL-24421-4.18.x

Conversation

@oscerd

@oscerd oscerd commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Backport of #25587 to camel-4.18.x.

Description

RedisConfiguration.createDefaultSerializer() builds a bare JdkSerializationRedisSerializer, whose read path runs through Spring's ConfigurableObjectInputStream with no ObjectInputFilter installed. Every other component in the codebase that performs JDK deserialization resolves a filter first — camel-spring-redis was the one path left without one.

Adds a deserializationFilter endpoint option (advanced,security). The default serializer now installs a filter: the configured pattern when set, otherwise the JVM-wide jdk.serialFilter, otherwise a conservative default allow-list. This covers the consumer, the producer read commands, and SpringRedisIdempotentRepository, which all share the default serializer.

Differences from the main PR

DeserializationFilterHelper does not exist on this branch, so FilteringDeserializer carries its own DEFAULT_DESERIALIZATION_FILTER constant and a local resolveDeserializationFilter, following the pattern already used here by NettyHttpHelper, JmsBinding and MinaConverter. As on those classes, the constant is !java.net.**;java.**;javax.**;org.apache.camel.**;!* without the JEP-290 graph-shape limits, which are main-only (CAMEL-23609) — the upgrade-guide wording reflects that.

The upgrade-guide entry goes in camel-4x-upgrade-guide-4_18.adoc.

Verified that JdkSerializationRedisSerializer(Converter, Converter), ConfigurableObjectInputStream(InputStream, ClassLoader) and Deserializer.deserialize are identical on the Spring 6.2 / Spring Data 3.5 used here, so the code compiles the same way as on main.

Testing

123/123 module tests pass, including the 5 new ones.

Note: this branch has ~146 generated files carrying a stale 4.18.4-SNAPSHOT version string that any local build rewrites to 4.18.5-SNAPSHOT. That drift is pre-existing and unrelated to this change, so it is deliberately not included here.


Do not merge before #25587.


Claude Code on behalf of oscerd

@oscerd oscerd closed this Aug 23, 2026
@oscerd oscerd reopened this Aug 23, 2026
…he default JDK serializer

RedisConfiguration.createDefaultSerializer() built a bare
JdkSerializationRedisSerializer, whose read path runs through Spring's
ConfigurableObjectInputStream with no ObjectInputFilter installed. Every other
component in the codebase that performs JDK deserialization -- camel-consul,
camel-leveldb, camel-mina, camel-netty, camel-netty-http, camel-vertx-http,
camel-jms, camel-sjms, camel-http-common, camel-cassandraql -- resolves a filter
first, so camel-spring-redis was the one path left without one.

The default serializer now installs a filter resolved through
DeserializationFilterHelper: the new deserializationFilter option when set,
otherwise the JVM-wide jdk.serialFilter, otherwise the shared Camel allow-list.

JdkSerializationRedisSerializer exposes no hook for a filter, so the serializer
is built through its Converter-based constructor with a deserializing converter
that sets one on the stream. Serialization is left untouched, and class
resolution is unchanged: the same null class loader Spring's DefaultDeserializer
uses by default is passed through.

This covers the three places that share the default serializer -- the consumer,
which deserializes the payload of every message published to the subscribed
channels; the producer read commands, through the default RedisTemplate; and
SpringRedisIdempotentRepository, which builds that same template. Note that
setting a custom redisTemplate does not reach the consumer, which reads
getSerializer() directly, so the option covers both paths.

Setting the serializer option to a custom RedisSerializer bypasses the filter,
since Camel then no longer controls how the payload is read.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit d35b455)
@oscerd
oscerd force-pushed the fix/CAMEL-24421-4.18.x branch from a23c7ed to 3fe0485 Compare August 24, 2026 07:38

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, well-structured backport of a security hardening change that closes the last JDK deserialization path without an ObjectInputFilter. The approach is consistent with how other components (NettyHttpHelper, MinaConverter, JmsBinding) handle the same concern on the 4.18.x branch, CI passes, and tests are comprehensive.

Key observations:

  • The FilteringDeserializer class correctly mirrors the local-constant + resolveDeserializationFilter pattern already used by NettyHttpHelper and MinaConverter on camel-4.18.x, where DeserializationFilterHelper does not exist.
  • The default filter value (!java.net.**;java.**;javax.**;org.apache.camel.**;!*) is identical to those components, correctly omitting the JEP-290 graph-shape limits (maxdepth, maxrefs, maxbytes) which are a main-only addition (CAMEL-23609).
  • The @UriParam(label = "advanced,security") annotation correctly categorizes the option as a security hardening parameter.
  • The upgrade guide entry clearly documents the behavioral change and provides a concrete example for users who need to widen the filter.
  • The PR correctly notes "Do not merge before #25587" to ensure the main PR lands first.

📋 PR Metadata

Aspect Current Suggested
Labels (none) bug
Milestone (none) 4.18.4

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of @gnodet

@oscerd
oscerd merged commit e721141 into apache:camel-4.18.x Aug 24, 2026
3 checks passed
oscerd added a commit to oscerd/camel that referenced this pull request Aug 27, 2026
… 4.22 and 4.18 upgrade guides

The upgrade guides for every release line live on main, which holds the canonical
history across all releases. The deserialization filter shipped on three lines --
4.23.0 (apache#25587), 4.22.1 (apache#25588) and 4.18.5 (apache#25589) -- but only the 4.23 note was
added here; the 4.22 and 4.18 notes went in on the maintenance branches, where they
are not part of that history.

Adds both, matching the text that shipped on each branch: the 4.22 note names the
JEP-290 graph-shape limits that DeserializationFilterHelper enforces there, the 4.18
note does not, because on that line the filter is the local constant without them.

Both are new leading sections, keeping the reverse-chronological order the guides
already use.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
oscerd added a commit that referenced this pull request Aug 27, 2026
… 4.22 and 4.18 upgrade guides (#25734)

The upgrade guides for every release line live on main, which holds the canonical
history across all releases. The deserialization filter shipped on three lines --
4.23.0 (#25587), 4.22.1 (#25588) and 4.18.5 (#25589) -- but only the 4.23 note was
added here; the 4.22 and 4.18 notes went in on the maintenance branches, where they
are not part of that history.

Adds both, matching the text that shipped on each branch: the 4.22 note names the
JEP-290 graph-shape limits that DeserializationFilterHelper enforces there, the 4.18
note does not, because on that line the filter is the local constant without them.

Both are new leading sections, keeping the reverse-chronological order the guides
already use.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants