Skip to content

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

Merged
oscerd merged 2 commits intoapache:mainfrom
oscerd:ci-issue-CAMEL-23373
Apr 30, 2026
Merged

CAMEL-23373: camel-jms - Disable ObjectMessage by default#22866
oscerd merged 2 commits intoapache:mainfrom
oscerd:ci-issue-CAMEL-23373

Conversation

@oscerd
Copy link
Copy Markdown
Contributor

@oscerd oscerd commented Apr 30, 2026

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.

Migration

Existing camel-jms tests that rely on ObjectMessage have been updated to opt in via setObjectMessageEnabled(true) on the component (or ?objectMessageEnabled=true on 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: new objectMessageEnabled option (default false), with security = "insecure:serialization" annotation
  • JmsBinding: checks the flag in extractBodyFromJms, createJmsMessage(Exception, Session), the transferExchange branch of createJmsMessage, and the Object case of createJmsMessageForType
  • JmsBindingTest: unit tests for the consumer-side default and opt-in
  • JmsObjectMessageEnabledTest: new integration test verifying both producer and consumer refusal under the default
  • 14 existing tests updated to opt in to objectMessageEnabled=true
  • core/camel-util/src/main/java/org/apache/camel/util/SecurityUtils.java: regenerated security options map
  • docs/user-manual/.../camel-4x-upgrade-guide-4_21.adoc: new "camel-jms" section documenting the change

Test plan

  • mvn test in components/camel-jms — 451 tests, 0 failures
  • mvn install -DskipTests from root for the affected modules (camel-jms, camel-catalog, camel-util) — green
  • New JmsObjectMessageEnabledTest covers default-disabled producer and consumer behavior
  • New JmsBindingTest cases cover the unit-level disabled-by-default and enabled paths
  • Full integration test run (mvn verify -Pit) — has not been run locally; CI will exercise it

🤖 Claude Code on behalf of Andrea Cosentino

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>
@oscerd oscerd requested review from davsclaus and orpiske April 30, 2026 10:12
@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@davsclaus
Copy link
Copy Markdown
Contributor

modified:   dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Activemq6ComponentBuilderFactory.java
modified:   dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ActivemqComponentBuilderFactory.java
modified:   dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AmqpComponentBuilderFactory.java
modified:   dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/JmsComponentBuilderFactory.java
modified:   dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AMQPEndpointBuilderFactory.java
modified:   dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ActiveMQ6EndpointBuilderFactory.java
modified:   dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ActiveMQEndpointBuilderFactory.java
modified:   dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/JmsEndpointBuilderFactory.java

…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>
@github-actions github-actions Bot added the dsl label Apr 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • catalog/camel-catalog
  • components/camel-activemq
  • components/camel-activemq6
  • components/camel-amqp
  • components/camel-jms
  • core/camel-util
  • docs
  • dsl/camel-componentdsl
  • dsl/camel-endpointdsl

ℹ️ Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the test-dependents label to force testing all dependents.

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • components/camel-jms: 8 test(s) disabled on GitHub Actions
Build reactor — dependencies compiled but only changed modules were tested (9 modules)
  • Camel :: AMQP
  • Camel :: ActiveMQ 5.x
  • Camel :: ActiveMQ 6.x
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Component DSL
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: JMS
  • Camel :: Util

⚙️ View full build and test results

@oscerd oscerd merged commit 6cb29c0 into apache:main Apr 30, 2026
7 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants