Executive brief
SSH.NET's ScpClient component constructs shell commands to transfer files over SSH. When an application passes attacker-influenced remote file paths to ScpClient without proper escaping, an attacker can inject shell metacharacters (such as command substitutions) to execute arbitrary commands on the SSH server as the authenticated user. This affects applications that accept user input for remote file paths and pass it directly to ScpClient against shell-based SSH servers.
Technical details
The vulnerability is a shell command injection in SSH.NET's ScpClient default path handling. The library constructs scp commands by inserting caller-supplied remote paths into shell commands without sufficient escaping—the default RemotePathTransformation.DoubleQuote does not neutralize shell metacharacters like $(...) or backticks on POSIX shells. An authenticated attacker who can influence the remote path parameter can craft a malicious path to break out of the quoting and execute arbitrary shell commands on the server. Exploitation requires the remote server to be shell-based (not all SSH servers are) and the attacker to craft a path that defeats the active quoting transformation. The fix requires callers to explicitly specify a RemotePathTransformation (e.g., ShellQuote for POSIX shells) rather than silently defaulting to an unsafe behavior; SFTP via SftpClient is recommended as a safer alternative that avoids shell interpretation.
Affected products
- SSH.NET SSH.NET <unknown
Timeline
- 2026-09-17: disclosed: Advisory published