Repository navigation
CAMEL-23522: camel-mail - gate JavaMail session properties from headers behind opt-in - #23362
Merged
Merged
Conversation
…rs behind opt-in 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>
davsclaus
approved these changes
May 20, 2026
Croway
approved these changes
May 20, 2026
Contributor
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
Contributor
|
🧪 CI tested the following changed modules:
Build reactor — dependencies compiled but only changed modules were tested (5 modules)
|
davsclaus
approved these changes
May 20, 2026
oscerd
added a commit
that referenced
this pull request
May 21, 2026
…rs behind opt-in (#23362) (#23381) 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
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>
oscerd
added a commit
that referenced
this pull request
May 21, 2026
…ating (#23418) Mirror the 4.14.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.14.x (#23416), the 4.18.x backport (#23381), the 4.18 doc-sync (#23383) and the main PR (#23362). Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
oscerd
added a commit
that referenced
this pull request
May 21, 2026
…rs behind opt-in (#23362) (#23416) 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>
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
Companion to CAMEL-23222 / the CVE-2025-27636 header-injection family, addressing a namespace missed in that sweep.
MailProducer.getSenderextractedmail.smtp.*/mail.smtps.*exchange headers and applied them as JavaMail session properties on a per-message custom sender. The namespace is Camel-internal (onlyMailProducerinterprets it) and is not filtered by anyHeaderFilterStrategy. A route chaining an untrusted producer (e.g.platform-httpquery parameters, JMS/Kafka from untrusted producers) intosmtp/smtpswithout an explicitremoveHeadersbetween 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 PR makes the per-message override opt-in.
Changes
MailConfiguration— new@UriParamuseJavaMailSessionPropertiesFromHeaders(defaultfalse,label="producer,advanced,security",security="insecure:ssl"). Picked up automatically by theSECURITY-OPTIONSgenerator and added tocore/camel-util/SecurityUtilsso the project-wide security-policy framework can govern it.MailProducer.getSender— returns the default sender unconditionally when the flag isfalse. Existing extraction path preserved when the flag istrue.MailHeaderFilterStrategy— extends the inboundsetInFilterStartsWithset withmail.smtp./mail.smtps.(defense in depth, mirroring CAMEL-23222 for theCamel*namespace). Outbound filtering is unchanged.mail-component.adocdocuments the new opt-in URI and the security caveat, with a cross-link to the project security model; pre-existingjava.smtp.typo in the same section corrected tomail.smtp..camel-mailentry incamel-4x-upgrade-guide-4_21.adocdocumenting the default tightening and the opt-in URI.MailSessionPropertiesFromHeadersTestcovers both flag values plus the no-header path;MailHeaderFilterStrategyTestcovers the new inbound prefix filtering, retention ofCamel*filtering, ordinary mail headers passing through, and outbound being unaffected.Backwards compatibility
This is a default-tightening breaking change, intentionally aligned with the CAMEL-23222 / CVE-2025-27636-family precedent of shipping default-secure even in patch releases. Routes that legitimately rely on per-message
mail.smtp.*headers must opt back in on the endpoint:Even with the opt-in enabled, route authors should still strip the namespace with
removeHeaders("mail.smtp.*", "mail.smtps.*")between any untrusted ingress and the mail producer — see the upgrade guide for the full rationale.Test plan
mvn testincomponents/camel-mail— 218/218 pass (4 skipped, no regressions).MailSessionPropertiesFromHeadersTest(3 tests),MailHeaderFilterStrategyTest(4 tests).mvn clean install -DskipTestsfrom root — exit 0; cross-module catalog mirrors, DSL builder factories, endpoint DSL, andSecurityUtilsregen all included in the commit.Backports
fixVersionson the Jira issue are4.21.0,4.18.3,4.14.8. The 4.18.x and 4.14.x backports will need light adaptation:mainpost-PR; straightforward cherry-pick.mail.smtps.fallback) and CAMEL-23308 (noconfigureJavaMailSenderon the custom sender). The flag and thegetSendergate apply identically; theMailHeaderFilterStrategychange applies identically.Backport PRs to follow once this lands on
main.Linked issue
https://issues.apache.org/jira/browse/CAMEL-23522
Claude Code on behalf of Andrea Cosentino