VAITP Dataset

← Back to the dataset

CVE-2026-83813

Twisted DNS accepts forged UDP replies with matching transaction ID, allowing spoofed answers.

  • CVSS 3.1
  • CWE-346
  • Input Validation and Sanitization
  • Remote

Twisted is an event-based framework for internet applications, supporting Python 3.6+. Prior to 26.10.0rc1, twisted.names.dns.DNSDatagramProtocol accepts a UDP DNS response for a pending query when its 16-bit transaction ID matches but does not verify that the response came from the queried host and port. An attacker able to deliver a packet to the resolver's listening port with the correct transaction ID can inject a forged answer. The standard twisted.names.client.Resolver uses a new random source port for each query, increasing off-path attack complexity, while applications that reuse a DNSDatagramProtocol instance expose only the transaction-ID search space after the first query. A successful forgery can redirect hostname resolution and enable mail interception, server-side request forgery, or man-in-the-middle positioning. This issue is fixed in version 26.10.0rc1.

CVSS base score
3.1
Published
2026-10-23
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Insecure Direct Object References (IDOR)
Accessibility scope
Remote
Impact
Unauthorized Access
Affected component
Twisted
Fixed by upgrading
Yes

Solution

Upgrade Twisted to 26.10.0rc1 or newer.

Vulnerable code sample

from twisted.internet import reactor
from twisted.names import dns, client

class SimpleResolver(dns.DNSDatagramProtocol):
    def __init__(self):
        self.pending = {}  # txid -> (query, address)

    def query(self, name, address=('8.8.8.8', 53)):
        q = dns.Query(name.encode('utf-8'), dns.A, dns.IN)
        pkt = dns.Message()
        pkt.id = dns.id()
        pkt.questions.append(q)
        self.transport.write(pkt.toStr(), address)
        # VULNERABLE: does not store source address for later verification
        self.pending[pkt.id] = (q, None)

    def datagramReceived(self, data, addr):
        msg = dns.Message()
        msg.fromStr(data)
        pending = self.pending.get(msg.id)
        if pending:
            # VULNERABLE: accepts any response with matching txid
            query, _ = pending
            print(f"Received answer for {query.name.decode()} from {addr}")
            del self.pending[msg.id]

def main():
    resolver = SimpleResolver()
    reactor.listenUDP(0, resolver)
    resolver.query(b'example.com')
    reactor.run()

Patched code sample

from twisted.internet import reactor
from twisted.names import dns, client

class SimpleResolver(dns.DNSDatagramProtocol):
    def __init__(self):
        self.pending = {}  # txid -> (query, address)

    def query(self, name, address=('8.8.8.8', 53)):
        q = dns.Query(name.encode('utf-8'), dns.A, dns.IN)
        pkt = dns.Message()
        pkt.id = dns.id()
        pkt.questions.append(q)
        self.transport.write(pkt.toStr(), address)
        # FIX: store the expected source address for verification
        self.pending[pkt.id] = (q, address)

    def datagramReceived(self, data, addr):
        msg = dns.Message()
        msg.fromStr(data)
        pending = self.pending.get(msg.id)
        if pending:
            query, expected_addr = pending
            # FIX: verify response originated from the queried host/port
            if addr != expected_addr:
                return
            print(f"Received answer for {query.name.decode()} from {addr}")
            del self.pending[msg.id]

def main():
    resolver = SimpleResolver()
    reactor.listenUDP(0, resolver)
    resolver.query(b'example.com')
    reactor.run()

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

  • drop responses sent from the wrong host or port (twisted/twisted)
    src/twisted/names/dns.py, src/twisted/names/dns.py · DNSDatagramProtocol.datagramReceived, src/twisted/names/dns.py · DNSDatagramProtocol.query, src/twisted/names/dns.py · DNSDatagramProtocol.startProtocol, src/twisted/names/dns.py · DNSDatagramProtocol.stopProtocol

Cite this entry

@misc{vaitp:cve202683813,
  title        = {{Twisted DNS accepts forged UDP replies with matching transaction ID, allowing spoofed answers.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-83813},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-83813/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.