{"id":"CVE-2026-54591","aliases":["CVE-2026-54591","GHSA-2wxc-x7rj-hg8f","PYSEC-2026-3808"],"related":[],"kind":"vulnerability","state":"published","title":"AsyncSSH: SCP Path Traversal to Arbitrary File Write","summary":"AsyncSSH is a Python package which provides an asynchronous client and server implementation of the SSHv2 protocol on top of the Python asyncio framework. Prior to 2.23.1, a malicious SSH server can write arbitrary files on the asyncssh SCP client's filesystem by sending filenames containing ../ traversal sequences because _parse_cd_args in scp.py returns server-provided names verbatim and _recv_files joins them to the destination path without enforcing the target directory boundary. This issue is fixed in version 2.23.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"AsyncSSH is a Python package which provides an asynchronous client and server implementation of the SSHv2 protocol on top of the Python asyncio framework. Prior to 2.23.1, a malicious SSH server can write arbitrary files on the asyncssh SCP client's filesystem by sending filenames containing ../ traversal sequences because _parse_cd_args in scp.py returns server-provided names verbatim and _recv_files joins them to the destination path without enforcing the target directory boundary. This issue is fixed in version 2.23.1.","source":"cvelist"},{"lang":"en","text":"| | |\n|---|---|\n| Product | asyncssh (all versions through 2.23.0) |\n| Related | CVE-2019-6111 (same class in OpenSSH) |\n| Fix | AsyncSSH 2.23.1 |\n\nA malicious SSH server can write arbitrary files on the asyncssh SCP client's filesystem by sending filenames containing `../` traversal sequences. The SCP receive path does not currently sanitize server-provided filenames. By chaining directory traversals via the `D` (directory) action, an attacker can escape any target directory and overwrite `~/.bashrc`, `~/.ssh/rc`, or `~/.ssh/authorized_keys`, achieving code execution. This is the same vulnerability class as CVE-2019-6111. The mitigation applied in OpenSSH does not appear to have been adopted in asyncssh.\n\n---\n\n**Steps to exploit:**\n\n**Step 1 - Normal usage:** Application calls `await asyncssh.scp((conn, 'file'), '/home/user/downloads/')`. This is the standard, documented API.\n\n**Step 2 - SCP protocol:** asyncssh opens an SSH exec channel, runs `scp -f file`. The server controls the filename field:\n\n```\nC0644 100 ../pwned.txt\\n       (simple traversal)\n\nD0755 0 ..\\n                   (traverse up, repeat as needed)\nC0644 47 .bashrc\\n             (write payload)\nE\\n\n```\n\n**Step 3 - `_parse_cd_args`** (`scp.py:134-142`) returns the filename verbatim:\n\n```python\ndef _parse_cd_args(args: bytes) -> Tuple[int, int, bytes]:\n    permissions, size, name = args.split(None, 2)\n    return int(permissions, 8), int(size), name  # no sanitization\n```\n\nThe returned `name` is not passed through `basename()` and is not checked for `..` or `/` components.\n\n**Step 4 - `_recv_files`** (`scp.py:706-713`) joins the unsanitized name:\n\n```python\nnew_dstpath = posixpath.join(dstpath, name)\n```\n\nWith `dstpath=b'/home/user/downloads/subdir'` and `name=b'../pwned.txt'`, this resolves to `/home/user/downloads/pwned.txt`, outside the target.\n\n**Step 5 - File write:** `_recv_file` opens the traversed path via `self._fs.open(dstpath, 'wb')` and writes attacker-controlled content. The resolved path is not checked against the target directory boundary.\n\n**Step 6 - RCE chains:**\n\n| Target | Execution trigger | Reliability |\n|---|---|---|\n| `~/.bashrc` | Next terminal open | High |\n| `~/.profile` | Next login | High |\n| `~/.ssh/rc` | Next SSH connection (requires sshd) | High |\n| `~/.ssh/authorized_keys` | Attacker logs in with `command=` | Medium |\n\n---\n\n**Reproduction:**\n\nLink to reproduction script: [path_traversal_poc.zip](https://github.com/user-attachments/files/28160665/path_traversal_poc.zip)\n\n```bash\ndocker build -t asyncssh-scp-traversal -f Dockerfile .\ndocker run --rm asyncssh-scp-traversal\n```\n\nThe attached `poc_scp_traversal.py` starts a malicious SSH server in-process using asyncssh's own API, then downloads from it via `asyncssh.scp()`.\n\n*Expected Output:*\n\n<img width=\"1400\" height=\"815\" alt=\"image\" src=\"https://github.com/user-attachments/assets/496745e4-d11d-4ed8-bddd-d15dd13d1751\" />","format":"markdown","source":"ghsa"},{"lang":"es","text":"AsyncSSH es un paquete de Python que proporciona una implementación asíncrona de cliente y servidor del protocolo SSHv2 sobre el framework asyncio de Python. Antes de la versión 2.23.1, un servidor SSH malicioso puede escribir archivos arbitrarios en el sistema de archivos del cliente SCP de asyncssh enviando nombres de archivo que contienen secuencias de recorrido ’.. / ’ porque _parse_cd_args en scp.py devuelve los nombres proporcionados por el servidor textualmente y _recv_files los une a la ruta de destino sin hacer cumplir el límite del directorio de destino. Este problema está solucionado en la versión 2.23.1.","source":"nvd"}],"published":"2026-07-08T20:33:57.420Z","modified":"2026-10-25T17:10:00.197Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H","score":8.1,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H","score":8.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H","score":8.1,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H","score":8.1,"rating":"HIGH"}],"cwes":["CWE-22"],"affected":[{"ranges":[{"version":"< 2.23.1","status":"affected"}],"vendor":"ronf","product":"asyncssh","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.23.1"}],"ecosystem":"PyPI","package":"asyncssh","purl":"pkg:pypi/asyncssh","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.23.1"}],"ecosystem":"PyPI","package":"asyncssh","purl":"pkg:pypi/asyncssh","source":"pysec"}],"references":[{"url":"https://github.com/ronf/asyncssh/security/advisories/GHSA-2wxc-x7rj-hg8f","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/ronf/asyncssh/commit/d730803b8e4e94c20c7580d90f94d1e05f9f58de","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/ronf/asyncssh/releases/tag/v2.23.1","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-54591","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/ronf/asyncssh","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/asyncssh","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-2wxc-x7rj-hg8f","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-07-09T14:21:05.079Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-54591","url":"https://www.cve.org/CVERecord?id=CVE-2026-54591","licence":"CVE Terms of Use","modified":"2026-07-09T14:40:52.505Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-2wxc-x7rj-hg8f","url":"https://github.com/advisories/GHSA-2wxc-x7rj-hg8f","licence":"CC-BY-4.0","modified":"2026-09-10T12:25:50.570Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-54591","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-54591","licence":"Public domain","modified":"2026-10-25T17:10:00.197Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-3808","url":"https://osv.dev/vulnerability/PYSEC-2026-3808","licence":"CC-BY-4.0","modified":"2026-09-10T12:15:06.100Z"}],"updatedAt":"2026-11-25T22:59:27.439Z","epss":{"score":0.00381,"percentile":0.34232,"date":"2026-12-01T12:00:22.000Z"}}