Skip to content

[backport camel-4.18.x] CAMEL-23373: camel-jms - Disable ObjectMessage by default#22918

Merged
oscerd merged 3 commits intoapache:camel-4.18.xfrom
oscerd:backport/22866-to-camel-4.18.x
May 4, 2026
Merged

[backport camel-4.18.x] CAMEL-23373: camel-jms - Disable ObjectMessage by default#22918
oscerd merged 3 commits intoapache:camel-4.18.xfrom
oscerd:backport/22866-to-camel-4.18.x

Conversation

@oscerd
Copy link
Copy Markdown
Contributor

@oscerd oscerd commented May 4, 2026

Backport of #22866

Cherry-pick of #22866 onto camel-4.18.x.

Original PR: #22866 - CAMEL-23373: camel-jms - Disable ObjectMessage by default
Original author: @oscerd
Target branch: camel-4.18.x

Conflict resolution notes

The cherry-pick required a few manual resolutions because camel-4.18.x does not yet carry the security-options infrastructure introduced on main:

  • Dropped the security = "insecure:serialization" attribute from @UriParam annotations on objectMessageEnabled, transferException, and transferExchange in JmsConfiguration — the security attribute does not exist on @UriParam / @Metadata in 4.18.x.
  • Dropped the regenerated core/camel-util/src/main/java/org/apache/camel/util/SecurityUtils.java — the SecurityUtils registry does not exist on 4.18.x.
  • Stripped the "security": "insecure:serialization" JSON entries from the regenerated catalog and component descriptor JSON files for the same reason (they would otherwise carry a key the 4.18.x catalog format does not declare).
  • Moved the upgrade-guide content from the (non-existent on 4.18.x) camel-4x-upgrade-guide-4_21.adoc into a new Upgrading from 4.18.2 to 4.18.3 section of camel-4x-upgrade-guide-4_18.adoc.

The functional behavior matches the original PR: objectMessageEnabled defaults to false, JmsBinding refuses to create or read jakarta.jms.ObjectMessage instances unless the option is enabled, all existing tests that rely on ObjectMessage opt in via setObjectMessageEnabled(true) (or ?objectMessageEnabled=true), and the new JmsObjectMessageEnabledTest covers default-disabled producer / consumer paths.

Sanity build

  • mvn -pl :camel-jms -am -DskipTests=true install — green
  • mvn -pl :camel-activemq,:camel-activemq6,:camel-amqp,:camel-catalog -am -DskipTests=true install — green

Original description

Summary

Resolves CAMEL-23373. Disables creation and reading of jakarta.jms.ObjectMessage by default in camel-jms and adds a new objectMessageEnabled option (default false) 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), JmsBinding refuses to:

  • create an ObjectMessage from a Serializable body (auto-detected jmsMessageType=Object or explicitly set)
  • create an ObjectMessage for transferExchange or transferException replies
  • extract the body of a received ObjectMessage

In each case, IllegalStateException is thrown with a message pointing the user at how to enable the option:

JMS ObjectMessage is disabled by default for security reasons (...). Set objectMessageEnabled=true on the JMS endpoint or component to enable it.

To restore the previous behavior:

camel.component.jms.objectMessageEnabled=true

or per endpoint: jms:queue:foo?objectMessageEnabled=true.

🤖 Claude Code on behalf of Andrea Cosentino

oscerd added 2 commits May 4, 2026 14:28
* 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>
Re-run the catalog generator on the backport so the JSON descriptors match
the 4.18.x source: bumps the version field from 4.21.0-SNAPSHOT to
4.18.3-SNAPSHOT and reverts a couple of option descriptions that were
clarified separately on main but not part of this fix.

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@davsclaus
Copy link
Copy Markdown
Contributor

btw there are (some) unit test fixes in itest that are related to this, that can be backported afterwards

commit 98926bb
Author: Claus Ibsen claus.ibsen@gmail.com
Date: Sat May 2 08:25:42 2026 +0200

CAMEL-23373: camel-jms - Disable ObjectMessage by default

@oscerd oscerd merged commit 844bbf8 into apache:camel-4.18.x May 4, 2026
3 of 5 checks passed
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.

2 participants