CVE-2026-54591 Overview
CVE-2026-54591 is a path traversal vulnerability [CWE-22] in AsyncSSH, a Python package that provides an asynchronous client and server implementation of the SSHv2 protocol on top of the Python asyncio framework. Versions prior to 2.23.1 allow a malicious SSH server to write arbitrary files on an AsyncSSH SCP client's filesystem. The flaw exists because _parse_cd_args in scp.py returns server-provided filenames verbatim, and _recv_files joins them to the destination path without enforcing the target directory boundary. An attacker controlling the remote server can inject ../ sequences into filenames to escape the intended download directory.
Critical Impact
A malicious SCP server can write arbitrary files to any location on the client host that the SCP process can access, enabling code execution through overwriting startup scripts, SSH configuration, or authorized_keys files.
Affected Products
- AsyncSSH versions prior to 2.23.1
- Python applications using AsyncSSH as an SCP client
- Automation and CI/CD pipelines relying on AsyncSSH SCP downloads
Discovery Timeline
- 2026-07-08 - CVE-2026-54591 published to NVD
- 2026-07-08 - Last updated in NVD database
Technical Details for CVE-2026-54591
Vulnerability Analysis
The vulnerability affects the SCP (Secure Copy Protocol) client implementation in AsyncSSH. When an SCP client downloads files from a remote server, the server transmits filenames as part of the SCP protocol control messages. AsyncSSH parses these filenames in the _parse_cd_args function and passes them to _recv_files, which joins the server-supplied name to the local destination directory. Because AsyncSSH did not validate that the resulting path stays within the intended target directory, filenames containing ../ traversal sequences or absolute path separators allowed the server to redirect writes outside the destination.
Root Cause
The root cause is missing input validation on server-controlled filenames. The _parse_cd_args function accepted any byte string returned by the server as a valid filename without checking for path separators (/, \) or the parent directory reference (..). Downstream path-joining logic in _recv_files then produced attacker-controlled write locations.
Attack Vector
Exploitation requires the victim to initiate an SCP download from an attacker-controlled or compromised SSH server. This matches the CVSS user-interaction requirement. Once the client connects, the malicious server responds to file copy commands with filenames such as ../../.ssh/authorized_keys or ../../../etc/cron.d/backdoor. AsyncSSH writes the file content to the resolved absolute path, bypassing the intended destination directory boundary.
# Security patch in asyncssh/scp.py — fix for SCP path traversal
try:
permissions, size, name = args.split(None, 2)
if b'/' in name or b'\\' in name or name == b'..':
raise _scp_error(SFTPBadMessage, 'Invalid filename')
return int(permissions, 8), int(size), name
except ValueError:
raise _scp_error(SFTPBadMessage,
Source: GitHub Commit d730803b. The patch rejects any filename containing forward slash, backslash, or a bare .., preventing the server from directing writes outside the target directory.
Detection Methods for CVE-2026-54591
Indicators of Compromise
- Files written outside the SCP client's intended download directory, particularly under ~/.ssh/, /etc/, or user profile startup paths
- SCP transfer logs referencing filenames containing ../ sequences or absolute path prefixes
- Modifications to authorized_keys, .bashrc, .profile, or cron directories immediately following an SCP session
- Outbound SSH connections from automation hosts to untrusted or newly observed remote endpoints
Detection Strategies
- Inventory Python environments and identify installations of AsyncSSH below version 2.23.1 using pip list or software composition analysis tooling
- Instrument SCP client code paths to log resolved destination paths and alert when writes occur outside the requested target directory
- Compare file integrity baselines of sensitive configuration files on hosts that regularly initiate SCP downloads
Monitoring Recommendations
- Enable filesystem auditing (auditd on Linux, FIM on Windows) for ~/.ssh/, /etc/, and scheduled task directories on SCP client hosts
- Monitor CI/CD runners and automation accounts for unexpected file writes following outbound SSH sessions
- Alert on any AsyncSSH-based process writing to paths outside its declared working directory
How to Mitigate CVE-2026-54591
Immediate Actions Required
- Upgrade AsyncSSH to version 2.23.1 or later across all Python environments and container images
- Audit code that invokes asyncssh.scp() in client mode and verify that remote endpoints are trusted
- Where feasible, migrate from SCP to SFTP, which has stricter filename handling semantics
- Review recent SCP downloads from untrusted servers for signs of file writes outside intended directories
Patch Information
The fix is available in AsyncSSH 2.23.1. The patch adds explicit validation in _parse_cd_args that rejects any server-supplied filename containing /, \, or equal to .., raising an SFTPBadMessage error. See the GitHub Security Advisory GHSA-2wxc-x7rj-hg8f and the GitHub Release v2.23.1 for release details.
Workarounds
- Restrict SCP client operations to trusted, authenticated servers only, avoiding downloads from unknown or third-party hosts
- Run SCP-consuming automation under least-privilege accounts with write access limited to a dedicated download directory
- Wrap SCP downloads in a post-processing step that verifies resolved file paths remain within the expected destination before use
# Upgrade AsyncSSH to the patched release
pip install --upgrade 'asyncssh>=2.23.1'
# Verify the installed version
python -c "import asyncssh; print(asyncssh.__version__)"
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

