Twisted: Unauthenticated Remote Denial of Service in the Twisted conch Telnet Transport via an Unbounded Subnegotiation Buffer
What fixes it
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
Summary
An allocation-without-limits vulnerability (CWE-770) in the Twisted conch telnet transport lets any unauthenticated remote peer exhaust server memory over a single connection. When the peer opens a telnet subnegotiation with IAC SB and then streams bytes without ever sending the IAC SE terminator, every byte is appended to a per-connection buffer that has no maximum length. The buffer persists across reads and is released only on the terminator the attacker withholds, so it grows without bound until the process is killed.
Details
The option-negotiation state machine in Telnet.dataReceived enters the subnegotiation state on IAC SB and sets an empty command list. In that state every non-IAC byte is appended to the list with no length check:
# src/twisted/conch/telnet.py (Telnet.dataReceived)
elif self.state == "subnegotiation":
if b == IAC:
self.state = "subnegotiation-escaped"
else:
self.commands.append(b) # unbounded: no len(self.commands) checkself.commands is an instance attribute that persists across dataReceived calls and is deleted only when IAC SE completes the subnegotiation. Negotiation runs at the transport layer before authentication, and the bytes are consumed inside dataReceived before any application callback, so an application cannot impose a bound. Twisted caps other parser buffers, for example NetstringReceiver.MAX_LENGTH, but not this one.
Affected product: Twisted, twisted.conch.telnet transport Affected versions: confirmed against 26.4.0
PoC
On any endpoint that exposes the Twisted telnet transport, such as the Twisted manhole telnet service, open one connection and send the two bytes IAC SB (0xFF 0xFA), then stream any non-0xFF bytes continuously and never send the IAC SE terminator (0xFF 0xF0). No credentials are required, because option negotiation runs before authentication.
Every byte is appended to the per-connection subnegotiation buffer with no maximum, and the buffer is released only by the terminator the attacker withholds, so it grows for the life of the connection. Because each byte is retained as a separate element the memory consumed is several times the traffic sent, so a modest-bandwidth peer, or several such connections, drives the process to memory exhaustion.
Impact
This is an unauthenticated remote denial of service (CWE-770, CWE-400) by memory exhaustion. A single connection grows an in-memory buffer without bound at a cost proportional to the bytes sent, amplified by per-byte object overhead, until the operating system kills the server and every service it hosts. There is no confidentiality or integrity impact and no code execution. The affected surface is any deployment that exposes a Twisted telnet or manhole transport to untrusted peers.
Text from GitHub Advisory Database
Affected versions 53
- Twisted, pip<= 26.4.0GitHub
- twistedaffected: < 26.10.0rc1CVE List
- twisted, PyPIfrom first release, fixed in 26.10.0rc1OSV
- twisted, PyPI1.0.1OSV
- twisted, PyPI1.0.3OSV
- twisted, PyPI1.0.4OSV
- twisted, PyPI1.0.5OSV
- twisted, PyPI1.0.6OSV
- twisted, PyPI1.0.7OSV
- twisted, PyPI1.1.0OSV
- twisted, PyPI1.1.1OSV
- twisted, PyPI1.2.0OSV
- twisted, PyPI10.0.0OSV
- twisted, PyPI10.1.0OSV
- twisted, PyPI10.2.0OSV
- twisted, PyPI11.0.0OSV
- twisted, PyPI11.1.0OSV
- twisted, PyPI12.0.0OSV
- twisted, PyPI12.1.0OSV
- twisted, PyPI12.2.0OSV
- twisted, PyPI12.3.0OSV
- twisted, PyPI13.0.0OSV
- twisted, PyPI13.1.0OSV
- twisted, PyPI13.2.0OSV
- twisted, PyPI14.0.0OSV
- twisted, PyPI14.0.1OSV
- twisted, PyPI14.0.2OSV
- twisted, PyPI15.0.0OSV
- twisted, PyPI15.1.0OSV
- twisted, PyPI15.2.0OSV
- twisted, PyPI15.2.1OSV
- twisted, PyPI15.3.0OSV
- twisted, PyPI15.4.0OSV
- twisted, PyPI15.5.0OSV
- twisted, PyPI16.0.0OSV
- twisted, PyPI16.1.0OSV
- twisted, PyPI16.1.1OSV
- twisted, PyPI16.2.0OSV
- twisted, PyPI16.3.0OSV
- twisted, PyPI16.3.1OSV
- twisted, PyPI16.3.2OSV
- twisted, PyPI16.4.0OSV
- twisted, PyPI16.4.1OSV
- twisted, PyPI16.5.0OSV
- twisted, PyPI16.5.0rc1OSV
- twisted, PyPI16.5.0rc2OSV
- twisted, PyPI16.6.0OSV
- twisted, PyPI16.6.0rc1OSV
- twisted, PyPI16.7.0rc1OSV
- twisted, PyPI16.7.0rc2OSV
- twisted, PyPI17.1.0OSV
- twisted, PyPI17.1.0rc1OSV
- twisted, PyPI17.5.0OSV
References 6
- github.com/twisted/twisted/commit/073ba878c6c07d569cb61abc5ae76d46eff1b529Fixvia CVE List
- github.com/twisted/twisted/commit/5d91cc66a3591faba758a80a1479e0103602faccFixvia CVE List
- github.com/twisted/twisted/releases/tag/twisted-26.10.0rc1Fixvia CVE List
- github.com/twisted/twisted/security/advisories/GHSA-cwm5-jh59-mwxrAdvisoryvia CVE List
- github.com/advisories/GHSA-cwm5-jh59-mwxrAdvisoryvia GitHub
- github.com/twisted/twisted/pull/12750Referencevia CVE List