[backport camel-4.18.x] CAMEL-24548 CAMEL-24549: Harden cloud storage download containment - #25991
Conversation
Backport of #25873 to camel-4.18.x. Local downloads in camel-azure-storage-blob, camel-azure-storage-datalake, and camel-google-storage now resolve existing filesystem path segments before checking that the destination stays inside the configured directory, rejecting a symbolic link inside the download directory that resolves outside of it. This branch predates the shared camel-azure-common module and AzureFileNameHelper, so the Azure fix is applied directly to the duplicated resolveWithinDirectory() methods in BlobOperations and DataLakeFileOperations instead. The Google fix is a direct port, since GoogleCloudStorageFileNameHelper is unchanged from main. The upgrade-guide note was added to the existing "Upgrading from 4.18.4 to 4.18.5" section of camel-4x-upgrade-guide-4_18.adoc. Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
gnodet
left a comment
There was a problem hiding this comment.
Adapted backport of PR #25873 to camel-4.18.x — the security fix (path traversal via symlink resolution) is correctly adapted. The resolveExistingPathSegments logic is identical across all inlined locations and matches the original shared utility class. CI is green.
Minor observations (informational, not blocking):
-
Test coverage gap: The backport tests for BlobOperations and DataLakeFileOperations only cover the basic symlink case but not the parent-segment-after-symlink case (
link/../file.txt) that the originalAzureFileNameHelperTestcovers. The logic is identical to GoogleCloudStorageFileNameHelper which does cover both cases, so this is a minor test coverage gap, not a security gap. -
Upgrade guide on
main: Per the project's backport upgrade-guide policy, this entry should also be added tocamel-4x-upgrade-guide-4_18.adoconmain— either as part of this workflow or in a follow-up doc-sync PR.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
Backport of #25873
Adaptation of #25873 onto
camel-4.18.x.Original PR: #25873 - CAMEL-24548 CAMEL-24549: Harden cloud storage download containment
Original author: @oscerd
Target branch:
camel-4.18.xOriginal description
This hardens local download path containment in the Azure Blob/DataLake and Google Storage components by resolving existing filesystem path segments before accepting a destination. It preserves valid nested paths while rejecting linked paths that resolve beyond the configured directory.
JIRA:
Note on this backport
Not a mechanical cherry-pick.
camel-4.18.xpredates the sharedcamel-azure-commonmodule andAzureFileNameHelperintroduced later — this module doesn't exist at all on this branch. Each Azurecomponent instead has its own duplicated private
resolveWithinDirectory()method(
BlobOperationsandDataLakeFileOperations), matching the pre-fix logic onmainexactly. The samehardening (resolve existing path segments via
Files.exists(..., NOFOLLOW_LINKS)+toRealPath()before the containment check) was applied directly to both duplicated methods, with equivalent new
tests added to
BlobOperationsTestandDataLakeFileOperationTest(via the publicdownloadBlobToFile/downloadToFileentry points, since there's no shared helper class to unit-testdirectly here).
The Google fix is a direct, unmodified port:
GoogleCloudStorageFileNameHelperon this branch isidentical to its pre-fix state on
main.As with the
camel-4.22.xbackport (#25990), the upgrade-guide entry was added to the existing"Upgrading from 4.18.4 to 4.18.5" section of
camel-4x-upgrade-guide-4_18.adoc, sincecamel-4x-upgrade-guide-4_23.adocdoesn't exist on this branch.Verification on this branch:
BlobOperationsTest: 6 passed (incl. new symlink-containment test)DataLakeFileOperationTest: 5 passed (incl. new symlink-containment test)GoogleCloudStorageFileNameHelperTest: 10 passedGiven the manual adaptation, this should go through a normal review rather than the no-review
backport fast path.
Claude Code on behalf of davsclaus