[
https://issues.apache.org/jira/browse/CAMEL-24893?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrea Cosentino updated CAMEL-24893:
-------------------------------------
Fix Version/s: 4.18.5
4.22.2
> camel-docling: also constrain absolute paths in custom-argument path
> validation
> -------------------------------------------------------------------------------
>
> Key: CAMEL-24893
> URL: https://issues.apache.org/jira/browse/CAMEL-24893
> Project: Camel
> Issue Type: Improvement
> Components: camel-docling
> Reporter: Andrea Cosentino
> Assignee: Andrea Cosentino
> Priority: Major
> Fix For: 4.18.5, 4.22.2, 4.23.0
>
>
> DoclingProducer validates path-like values supplied through the
> CamelDoclingCustomArguments header before appending them to the docling CLI
> command (validateCustomArguments -> validatePathSafety).
> Currently validatePathSafety only guards against relative traversal: it
> rejects values containing ../ or ..\ and values whose normalized form still
> contains a .. element. It does not constrain absolute paths, so an absolute
> value (e.g. for a flag such as --artifacts-path) passes validation unchanged.
> This is inconsistent with how the component treats input file paths, where
> resolveWithinInputBaseDirectory() confirms a resolved path stays inside a
> configured base directory. Custom-argument path values have no equivalent
> containment.
> Proposed change (in
> components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java):
> - In validatePathSafety, reject values that are absolute
> (Paths.get(value).isAbsolute()), or resolve custom-argument path values
> against a configured safe base directory using the same containment approach
> as resolveWithinInputBaseDirectory, so any value resolving outside the
> intended working directory is rejected - covering both relative traversal
> (already handled) and absolute paths.
> - Add unit tests in DoclingCustomArgsValidationTest for plain absolute-path
> values in both the "--flag value" and "--flag=value" forms (existing tests
> cover only relative traversal).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)