Skip to content

CAMEL-24085: Apply header filter strategy to IronMQ message envelope headers#24828

Merged
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24085
Jul 17, 2026
Merged

CAMEL-24085: Apply header filter strategy to IronMQ message envelope headers#24828
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24085

Conversation

@oscerd

@oscerd oscerd commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Motivation

When receiving a message with preserveHeaders=true, the IronMQ consumer deserializes a JSON envelope (a headers map and a body) and copies the embedded header entries onto the Camel message (GsonUtil.copyFrom, called from IronMQConsumer) without applying a HeaderFilterStrategy. The envelope is fully sender-controlled, so a sender can inject Camel-internal control headers (the Camel* namespace) onto the exchange.

Changes

  • GsonUtil.copyFrom now routes the embedded envelope headers through a DefaultHeaderFilterStrategy (applyFilterToExternalHeaders), so Camel* headers (matched case-insensitively) are no longer mapped onto the Camel message — consistent with the inbound header filtering performed by other consumers, and with the same approach as the structured-mode CloudEvent fix in CAMEL-24084 (CAMEL-24084: Apply header filter strategy to structured-mode CloudEvent extension headers #24724).
  • New IronMQConsumerHeaderFilterTest pushing a crafted envelope through the existing MockQueue: ordinary headers still propagate, Camel* entries are filtered.
  • Upgrade-guide entry in camel-4x-upgrade-guide-4_22.adoc.

Note: camel-ironmq is deprecated since 4.21, but still ships; the same envelope mapping exists on the 4.18.x/4.14.x maintenance branches, so this is a backport candidate (those branches need the explicit setInFilterStartsWith variant, pre-CAMEL-23543).

Testing

  • mvn clean install in components/camel-ironmq: all tests pass (new test + existing preserve-headers round-trip).
  • Full reactor mvn clean install -DskipTests from root: success, no stale generated files.

Claude Code on behalf of Andrea Cosentino (@oscerd).

🤖 Generated with Claude Code

…headers

The IronMQ consumer deserializes a JSON envelope (a headers map and a body)
and copied the embedded header entries onto the Camel message without
applying a HeaderFilterStrategy. Route the envelope headers through a
HeaderFilterStrategy so Camel* headers (matched case-insensitively) present
in the sender-controlled envelope are filtered, consistent with the inbound
header filtering performed by other consumers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd
oscerd requested review from davsclaus and gnodet July 17, 2026 07:55
@oscerd oscerd added the enhancement New feature or request label Jul 17, 2026
@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.

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code on behalf of gnodet

LGTM — security fix for header injection via IronMQ message envelope.

This is exactly the kind of consumer-side header filtering gap the project's security model flags (untrusted input mapped into the Exchange header map without a HeaderFilterStrategy). The fix is consistent with the CloudEvent structured-mode fix in CAMEL-24084 (#24724).

Review notes:

  1. Correct patternDefaultHeaderFilterStrategy filters Camel* headers case-insensitively by default, matching the standard inbound filtering behavior of other consumers. The !applyFilterToExternalHeaders() negation correctly blocks filtered headers.

  2. Thread-safeDefaultHeaderFilterStrategy is stateless, so the private static final instance is safe for concurrent use across consumer threads.

  3. Existing-header precedence preserved — the target.getHeader(key) == null check remains, so component-set headers (like MESSAGE_ID) aren't overwritten by envelope data.

  4. Test — crafts a realistic attack payload with both CamelFileName (Pascal-case) and camelExecCommandExecutable (camel-case) injected headers. Verifies legitimate headers propagate while Camel* entries are filtered. Good case-insensitivity coverage.

  5. Upgrade guide — clear migration note following the same structure as the CloudEvent entry. Appropriate given the behavioral change for preserveHeaders=true consumers.

  6. Backport note — good call flagging the 4.18.x/4.14.x applicability with the setInFilterStartsWith variant needed for pre-CAMEL-23543 branches.

Minor: the component is deprecated since 4.21 but this fix is still worthwhile since it ships in 4.22 and the maintenance branches.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-ironmq
  • docs

🔬 Scalpel shadow comparison — Scalpel: 10 tested, 28 compile-only — current: 9 all tested

Maveniverse Scalpel detected 38 affected modules (current approach: 9).

⚠️ Modules only in Scalpel (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 10 modules (2 direct + 8 downstream), skip tests for 28 (generated code, meta-modules)

Modules Scalpel would test (10)
  • camel-ironmq
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
  • docs
Modules with tests skipped (28)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (38 modules)
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: IronMQ
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@oscerd oscerd self-assigned this Jul 17, 2026
@oscerd oscerd added this to the 4.22.0 milestone Jul 17, 2026
@oscerd
oscerd merged commit 81cee8e into apache:main Jul 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

components docs enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants