Claus Ibsen created CAMEL-26066:
-----------------------------------

             Summary: camel-jsch - the scp producer should refuse a file name 
with a line break or another control character
                 Key: CAMEL-26066
                 URL: https://issues.apache.org/jira/browse/CAMEL-26066
             Project: Camel
          Issue Type: Improvement
          Components: camel-jsch
            Reporter: Claus Ibsen
             Fix For: 4.24.0


The scp producer sends the name of the file it writes inside the scp protocol, 
on a line that ends with a line feed: {{D0775 0 <dir>}} for each directory in 
the name, then {{C0<chmod> <size> <name>}} for the file 
({{ScpOperations.writeFile}}, main faa015319ee7, lines 458 and 488).

The name comes from the {{CamelFileName}} header or the {{fileName}} option. 
The producer checks that it stays inside the starting directory, and the 
{{chmod}} option must be three octal digits, but nothing checks the name for a 
line feed or another control character, which file systems allow in a file 
name. A line feed would end the protocol line early, and the remote scp would 
read the rest of the name as the next line.

*Proposal*:
* refuse a name with a line feed, a carriage return or another control 
character with a {{GenericFileOperationFailedException}}, before anything is 
sent;
* test it against the embedded SSH server of the camel-jsch tests;
* mention it in the scp docs.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to