CVE-2026-85756 Overview
SSH.NET, a widely used Secure Shell (SSH) library for .NET, contains a command injection vulnerability [CWE-78] in its ScpClient implementation. Prior to version 2026.0.0, ScpClient embeds caller-supplied remote paths directly into the scp command executed on the server. The default RemotePathTransformation.DoubleQuote transformation cannot safely quote paths for every remote command interpreter. When an application forwards an attacker-controlled path to a shell-based server, shell metacharacters that the active IRemotePathTransformation fails to neutralize execute as commands under the authenticated SSH user account.
Critical Impact
Attackers who influence remote path arguments passed to ScpClient can execute arbitrary commands on shell-based SSH servers with the privileges of the authenticated SSH user.
Affected Products
- SSH.NET library versions prior to 2026.0.0
- .NET applications using ScpClient with RemotePathTransformation.DoubleQuote (default)
- Deployments targeting shell-based SSH servers where remote paths originate from untrusted input
Discovery Timeline
- 2026-09-16 - CVE-2026-85756 published to NVD
- 2026-09-16 - Last updated in NVD database
- Fix released - SSH.NET version 2026.0.0 addresses the vulnerability
Technical Details for CVE-2026-85756
Vulnerability Analysis
The flaw resides in how ScpClient constructs scp commands transmitted to the remote SSH server. Callers supply a remote path, and the library applies an IRemotePathTransformation before embedding the value in the shell command. The default RemotePathTransformation.DoubleQuote only wraps the path in double quotes, which does not neutralize every metacharacter interpreted by shells such as bash, sh, or zsh. Sequences involving backticks, $(...), or escaped quote handling can break out of the quoted context. The result is command injection under the authenticated user's shell.
Root Cause
The root cause is inadequate input neutralization for OS command injection [CWE-78]. ScpClient treats the remote path as trusted textual data and delegates escaping to a transformation whose default implementation is insufficient for arbitrary shell parsers. SftpClient is not affected because it never invokes a remote shell. Non-shell SSH servers are also unaffected because they interpret paths literally.
Attack Vector
Exploitation requires an application that passes attacker-influenced strings to ScpClient methods such as Upload or Download, a shell-based SSH server, and knowledge of that shell's parsing rules. The attacker must also possess or influence valid SSH credentials used by the client. Successful exploitation yields command execution as the authenticated SSH user.
// Security patch in src/Renci.SshNet/IRemotePathTransformation.cs
// Require an explicit IRemotePathTransformation for ScpClient
/// <summary>
/// Represents a transformation that can be applied to a remote path.
/// </summary>
+ /// <remarks>
+ /// <para>
+ /// A remote path transformation is used by <see cref="ScpClient"/> to encode a remote path before it
+ /// is embedded in the <c>scp</c> command that is sent to the server. The correct transformation
+ /// depends on the server: a shell-based server requires the path to be quoted or escaped according to
+ /// its shell's rules, whereas a non-shell-based server uses the path literally and requires no
+ /// transformation (see <see cref="RemotePathTransformation.None"/>).
+ /// </para>
+ /// <para>
+ /// See <see cref="RemotePathTransformation"/> for the implementations supplied with SSH.NET. On a
+ /// shell-based server, choosing a transformation that does not match the shell can leave a crafted
+ /// path able to execute as a command on the server; on a non-shell-based server, applying quoting or
+ /// escaping corrupts the path. A transformation should therefore be selected deliberately for the
+ /// target server and the trust placed in the supplied paths.
+ /// </para>
+ /// </remarks>
public interface IRemotePathTransformation
{
/// <summary>
Source: GitHub Commit c66b9f8
Detection Methods for CVE-2026-85756
Indicators of Compromise
- Unexpected child processes spawned from sshd sessions on servers accessed by SSH.NET-based clients.
- scp server-side command lines containing shell metacharacters such as backticks, $(...), ;, or | embedded in path arguments.
- Authentication events for SSH accounts followed by anomalous command execution not tied to legitimate file transfers.
Detection Strategies
- Inventory .NET applications and identify dependencies on SSH.NET packages older than 2026.0.0.
- Audit source code for calls to ScpClient methods that accept externally sourced path parameters.
- Enable SSH server-side command logging and review scp invocations for suspicious argument content.
Monitoring Recommendations
- Forward SSH server auth and process telemetry to a centralized analytics platform for correlation across sessions.
- Alert on process lineage where sshd spawns interpreters like bash, sh, or python outside expected file-transfer patterns.
- Track outbound network activity from SSH server accounts that historically only handled scp transfers.
How to Mitigate CVE-2026-85756
Immediate Actions Required
- Upgrade the SSH.NET dependency to version 2026.0.0 or later across all applications.
- Identify code paths where untrusted input reaches ScpClient and validate or reject shell metacharacters at the boundary.
- Rotate SSH credentials used by affected clients if exploitation is suspected.
Patch Information
The fix ships in SSH.NET 2026.0.0. The patch requires callers to select an IRemotePathTransformation explicitly for ScpClient, forcing a deliberate choice appropriate to the target server. See the GitHub Release 2026.0.0 and the GitHub Security Advisory GHSA-mggc-4xg6-vcxf for full details.
Workarounds
- Switch from ScpClient to SftpClient, which does not invoke a remote shell and is not affected.
- When ScpClient must be used against POSIX shell servers, configure RemotePathTransformation.ShellQuote instead of the default DoubleQuote.
- Restrict SSH accounts used by client applications to minimum privileges and forced-command shells where feasible.
# Update SSH.NET package reference to the patched release
dotnet add package SSH.NET --version 2026.0.0
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.