/

CVE-2026-85756

Severity:

HIGH RISK

(7.5)

OS Command Injection (CWE-78) in SSH.NET ScpClient

CVE-2026-85756

Awaiting Analysis

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Remote Command Execution

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

SSH.NET's ScpClient can place attacker-controlled remote paths into the server-side scp command without safely neutralizing every shell metacharacter. When an application passes such a path to a shell-based SSH server, an attacker may execute commands with the privileges of the authenticated SSH user.

Affected context

The vulnerability occurs in applications using SSH.NET's ScpClient to send caller-controlled remote paths to a shell-based SSH server. Risk depends on the active IRemotePathTransformation and the parsing rules of the remote command interpreter; non-shell servers and paths fully neutralized by the selected transformation are generally outside the affected conditions.

Exploit preconditions

  • Attack surface: Application functionality that invokes ScpClient with a remote path
  • Required access: Ability to influence or supply the remote path, plus an application-mediated authenticated SSH session
  • Trigger point: Construction and execution of the server-side scp command
  • Why exploitation is possible: The default path transformation may not neutralize all shell metacharacters for the target shell, allowing crafted path content to alter command interpretation

Why this happens

The issue is caused by embedding caller-controlled remote path data into a shell command while relying on a quoting transformation that is not safe for every remote command interpreter. This behavior maps to CWE-78, OS Command Injection, because data intended as a path can be interpreted as shell syntax when it crosses the command-execution boundary.

Potential impact

  • An attacker may execute arbitrary commands as the authenticated SSH user.
  • The attacker could read, modify, or delete data accessible to that account.
  • The compromised account may be used to alter remote application or system state.
  • Further compromise could occur if the SSH account has excessive privileges or reusable credentials.

General mitigation guidance

Mitigation generally focuses on preventing untrusted path data from becoming

shell syntax.

Common defensive patterns include:

  • Prefer transfer APIs that avoid invoking a remote shell, such as SFTP where suitable.
  • Use a shell-specific path transformation that safely quotes paths for the known remote shell.
  • Avoid accepting arbitrary remote paths when an application can use fixed directories or allowlisted names.
  • Validate paths against an application-defined policy before passing them to the SSH library.
  • Use SSH accounts with the least privileges required for file-transfer operations.
  • Keep remote shells and command permissions restricted when shell execution is not required.
  • Treat quoting as interpreter-specific rather than assuming one transformation works across all server environments.

How teams detect issues like this

Organizations can look for this issue through:

  • Static analysis rules identifying caller-controlled values passed to SCP or shell-command construction APIs.
  • Code review checks for remote path transformations, especially use of default or interpreter-agnostic quoting.
  • Tests covering shell metacharacters and the parsing behavior of each supported server shell, without relying solely on positive-path tests.
  • Policy enforcement requiring allowlisted remote paths or shell-free transfer protocols for untrusted inputs.
  • Runtime monitoring for unexpected command execution or unusual activity by SSH service accounts.

Automated code review and software composition analysis tools may help identify risky API usage and outdated dependency behavior.

Sources

SourceLink
github.comgithub.com/sshnet/SSH.NET/commit/c66b9f8fb06c12e71761e58a577b1e796026310f
github.comgithub.com/sshnet/SSH.NET/releases/tag/2026.0.0
github.comgithub.com/sshnet/SSH.NET/security/advisories/GHSA-mggc-4xg6-vcxf

Frequently asked

questions

It can be exploitable through an application that exposes attacker-controlled

paths and uses SSH.NET's ScpClient against a shell-based SSH server. The

attacker does not necessarily need direct SSH access if the application

performs the authenticated transfer on the attacker's behalf.

The attacker must be able to influence a remote path consumed by the

vulnerable transfer flow. The application also needs an authenticated SSH

connection to a server that interprets the generated scp command through a

shell.

Avoid remote shell invocation where possible by using a shell-free transfer

mechanism. Otherwise, apply a transformation designed for the specific

remote shell and combine it with strict path allowlisting.

Treat remote paths as untrusted input, separate data from commands, test

quoting against each supported interpreter, and run transfer accounts with

narrowly scoped privileges.

Find out what's already
exploitable in your codebase.