[
https://issues.apache.org/jira/browse/CAMEL-27453?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18149851#comment-18149851
]
Guillaume Nodet commented on CAMEL-27453:
-----------------------------------------
This issue is being investigated by a coding agent (on behalf of gnodet).
Triage analysis: Real bug confirmed in code. `FileUtil.compactPath` (used by
`RemoteFileConsumer.isWithinStartingDirectory`,
`GenericFileProducer.jailedCheck`, and `SmbConsumer.isWithinStartingDirectory`)
treats http:/https:/file:/classpath: prefixes as URI schemes and handles
Windows drive letters specially. These general-purpose path conventions do not
apply to remote file paths. For an FTP endpoint with no configured directory,
`compactPath` could mishandle paths whose segments resemble schemes or drive
letters, producing normalizations that could bypass the starting directory
check or incorrectly reject valid paths. Fix scope: add a lexical path
normalization to `GenericFileHelper` without special prefix handling, and use
it in the three starting directory check sites.
_Note: This comment was generated by an AI coding agent and requires manual
verification._
> camel-file - starting directory check: normalize paths without special
> prefixes
> -------------------------------------------------------------------------------
>
> Key: CAMEL-27453
> URL: https://issues.apache.org/jira/browse/CAMEL-27453
> Project: Camel
> Issue Type: Bug
> Components: camel-file, camel-ftp
> Reporter: Federico Mariani
> Assignee: Guillaume Nodet
> Priority: Major
> Fix For: 4.24.0
>
>
> The starting directory check (jailStartingDirectory) of the remote-file
> consumers and of the file producers normalizes the path with
> FileUtil.compactPath. That general-purpose helper gives some leading prefixes
> a special meaning. For an endpoint without a directory, which works in the
> login directory, this normalization does not match how the FTP client and the
> server resolve the path.
> Change:
> - Add a lexical normalization to GenericFileHelper that is used only by the
> starting directory check. It treats every path segment alike, without special
> handling of any prefix.
> - GenericFileHelper.isWithinDirectory refuses a target that still has a
> parent-directory segment after normalization.
> - Use both in RemoteFileConsumer.isWithinStartingDirectory,
> GenericFileProducer (jailStartingDirectory check) and SmbConsumer.
> FileUtil.compactPath and the local work directory check are not changed.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)