Twisted: Unauthenticated Remote Denial of Service in the Twisted IRC Server via an Unbounded Line 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 unbounded-buffer vulnerability (CWE-770) in the Twisted words IRC server lets any unauthenticated remote client exhaust server memory. twisted.words.protocols.irc.IRC.dataReceived appends every received byte to a per-connection buffer and only removes data at a line feed, with no maximum length. Because IRC is a plain Protocol and not a LineReceiver, one connection that streams bytes without a line feed grows the buffer without bound and drives the whole single-threaded process to out-of-memory, dropping every user at once. The twistd words server inherits the method unchanged through IRCUser, and the data is buffered before any authentication.
Details
IRC.dataReceived keeps everything up to the last line feed in self.buffer:
# twisted/words/protocols/irc.py
class IRC(protocol.Protocol): # not a LineReceiver, so no MAX_LENGTH
buffer = ""
def dataReceived(self, data):
if isinstance(data, bytes):
data = data.decode("utf-8")
lines = (self.buffer + data).split(LF)
self.buffer = lines.pop() # no 3line feed -> whole input stays buffered
...With no line feed in the data, lines.pop() returns the entire accumulated content to self.buffer, so it grows by every chunk and is never bounded; IRC defines no MAX_LENGTH, no lineLengthExceeded, and no timeout, so the connection is never closed. The twistd words server protocol IRCUser subclasses IRC without overriding dataReceived, and the buffer is filled before any PASS, NICK, or USER, so no credentials are required.
Affected product: Twisted (twisted.words), twisted.words.protocols.irc.IRC and its subclass twisted.words.service.IRCUser Affected versions: 26.4.0 and earlier
PoC
On a standard Twisted words IRC server (the server twistd words runs, using IRCUser), an unauthenticated client opens a single TCP connection and continuously sends data that contains no line feed, never completing a line. Every chunk is appended to the connection's line buffer, and because no complete line is ever formed none of it is consumed, so the buffer grows by the full volume sent.
In a measured run against a real IRCFactory server, one unauthenticated connection sending 60 MB of line-feed-free data raised the server process resident memory from about 47 MB to 2966 MB (roughly 49 MB per MB sent) with the connection still open and no limit triggered. Sending the same volume as normal line-feed-terminated commands leaves memory flat, which isolates the cause to the missing line-length bound.
Impact
An unauthenticated remote denial of service from allocation without limits (CWE-770) leading to uncontrolled resource consumption (CWE-400). A single credential-free connection exhausts the memory of the whole twistd words process, and because one process serves every user, the crash drops all connections at once and the service stays down until it is restarted. The quadratic buffer copy reaches the same effect faster. There is no confidentiality or integrity impact and no code execution.
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/01f8cff7753c1edac132380b2ea939fa6bdbab30Fixvia CVE List
- github.com/twisted/twisted/commit/ac90fb7b0ab73688a581fcd9a7c0577ec8ca3059Fixvia CVE List
- github.com/twisted/twisted/releases/tag/twisted-26.10.0rc1Fixvia CVE List
- github.com/twisted/twisted/security/advisories/GHSA-53xc-49m8-p798Advisoryvia CVE List
- github.com/advisories/GHSA-53xc-49m8-p798Advisoryvia GitHub
- github.com/twisted/twisted/pull/12771Referencevia CVE List