Fix http-streaming upload example broken by Camel's jailStartingDirectory hardening - #197
Open
Croway wants to merge 1 commit into
Open
Fix http-streaming upload example broken by Camel's jailStartingDirectory hardening#197Croway wants to merge 1 commit into
Croway wants to merge 1 commit into
Conversation
…l's jailStartingDirectory hardening Camel 4.23 hardened the file component's jailStartingDirectory containment check to unconditionally reject any starting directory whose compacted path still begins with "..", which is always true for the upload backend's `file:../client` endpoint. This made the upload scenario throw IllegalArgumentException on every request while the download scenario (which reads via plain java.io.File) kept working. Disable the check on this specific endpoint via jailStartingDirectory=false, since the target file name is a hardcoded constant and not derived from exchange/header data, so there is nothing here for the guard to protect against. Document the reasoning and the security trade-off in the example's README so it isn't copied blindly into routes with dynamic file names. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R7ZfDGqU16yJFWuGogJ3Ju
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.
Summary
file:component'sjailStartingDirectorycontainment check (GenericFileHelper.isWithinDirectory) to unconditionally reject any starting directory whose compacted path still begins with... This is always true for the upload backend'sfile:../clientendpoint, so every upload request in thehttp-streamingexample started throwingIllegalArgumentException(the download scenario was unaffected since it reads via plainjava.io.File, bypassing the file producer entirely).jailStartingDirectory=falseto the upload endpoint. This is safe here because the written file name (output) is a hardcoded constant, never derived from exchange/header data, so there's nothing for the containment check to actually protect against.http-streaming/README.adoc, with an explicit warning against reusingjailStartingDirectory=falsein routes where the file name or directory come from exchange/header/external input.Test plan
mvn -q -o compileonhttp-streaming/upload/backend-servercurl -X PUT -F "data=@input" .../test; verified the writtenoutputfile is byte-identical to the input (previously failed withIllegalArgumentException)