CAMEL-24296: camel-support - apply a JEP-290 deserialization filter on CamelObjectInputStream by default - #25378
Conversation
…n CamelObjectInputStream by default CamelObjectInputStream is the shared ObjectInputStream used by Camel's Java-object deserialization paths but installed no ObjectInputFilter, leaving any direct caller unprotected. It now resolves a filter via DeserializationFilterHelper and installs it with setObjectInputFilter(): when no explicit pattern is supplied the JVM-wide jdk.serialFilter is honoured if set, otherwise the default Camel allow-list is applied (permits standard Java and Apache Camel types, denies java.net.**, enforces JEP-290 graph-shape limits). A new (InputStream, CamelContext, String) constructor accepts an explicit filter pattern. HttpHelper now passes its configured pattern through that constructor instead of calling setObjectInputFilter() separately; the built-in HTTP path already applied the default filter, so its behaviour is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 556 tested, 28 compile-only — current: 555 all testedMaveniverse Scalpel detected 584 affected modules (current approach: 555).
|
gnodet
left a comment
There was a problem hiding this comment.
Good security hardening — centralizing JEP-290 filter application in the CamelObjectInputStream constructor is the right approach. The deny-by-default posture (!*) and the fallback chain (explicit pattern → JVM-wide jdk.serialFilter → Camel default) give operators appropriate control. Tests cover the meaningful code paths well.
Two minor observations below.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of @gnodet
What
CamelObjectInputStreamis the sharedObjectInputStreamused by Camel's Java-object deserialization paths (e.g. the HTTP components), but it installed nojava.io.ObjectInputFilter, so any code constructing it directly deserialized without a JEP-290 filter.This change makes
CamelObjectInputStreamresolve a filter via the existingDeserializationFilterHelperand install it withsetObjectInputFilter():jdk.serialFilteris honoured if set, otherwise the default Camel allow-list (DEFAULT_DESERIALIZATION_FILTER) is applied — permits standard Java and Apache Camel types, deniesjava.net.**, and enforces JEP-290 graph-shape limits.CamelObjectInputStream(InputStream, CamelContext, String)constructor accepts an explicit filter pattern.HttpHelpernow passes its configured pattern through the new constructor instead of callingsetObjectInputFilter()separately. The built-in HTTP path already applied the default filter (viaDeserializationFilterHelper), so its runtime behaviour is unchanged — this closes the gap for any direct instantiation and centralizes the filter on the stream itself.Why
Defense-in-depth against unsafe deserialization: the shared stream is now safe-by-default and configurable, consistent with the deserialization filtering already applied by
camel-jms,camel-mina,camel-nettyandcamel-netty-http.Testing
CamelObjectInputStreamTest(4 tests): the default filter allows standard types, rejects a class outside the allow-list, a blank pattern falls back to the default, and an explicit pattern can allow an otherwise-denied class.mvn clean install -DskipTestspasses.Docs
camel-4x-upgrade-guide-4_22.adoc(publiccamel-supportclass default change).Claude Code on behalf of oscerd