Skip to content

[backport camel-4.18.x] CAMEL-23522: camel-mail - gate JavaMail session properties from headers behind opt-in#23381

Merged
oscerd merged 1 commit into
apache:camel-4.18.xfrom
oscerd:backport/23362-to-camel-4.18.x
May 21, 2026
Merged

[backport camel-4.18.x] CAMEL-23522: camel-mail - gate JavaMail session properties from headers behind opt-in#23381
oscerd merged 1 commit into
apache:camel-4.18.xfrom
oscerd:backport/23362-to-camel-4.18.x

Conversation

@oscerd
Copy link
Copy Markdown
Contributor

@oscerd oscerd commented May 20, 2026

Backport of #23362

Cherry-pick of #23362 onto camel-4.18.x (Jira: CAMEL-23522, fixVersion 4.18.3).

Original PR: #23362CAMEL-23522: camel-mail - gate JavaMail session properties from headers behind opt-in
Original author: @oscerd
Target branch: camel-4.18.x

Branch-specific adjustments

  • The security = "insecure:ssl" attribute was removed from the @UriParam. @UriParam.security was introduced together with the security-policy enforcement framework (CAMEL-23250 / core/camel-util/SecurityUtils), which lives only on main / 4.21. On 4.18.x the categorisation is preserved through label = "producer,advanced,security" only.
  • The corresponding core/camel-util/SecurityUtils change was dropped for the same reason — the file does not exist on this branch.
  • The upgrade-guide entry was added to camel-4x-upgrade-guide-4_18.adoc under "Upgrading from 4.18.2 to 4.18.3" (the 4_21 file used on main does not exist on this branch).
  • The xref:manual::security-model.adoc[…] cross-link in mail-component.adoc was dropped because security-model.adoc was introduced on main only (CAMEL-23496) and is not present on 4.18.x — the xref-check would fail.
  • The new test class imports org.apache.camel.test.junit5.CamelTestSupport (instead of the junit6 package used on main).

A separate doc-sync PR will mirror the 4.18 upgrade-guide entry onto main, per the project's "Backport upgrade-guide policy" in CLAUDE.md.

Verification on camel-4.18.x

  • mvn test in components/camel-mail — 218/218 pass (4 skipped, no failures); 7 new tests green (MailSessionPropertiesFromHeadersTest + MailHeaderFilterStrategyTest).
  • Full-reactor mvn clean install -DskipTests exits 0 with all generated catalog mirrors, DSL builder factories, endpoint DSL, and component metadata regenerated and committed.

Original description (from #23362)

MailProducer.getSender extracted mail.smtp.* / mail.smtps.* exchange headers and applied them as JavaMail session properties on a per-message custom sender. The namespace is Camel-internal (only MailProducer interprets it) and is not filtered by any HeaderFilterStrategy. A route chaining an untrusted producer (e.g. platform-http query parameters, JMS/Kafka from untrusted producers) into smtp/smtps without an explicit removeHeaders between them therefore let an attacker drive transport-security settings: mail.smtp.ssl.trust, mail.smtp.ssl.checkserveridentity, mail.smtp.starttls.enable, mail.smtp.socks.host, etc.

This is the same conceptual pattern as the Camel* header-injection family (CAMEL-23222 / CVE-2025-27636), with a namespace that was missed in that sweep. The fix makes the per-message override opt-in (useJavaMailSessionPropertiesFromHeaders, default false).


Claude Code on behalf of Andrea Cosentino

…rs behind opt-in (apache#23362)

MailProducer.getSender extracted mail.smtp.* / mail.smtps. exchange headers and applied them as
JavaMail session properties on a per-message custom sender. The namespace is Camel-internal
(only MailProducer interprets it) and is not filtered by any HeaderFilterStrategy, so a route
chaining an untrusted producer (platform-http, JMS, Kafka, ...) into smtp/smtps without an
explicit removeHeaders between them let an attacker drive transport-security settings
(mail.smtp.ssl.trust, mail.smtp.starttls.enable, mail.smtp.socks.host, ...).

This is the same conceptual pattern as the Camel* header injection family (CAMEL-23222 /
CVE-2025-27636), with a namespace that was missed in that sweep.

Changes:

* New @UriParam useJavaMailSessionPropertiesFromHeaders (default false, label
  producer,advanced,security, security=insecure:ssl) on MailConfiguration. When false,
  MailProducer.getSender always returns the default sender.
* MailHeaderFilterStrategy now also filters mail.smtp. / mail.smtps. on the inbound path
  (defense in depth, mirroring CAMEL-23222).
* Doc note in mail-component.adoc with the security warning and the opt-in URI.
* Upgrade-guide entry in camel-4x-upgrade-guide-4_21.adoc.
* Tests for both flag values and for the header-filter strategy behaviour.

The build's SECURITY-OPTIONS generator picked up the new annotation and added the property to
the policy-enforceable map in core/camel-util SecurityUtils.

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd oscerd requested review from Croway, davsclaus and gnodet May 20, 2026 16:01
@oscerd oscerd merged commit 725175e into apache:camel-4.18.x May 21, 2026
3 checks passed
oscerd added a commit that referenced this pull request May 21, 2026
…ating (#23383)

Mirror the 4.18.x upgrade-guide entry for CAMEL-23522 (camel-mail - gate JavaMail session
properties from headers behind opt-in) onto main, per the project's backport upgrade-guide
policy: the camel-4x-upgrade-guide-4_XX.adoc files on main act as the canonical history
across all releases, so any entry added on a maintenance branch must also land here.

Companion to the backport PR against camel-4.18.x (#23381) and the main PR (#23362).

Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
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.

3 participants