Skip to content

CAMEL-23942: contain Azure Storage Blob/DataLake fileDir downloads within the configured directory#24542

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

CAMEL-23942: contain Azure Storage Blob/DataLake fileDir downloads within the configured directory#24542
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-23942

Conversation

@oscerd

@oscerd oscerd commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What

The remote-file consumers (camel-file, camel-ftp, camel-smb, camel-mina-sftp) and camel-azure-files constrain their local downloads to the configured local directory using a path-segment boundary check — the containment added in CAMEL-23765 and made boundary-aware in CAMEL-23868 (GenericFileHelper.isWithinDirectory / jailToLocalWorkDirectory).

The Azure Storage Blob and DataLake consumers did not apply an equivalent check. When fileDir is configured, the local download target was built directly from the remote object name via new File(fileDir, name), so a name containing ../ segments could resolve to a location outside fileDir. This change brings the two Azure Storage consumers in line with the rest of the file-download consumer family.

How

  • New shared helper AzureFileNameHelper.resolveWithinDirectory(fileDir, name) in camel-azure-common (already a dependency of both storage modules). It resolves the name against fileDir, normalizes lexically, and verifies the result stays within fileDir on path-segment boundaries, throwing IllegalArgumentException otherwise. It uses only java.nio.file, so it adds no new dependency and does not depend on camel-file.
  • Wired into BlobOperations.downloadBlobToFile and DataLakeFileOperations.downloadToFile.

Tests

  • AzureFileNameHelperTest — rejects parent/deep ../ traversal and a sibling directory that merely shares a name prefix (segment boundary, not string prefix); accepts simple/nested names and an internal .. that normalizes back inside the directory.
  • BlobOperationsTest / DataLakeFileOperationTest — each asserts a ../-bearing object name is rejected at the download call site.

Notes

  • No public API or @UriParam changes; the full reactor build produced no regenerated catalog/DSL drift.

Issue: https://issues.apache.org/jira/browse/CAMEL-23942


Claude Code on behalf of oscerd

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Jul 8, 2026

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.

…thin the configured directory

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd oscerd force-pushed the fix/CAMEL-23942 branch from f95661b to aeaf183 Compare July 8, 2026 19:23
@github-actions github-actions Bot added the docs label Jul 8, 2026
@oscerd oscerd requested review from davsclaus and gnodet July 8, 2026 19:26
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-azure/camel-azure-common
  • components/camel-azure/camel-azure-storage-blob
  • components/camel-azure/camel-azure-storage-datalake
  • docs

🔬 Scalpel shadow comparison — Scalpel: 20 tested, 28 compile-only — current: 19 all tested

Maveniverse Scalpel detected 48 affected modules (current approach: 19).

⚠️ 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 20 modules (4 direct + 16 downstream), skip tests for 28 (generated code, meta-modules)

Modules Scalpel would test (20)
  • camel-azure-common
  • camel-azure-cosmosdb
  • camel-azure-eventgrid
  • camel-azure-eventhubs
  • camel-azure-files
  • camel-azure-functions
  • camel-azure-key-vault
  • camel-azure-servicebus
  • camel-azure-storage-blob
  • camel-azure-storage-datalake
  • camel-azure-storage-queue
  • 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 (48 modules)
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Azure :: Common
  • Camel :: Azure :: CosmosDB
  • Camel :: Azure :: Event Grid
  • Camel :: Azure :: Event Hubs
  • Camel :: Azure :: Files
  • Camel :: Azure :: Functions
  • Camel :: Azure :: Key Vault
  • Camel :: Azure :: ServiceBus
  • Camel :: Azure :: Storage Blob
  • Camel :: Azure :: Storage Datalake
  • Camel :: Azure :: Storage Queue
  • 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 :: 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

@davsclaus davsclaus 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.

Clean security hardening fix that brings the Azure Storage Blob and DataLake fileDir downloads in line with the containment already present in camel-file/camel-ftp/camel-smb/camel-mina-sftp (CAMEL-23765, CAMEL-23868) and camel-azure-files.

Verified:

  • Both unguarded call sites (BlobOperations.java:156, DataLakeFileOperations.java:109) have been present since 2021. No remaining unguarded new File(fileDir, ...) patterns in components/camel-azure/.
  • Path.normalize() + Path.startsWith() is a correct containment check with inherent segment-boundary enforcement.
  • Tests are comprehensive: simple/nested names, internal ../ that normalizes back inside, parent traversal, deep traversal, sibling-prefix attack, plus integration tests in both Blob and DataLake.
  • Helper in camel-azure-common avoids cross-module dependency on camel-file.
  • Upgrade guide entry present.

LGTM.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants