<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Twisted (&lt;= 25.5.0) — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/twisted--25.5.0/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata — refreshed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Tue, 09 Jan 2024 18:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/twisted--25.5.0/feed.xml" rel="self" type="application/rss+xml"/><item><title>Twisted DNS Server Denial of Service via Crafted Compression Pointers</title><link>https://feed.craftedsignal.io/briefs/2024-01-twisted-dns-dos/</link><pubDate>Tue, 09 Jan 2024 18:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-twisted-dns-dos/</guid><description>A denial-of-service vulnerability exists in the twisted.names module, where an unauthenticated attacker can send a crafted TCP DNS packet with deeply chained compression pointers, causing the Twisted reactor to hang while processing recursive lookups and effectively freezing the server.</description><content:encoded><![CDATA[<p>The <code>twisted.names</code> module is susceptible to a Denial of Service (DoS) attack due to resource exhaustion during DNS name decompression. This vulnerability allows a remote, unauthenticated attacker to exploit the system by sending a crafted TCP DNS packet containing deeply chained compression pointers. This bypasses existing loop-prevention mechanisms and leads to the single-threaded Twisted reactor becoming unresponsive as it processes millions of recursive lookups. The vulnerability was introduced prior to commit e11cd82. The affected package is pip/Twisted (&lt;= 25.5.0), making any service reliant on Twisted for DNS resolution vulnerable. This can paralyze the server, causing significant disruption to services relying on the Twisted framework.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>Attacker crafts a malicious TCP DNS packet with deeply chained compression pointers. The packet is designed to trigger excessive recursive lookups.</li>
<li>The attacker sends the crafted DNS packet to a vulnerable Twisted DNS server.</li>
<li>The <code>DNSServerFactory</code> processes the incoming TCP packet and parses the number of question records (QDCOUNT).</li>
<li>For each question record, the <code>Message.decode</code> function calls <code>Name.decode</code> to decompress the DNS name.</li>
<li>The <code>Name.decode</code> function recursively dereferences the compression pointers, attempting to resolve the name. Due to the crafted chains, the process enters a loop-like behavior.</li>
<li>The lack of a limit on pointer resolutions causes the Twisted reactor&rsquo;s event loop to become blocked.</li>
<li>The server becomes unresponsive to new connections, I/O operations, and existing requests.</li>
<li>The server experiences a Denial of Service (DoS) condition, rendering it effectively paralyzed until the malicious packet processing completes or the process is restarted.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>A successful attack can render a Twisted-based DNS server unresponsive, leading to a Denial of Service condition. A single malformed TCP packet is sufficient to block the Twisted reactor&rsquo;s event loop for several seconds, or potentially longer, depending on the resources available. The impact is significant because Twisted&rsquo;s single-threaded, cooperative multitasking model makes it vulnerable to such blocking operations. This can affect any service relying on the server for DNS resolution, potentially impacting numerous users and applications.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Update the <code>twisted.names.dns.Name.decode</code> function to implement a limit on the number of pointer resolutions allowed per DNS message to address the root cause of the vulnerability.</li>
<li>Implement state sharing of the &ldquo;resolved offset&rdquo; across all records within a single message to prevent redundant processing of the same compression pointers, mitigating resource exhaustion.</li>
<li>Prior to entering the decoding loop in <code>Message.decode</code>, validate the number of questions (QDCOUNT) in the DNS packet to avoid processing excessively large question sections.</li>
<li>Deploy the Sigma rule <code>Detect Twisted DNS DoS Attack via Deep Compression Pointers</code> to identify and alert on the exploitation attempts based on the structure of DNS packets.</li>
</ul>
]]></content:encoded><category domain="severity">medium</category><category domain="type">advisory</category><category>denial-of-service</category><category>dns</category><category>twisted</category></item></channel></rss>