Skip to content

[backport camel-4.18.x] CAMEL-23321: Add deserialization filtering for JMS ObjectMessage handling in camel-jms and camel-sjms#22603

Merged
oscerd merged 4 commits intoapache:camel-4.18.xfrom
oscerd:backport/22598-to-camel-4.18.x
Apr 14, 2026
Merged

[backport camel-4.18.x] CAMEL-23321: Add deserialization filtering for JMS ObjectMessage handling in camel-jms and camel-sjms#22603
oscerd merged 4 commits intoapache:camel-4.18.xfrom
oscerd:backport/22598-to-camel-4.18.x

Conversation

@oscerd
Copy link
Copy Markdown
Contributor

@oscerd oscerd commented Apr 14, 2026

Backport of #22598

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

Original PR: #22598 - CAMEL-23321: Add deserialization filtering for JMS ObjectMessage handling in camel-jms and camel-sjms
Original author: @oscerd
Target branch: camel-4.18.x
Jira: https://issues.apache.org/jira/browse/CAMEL-23321

Two commits cherry-picked in order:

  1. CAMEL-23321: Add deserialization filtering for JMS ObjectMessage handling in camel-jms and camel-sjms
  2. Regen

Conflict resolution

One minor, style-only conflict in components/camel-sjms/src/main/java/org/apache/camel/component/sjms/jms/JmsBinding.java. main had been refactored to use pattern-matching instanceof (payload instanceof DefaultExchangeHolder holder); camel-4.18.x still uses the explicit-cast style. Resolved by keeping the existing 4.18.x style and adding only the security-relevant change:

Object payload = objectMessage.getObject();
checkDeserializedClass(payload);                         // added
if (payload instanceof DefaultExchangeHolder) {
    DefaultExchangeHolder holder = (DefaultExchangeHolder) payload;
    DefaultExchangeHolder.unmarshal(exchange, holder);   // NOSONAR
    return exchange.getIn().getBody();
}

All other code (the checkDeserializedClass method itself, the new deserializationFilter option on JmsConfiguration / SjmsEndpoint, generated descriptors, DSL factories) was auto-merged cleanly.

Verification

  • Cherry-pick applied successfully (one conflict, resolved as described above)
  • camel-jms and camel-sjms compile cleanly on the camel-4.18.x baseline
  • Apache CI will run the authoritative test suite

Claude Code on behalf of Andrea Cosentino

…ling in camel-jms and camel-sjms

Aligns the JMS component family with the defense-in-depth pattern applied in
camel-netty (CAMEL-23297) and camel-mina (CAMEL-23319).

JmsBinding (camel-jms and camel-sjms) now resolves a deserialization filter at
construction using the same priority as the other components:
  configured value -> JVM -Djdk.serialFilter -> default "java.**;javax.**;org.apache.camel.**;!*".
After ObjectMessage.getObject(), the class of the returned payload is checked
against the filter and a SecurityException is thrown on reject. The filter is
exposed as a new endpoint option 'deserializationFilter' on JmsConfiguration
(camel-jms) and SjmsEndpoint (camel-sjms).

Note: this check runs after the JMS provider has deserialized the payload, so
the option does not, on its own, stop gadget chains that execute inside the
provider's ObjectInputStream. The javadoc makes this explicit and points users
to JVM-wide -Djdk.serialFilter and provider-specific filters for complete
coverage. camel-amqp inherits the behaviour via AMQPJmsBinding.

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd oscerd requested a review from davsclaus April 14, 2026 09:34
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd oscerd force-pushed the backport/22598-to-camel-4.18.x branch from 53ed738 to c311624 Compare April 14, 2026 10:14
oscerd added 2 commits April 14, 2026 12:55
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
…ling in camel-jms and camel-sjms

Configure deserializationFilter in CxfToJmsInOutTest and JmsToCxfInOutTest
Spring contexts to allow org.apache.cxf.** classes alongside the defaults,
so MessageContentsList payloads exchanged over JMS ObjectMessage pass the
filter introduced in CAMEL-23321.

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd oscerd merged commit 0c06142 into apache:camel-4.18.x Apr 14, 2026
3 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