Twisted: Unauthenticated Remote Denial of Service in the Twisted words domish XML Element Stream via an Unbounded Element Tree
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 in the Twisted XML element stream lets any unauthenticated remote peer exhaust server memory over a single stream. When the peer opens a container element and streams child elements without ever closing the container, every element is materialised into an in-memory tree with no limit on depth or child count. An element is released only when its end tag arrives, so a container the attacker never closes retains everything beneath it until the process is killed.
Details
In ExpatElementStream._onStartElement, each start tag appends a new element to the current element's children and descends into it, with no depth or child-count check:
# src/twisted/words/xish/domish.py (ExpatElementStream._onStartElement)
if self.documentStarted == 1:
if self.currElem != None:
self.currElem.children.append(e) # append child: no depth/count cap
e.parent = self.currElem
self.currElem = e # descend into the new elementAn element is emitted and dropped only when its end tag arrives while it sits directly under the document root, so a container that is never closed keeps every child beneath it. The transport XmlStream.dataReceived feeds bytes to self.stream.parse(data) with no size limit, and in XMPP the stream is parsed during negotiation before authentication.
Affected product: Twisted, twisted.words.xish.domish element stream Affected versions: confirmed against 26.4.0
PoC
On any endpoint that parses untrusted XML streams with this stack, such as an XMPP server, open a stream by sending the opening stream:stream tag and a container element, then stream child elements continuously and never send the container's closing tag. No credentials are required, because in XMPP the stream is parsed before authentication.
Every child is appended to the container and retained because the container is never emitted, and the transport applies no limit on the size of the unfinished document. Because each small element becomes a full object in memory the footprint is many times the traffic sent, so a modest-bandwidth peer, or several such streams, drives the process to memory exhaustion.
Impact
This is an unauthenticated remote denial of service by memory exhaustion. A single stream grows an in-memory element tree without bound, amplified by per-element object overhead, until the operating system kills the server. There is no confidentiality or integrity impact and no code execution. The affected surface is any deployment that parses untrusted XML streams with this stack, such as an XMPP server or component.
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 5
- github.com/twisted/twisted/commit/8873814bec8288e2466fad4d2c4d64039beb88b0Fixvia CVE List
- github.com/twisted/twisted/releases/tag/twisted-26.10.0rc1Fixvia CVE List
- github.com/twisted/twisted/security/advisories/GHSA-3476-c5c2-fr73Advisoryvia CVE List
- github.com/advisories/GHSA-3476-c5c2-fr73Advisoryvia GitHub
- github.com/twisted/twisted/pull/12751Referencevia CVE List