Skip to content

[backport camel-spring-boot-4.22.x] CAMEL-24503: camel-spring-boot - see camel properties supplied as environment variables - #1961

Merged
Croway merged 1 commit into
apache:camel-spring-boot-4.22.xfrom
Croway:backport/1913-to-camel-spring-boot-4.22.x
Sep 9, 2026
Merged

Croway merged 1 commit into
apache:camel-spring-boot-4.22.xfrom
Croway:backport/1913-to-camel-spring-boot-4.22.x

Conversation

@Croway

@Croway Croway commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Cherry-pick of #1913 onto camel-spring-boot-4.22.x.

Original PR: #1913 — camel-spring-boot - see camel properties supplied as environment variables
JIRA: CAMEL-24503

What it fixes

CamelSecurityPolicyAutoConfiguration.extractCamelProperties collected candidate properties by
matching each Spring Environment property name literally against the camel. prefix. That works
fine for properties coming from application.properties/YAML, but the systemEnvironment property
source reports names in their native form (e.g. CAMEL_COMPONENT_FOO_BAR), which never starts with
camel. — even though Spring Boot's relaxed binding still applies that value to the Camel component
regardless of how it is expressed.

The practical effect was a security-policy bypass: the camel.security policy check introduced in
CAMEL-23250 was blind to any Camel option supplied via environment variables, which is the standard
way to configure a containerised deployment (Docker/Kubernetes env vars, .env files, etc.). A
policy-violating option set that way would silently take effect on the component while going
completely unnoticed by the check.

The fix canonicalizes each reported property name with ConfigurationPropertyName.adapt(name, '_')
before testing the camel. prefix, and performs the environment lookup using that canonical name so
relaxed binding resolves it back to the actual value. SecurityUtils.getSecurityOption already
lowercases and strips dashes, so the canonicalized name still matches the same security option
correctly.

Branch applicability

Confirmed camel-spring-boot-4.18.x does not carry CAMEL-23250's security-policy feature, so this fix does not
apply there — 4.22.x only.

Verification on this branch

  • Cherry-pick (git cherry-pick -x) applied cleanly with no conflicts; the diff touches only
    CamelSecurityPolicyAutoConfiguration.java and CamelSecurityPolicyAutoConfigurationTest.java in
    core/camel-spring-boot.
  • Ran CamelSecurityPolicyAutoConfigurationTest directly: 12/12 tests passed.
  • Ran the full core/camel-spring-boot module verify (mvn verify): 140 tests run, 0 failures, 0
    errors, 1 skipped (pre-existing, unrelated to this change), plus 2 passing integration tests
    (CamelVirtualThreadsIT). Overall BUILD SUCCESS.
  • (Local-build-only workaround: temporarily repointed the unresolvable SNAPSHOT parent/camel-version
    to the released 4.22.0 to allow a from-scratch build; those edits were reverted before pushing —
    this PR contains only the cherry-picked commit.)

Claude Code on behalf of Federico Mariani

…ironment variables

extractCamelProperties filtered on the property name exactly as its source
reports it. The systemEnvironment source reports environment variables in their
native CAMEL_COMPONENT_FOO_BAR form, which never matches the "camel." prefix, so
any Camel option configured through the environment was invisible to the
camel.security policy check added in CAMEL-23250 - even though Spring's relaxed
binding applies it to the component regardless.

That is the usual way to configure a containerised application, so the check was
blind to a large part of real deployments.

Names are now canonicalized with ConfigurationPropertyName.adapt before the
prefix test, and the canonical name is used for the lookup so relaxed binding
resolves it back to the variable. SecurityUtils.getSecurityOption already
lowercases and strips dashes, so the canonical name matches the same option.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
(cherry picked from commit 27fb340)
@Croway
Croway requested review from davsclaus and oscerd September 9, 2026 10:52
@Croway
Croway merged commit a138212 into apache:camel-spring-boot-4.22.x Sep 9, 2026
2 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