CAMEL-23942: contain Azure Storage Blob/DataLake fileDir downloads within the configured directory#24542
Conversation
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
…thin the configured directory Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 20 tested, 28 compile-only — current: 19 all testedMaveniverse Scalpel detected 48 affected modules (current approach: 19).
|
davsclaus
left a comment
There was a problem hiding this comment.
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 unguardednew File(fileDir, ...)patterns incomponents/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-commonavoids cross-module dependency oncamel-file. - Upgrade guide entry present.
LGTM.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
What
The remote-file consumers (
camel-file,camel-ftp,camel-smb,camel-mina-sftp) andcamel-azure-filesconstrain 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
fileDiris configured, the local download target was built directly from the remote object name vianew File(fileDir, name), so a name containing../segments could resolve to a location outsidefileDir. This change brings the two Azure Storage consumers in line with the rest of the file-download consumer family.How
AzureFileNameHelper.resolveWithinDirectory(fileDir, name)incamel-azure-common(already a dependency of both storage modules). It resolves the name againstfileDir, normalizes lexically, and verifies the result stays withinfileDiron path-segment boundaries, throwingIllegalArgumentExceptionotherwise. It uses onlyjava.nio.file, so it adds no new dependency and does not depend oncamel-file.BlobOperations.downloadBlobToFileandDataLakeFileOperations.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
@UriParamchanges; 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