/

CVE-2026-54591

Severity:

HIGH RISK

(8.1)

Path Traversal (CWE-22) in AsyncSSH SCP Client

CVE-2026-54591

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write Outside Intended Directory

Severity:

HIGH RISK

(8.1)

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

A path traversal flaw in the AsyncSSH SCP client allows a malicious SSH server to write files outside the intended download directory by abusing server-controlled filenames.

When the client connects to an untrusted or compromised SCP server, crafted ../ sequences in filenames can cause arbitrary files to be created or overwritten on the client's filesystem.

Affected context

This vulnerability affects environments where AsyncSSH is used as an SCP client to pull files from remote SSH servers over asyncio.

The risk materializes when the client interacts with servers that are untrusted, misconfigured, or potentially compromised and is configured to accept server-provided filenames without additional validation.

The issue arises specifically in the code paths where server-controlled filenames are joined with a client-specified destination directory, but no checks enforce that the resulting paths remain within that directory.

Exploit preconditions

  • Attack surface: AsyncSSH-based SCP client operations receiving files from remote SSH servers.
  • Required access: Ability to operate or compromise the SSH/SCP server the client connects to, or to intercept and manipulate SCP protocol file metadata.
  • Trigger point: The SCP client receives filenames containing ../ sequences or absolute-like path components which are then joined to the destination directory.
  • Why exploitation is possible: The _parse_cd_args function returns server-provided names verbatim, and _recv_files blindly joins them with the target path without normalizing or enforcing that the computed path stays within the intended directory boundary.

Why this happens

The underlying bug class is path traversal due to improper validation of externally supplied path components, mapped to CWE-22: Improper Limitation of a Pathname to a Restricted Directory.

In AsyncSSH's SCP client, server-provided filenames and directory arguments are treated as trusted and concatenated with the user's selected destination directory using standard path-joining APIs.

Because no canonicalization, normalization, or boundary checks are applied, attackers can embed ../ sequences or other constructs that escape the destination directory, leading the client to write files into arbitrary locations on the local filesystem.

Potential impact

  • Remote server can write files to arbitrary locations on the SCP client's filesystem.
  • Important configuration or application files may be overwritten, potentially leading to service disruption.
  • Malicious scripts or binaries could be planted in locations that are later executed by the user or automated processes.
  • Local privilege escalation may be possible if written files influence privileged services or trust relationships.
  • Data integrity and confidentiality may be compromised through unauthorized file creation or modification.

General mitigation guidance

Mitigation generally focuses on constraining how path information from untrusted sources is handled and enforcing strict directory boundaries for file operations.

Common defensive patterns include:

  • Normalizing and canonicalizing all server-provided filenames before use, then verifying that their resolved paths remain under the intended destination directory.
  • Rejecting or sanitizing any filename containing .., absolute path indicators, or unexpected path separators when accepting files from remote peers.
  • Using secure-by-default file transfer abstractions that explicitly restrict operations to a predefined sandbox or chroot-like directory.
  • Running SCP client processes with least privilege, ensuring that even if directory traversal occurs, the process cannot write into sensitive system locations.
  • Treating all server-controlled metadata, including filenames and directory names, as untrusted input subject to validation rather than direct concatenation.

How teams detect issues like this

Organizations can detect and manage similar path traversal issues through:

  • Static analysis rules that flag direct concatenation of untrusted path components (e.g., network or protocol fields) with local filesystem paths without normalization or boundary checks.
  • Code review practices that require explicit checks to ensure joined paths stay under expected root directories, using functions like realpath-based comparisons or path traversal guards.
  • Secure coding guidelines and linting policies that discourage accepting filenames from remote peers verbatim and mandate input validation for path-related data.
  • Optional use of dynamic analysis or runtime monitoring tools that can log and alert on unexpected write operations outside designated directories by client applications.

Sources

SourceLink
github.comgithub.com/ronf/asyncssh/commit/d730803b8e4e94c20c7580d90f94d1e05f9f58de
github.comgithub.com/ronf/asyncssh/releases/tag/v2.23.1
github.comgithub.com/ronf/asyncssh/security/advisories/GHSA-2wxc-x7rj-hg8f

Frequently asked

questions

Exploitation is limited to scenarios where an AsyncSSH SCP client connects to a malicious or compromised SSH/SCP server. Within those scenarios, the server can reliably influence where files are written on the client filesystem.

The attacker must control or be able to substantially influence the SSH/SCP server that the AsyncSSH SCP client is downloading from, or otherwise inject crafted filenames into the SCP protocol stream.

The safest pattern is to treat all server-supplied filenames as untrusted, normalize and canonicalize them, and enforce that the final computed path remains within a pre-defined destination directory, rejecting any requests that attempt to escape that boundary.

Future prevention relies on designing file-transfer logic with strict sandbox boundaries, validating and sanitizing all remote path inputs, incorporating static analysis or linters focused on path handling, and embedding these checks into coding standards and review processes for networked file operations.

Find out what's already
exploitable in your codebase.