CAMEL-23373: camel-jms - Disable ObjectMessage by default#22866
Merged
oscerd merged 2 commits intoapache:mainfrom Apr 30, 2026
Merged
CAMEL-23373: camel-jms - Disable ObjectMessage by default#22866oscerd merged 2 commits intoapache:mainfrom
oscerd merged 2 commits intoapache:mainfrom
Conversation
Java object serialization over JMS is rarely used in practice and is a recurring source of security advisories. Disable creation and reading of jakarta.jms.ObjectMessage by default and add a new objectMessageEnabled option (default false) on JmsConfiguration / JmsComponent / JmsEndpoint to opt back in. When disabled, JmsBinding now refuses to: - create an ObjectMessage from a Serializable body (auto-detected jmsMessageType=Object or explicitly set) - create an ObjectMessage for transferExchange or transferException - extract the body of a received ObjectMessage Existing tests that rely on ObjectMessage have been updated to opt in. A new JmsObjectMessageEnabledTest validates the default disabled behavior on producer and consumer side, and JmsBindingTest covers the unit-level checks. Documentation updated in the 4.21 upgrade guide. Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
Contributor
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
davsclaus
approved these changes
Apr 30, 2026
Contributor
|
…builders The componentdsl and endpointdsl builder factories for camel-jms and the JMS-derived components (camel-activemq, camel-activemq6, camel-amqp) needed to be regenerated to expose the new objectMessageEnabled option in the fluent DSL. These are generated files only; no hand-written code changed. Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
Contributor
|
🧪 CI tested the following changed modules:
Build reactor — dependencies compiled but only changed modules were tested (9 modules)
|
This was referenced May 4, 2026
oscerd
added a commit
that referenced
this pull request
May 4, 2026
…kport) Backport of #22866 onto camel-4.18.x. Disables creation and reading of jakarta.jms.ObjectMessage by default and adds a new objectMessageEnabled option (default false) on JmsConfiguration / JmsComponent / JmsEndpoint to opt back in. Existing camel-jms tests that rely on ObjectMessage have been updated to opt in, the camel-itest greeter / JmsJaxbTest fixtures have been updated likewise, and a JmsObjectMessageEnabledTest covers the default-disabled producer/consumer paths. Generated catalog descriptors and DSL builders for camel-jms / camel-activemq / camel-activemq6 / camel-amqp have been regenerated against 4.18.3-SNAPSHOT. The 4.21 upgrade-guide section was relocated to a new "Upgrading from 4.18.2 to 4.18.3" section in camel-4x-upgrade-guide-4_18.adoc. Closes #22918
oscerd
added a commit
that referenced
this pull request
May 5, 2026
…e by default (#22920) * CAMEL-23373: camel-jms - Disable ObjectMessage by default (#22866) * CAMEL-23373: camel-jms - Disable ObjectMessage by default Java object serialization over JMS is rarely used in practice and is a recurring source of security advisories. Disable creation and reading of jakarta.jms.ObjectMessage by default and add a new objectMessageEnabled option (default false) on JmsConfiguration / JmsComponent / JmsEndpoint to opt back in. When disabled, JmsBinding now refuses to: - create an ObjectMessage from a Serializable body (auto-detected jmsMessageType=Object or explicitly set) - create an ObjectMessage for transferExchange or transferException - extract the body of a received ObjectMessage Existing tests that rely on ObjectMessage have been updated to opt in. A new JmsObjectMessageEnabledTest validates the default disabled behavior on producer and consumer side, and JmsBindingTest covers the unit-level checks. Documentation updated in the 4.21 upgrade guide. Signed-off-by: Andrea Cosentino <ancosen@gmail.com> * CAMEL-23373: Regenerate camel-jms / camel-activemq* / camel-amqp DSL builders The componentdsl and endpointdsl builder factories for camel-jms and the JMS-derived components (camel-activemq, camel-activemq6, camel-amqp) needed to be regenerated to expose the new objectMessageEnabled option in the fluent DSL. These are generated files only; no hand-written code changed. Signed-off-by: Andrea Cosentino <ancosen@gmail.com> --------- Signed-off-by: Andrea Cosentino <ancosen@gmail.com> * CAMEL-23373: camel-jms - Disable ObjectMessage by default --------- Signed-off-by: Andrea Cosentino <ancosen@gmail.com> Co-authored-by: Claus Ibsen <claus.ibsen@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves CAMEL-23373. Disables creation and reading of
jakarta.jms.ObjectMessageby default incamel-jmsand adds a newobjectMessageEnabledoption (defaultfalse) to opt back in at the component or endpoint level.Java object serialization over JMS is rarely used in practice and is a recurring source of security advisories — the goal is to reduce the default attack surface and keep the feature available for users who explicitly need it.
Behavior
When
objectMessageEnabled=false(the new default),JmsBindingrefuses to:ObjectMessagefrom aSerializablebody (auto-detectedjmsMessageType=Objector explicitly set)ObjectMessagefortransferExchangeortransferExceptionrepliesObjectMessageIn each case,
IllegalStateExceptionis thrown with a message pointing the user at how to enable the option:To restore the previous behavior:
camel.component.jms.objectMessageEnabled=trueor per endpoint:
jms:queue:foo?objectMessageEnabled=true.Migration
Existing
camel-jmstests that rely onObjectMessagehave been updated to opt in viasetObjectMessageEnabled(true)on the component (or?objectMessageEnabled=trueon URLs). This matches the migration story end users will follow.The downstream JMS-derived components (
camel-activemq,camel-activemq6,camel-amqp) have had their generated catalogs / URI factories regenerated to expose the new option.What this PR contains
JmsConfiguration/JmsComponent: newobjectMessageEnabledoption (defaultfalse), withsecurity = "insecure:serialization"annotationJmsBinding: checks the flag inextractBodyFromJms,createJmsMessage(Exception, Session), thetransferExchangebranch ofcreateJmsMessage, and theObjectcase ofcreateJmsMessageForTypeJmsBindingTest: unit tests for the consumer-side default and opt-inJmsObjectMessageEnabledTest: new integration test verifying both producer and consumer refusal under the defaultobjectMessageEnabled=truecore/camel-util/src/main/java/org/apache/camel/util/SecurityUtils.java: regenerated security options mapdocs/user-manual/.../camel-4x-upgrade-guide-4_21.adoc: new "camel-jms" section documenting the changeTest plan
mvn testincomponents/camel-jms— 451 tests, 0 failuresmvn install -DskipTestsfrom root for the affected modules (camel-jms, camel-catalog, camel-util) — greenJmsObjectMessageEnabledTestcovers default-disabled producer and consumer behaviorJmsBindingTestcases cover the unit-level disabled-by-default and enabled pathsmvn verify -Pit) — has not been run locally; CI will exercise it🤖 Claude Code on behalf of Andrea Cosentino