Skip to content

Fix http-streaming upload example broken by Camel's jailStartingDirectory hardening - #197

Open
Croway wants to merge 1 commit into
mainfrom
fix/http-streaming-jail-starting-directory
Open

Fix http-streaming upload example broken by Camel's jailStartingDirectory hardening#197
Croway wants to merge 1 commit into
mainfrom
fix/http-streaming-jail-starting-directory

Conversation

@Croway

@Croway Croway commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Camel 4.23 hardened the file: component's jailStartingDirectory containment check (GenericFileHelper.isWithinDirectory) to unconditionally reject any starting directory whose compacted path still begins with ... This is always true for the upload backend's file:../client endpoint, so every upload request in the http-streaming example started throwing IllegalArgumentException (the download scenario was unaffected since it reads via plain java.io.File, bypassing the file producer entirely).
  • Fix: add jailStartingDirectory=false to 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.
  • Document the change and the security trade-off in http-streaming/README.adoc, with an explicit warning against reusing jailStartingDirectory=false in routes where the file name or directory come from exchange/header/external input.

Test plan

  • mvn -q -o compile on http-streaming/upload/backend-server
  • Started the backend server and uploaded a 5MB file via curl -X PUT -F "data=@input" .../test; verified the written output file is byte-identical to the input (previously failed with IllegalArgumentException)

…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
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