CAMEL-24627: resolve symlinks when containing local work directory downloads - #26121
Open
oscerd wants to merge 1 commit into
Open
CAMEL-24627: resolve symlinks when containing local work directory downloads#26121oscerd wants to merge 1 commit into
oscerd wants to merge 1 commit into
Conversation
…wnloads GenericFileHelper.jailToLocalWorkDirectory performed a lexical path-boundary check only. It now also resolves the existing filesystem path segments (following symbolic links) before checking that the destination stays inside the configured localWorkDirectory, so a symbolic link inside the work directory that resolves outside of it cannot be used to write files elsewhere. This brings the file-based components (camel-file, camel-ftp/sftp, camel-smb, camel-mina-sftp, camel-azure-files) to parity with the cloud storage hardening done in CAMEL-24548 / CAMEL-24549. Valid nested download paths continue to work unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
GenericFileHelper.jailToLocalWorkDirectory— used by the file-based components to keep downloads within the configuredlocalWorkDirectory— performed a lexical path-boundary check only. A symbolic link inside the work directory that resolves outside of it could therefore be used to write files elsewhere on the filesystem.This change brings it to parity with the cloud storage hardening done in CAMEL-24548 / CAMEL-24549 (
AzureFileNameHelper/GoogleCloudStorageFileNameHelper): after the lexical check, the existing filesystem path segments are resolved (following symbolic links) and the containment is re-verified. Valid nested download paths continue to work unchanged.Affected components
Fix lives in the shared
camel-filehelper, so all callers benefit:camel-file,camel-ftp(FTP + SFTP),camel-smb,camel-mina-sftp,camel-azure-filesChanges
GenericFileHelper.jailToLocalWorkDirectorynow resolves existing path segments and re-checks containment (defensively guarded; skipped when no work directory boundary is configured).resolveExistingPathSegmentsmirroring the approach inAzureFileNameHelper.GenericFileHelperTest.Testing
mvn test -Dtest=GenericFileHelperTestincomponents/camel-file— all green (existing lexical cases + new symlink case; the symlink test self-skips on platforms without symlink support).Claude Code on behalf of oscerd
🤖 Generated with Claude Code