Skip to content

CAMEL-24627: resolve symlinks when containing local work directory downloads - #26121

Open
oscerd wants to merge 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24627
Open

CAMEL-24627: resolve symlinks when containing local work directory downloads#26121
oscerd wants to merge 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24627

Conversation

@oscerd

@oscerd oscerd commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Description

GenericFileHelper.jailToLocalWorkDirectory — used by the file-based components to keep downloads within the configured localWorkDirectory — 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-file helper, so all callers benefit:

  • camel-file, camel-ftp (FTP + SFTP), camel-smb, camel-mina-sftp, camel-azure-files

Changes

  • GenericFileHelper.jailToLocalWorkDirectory now resolves existing path segments and re-checks containment (defensively guarded; skipped when no work directory boundary is configured).
  • Added resolveExistingPathSegments mirroring the approach in AzureFileNameHelper.
  • Added a symlink-escape test case to GenericFileHelperTest.
  • Upgrade guide note added for 4.23.

Testing

  • mvn test -Dtest=GenericFileHelperTest in components/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

…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>
@oscerd
oscerd requested review from davsclaus and gnodet September 4, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant