CVE-2010-3492
Denial of Service in asyncore module
- CVSS 5.0
- CWE-665: Improper Initialization
- Resource Management
- Remote
The asyncore module in Python before 3.2 does not properly handle unsuccessful calls to the accept function, and does not have accompanying documentation describing how daemon applications should handle unsuccessful calls to the accept function, which makes it easier for remote attackers to conduct denial of service attacks that terminate these applications via network connections.
- CVSS base score
- 5.0
- Published
- 2010-10-19
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Fixed by upgrading
- Yes
Solution
Upgrade to Python 3.2 or newer
Vulnerable code sample
import asyncore
import socket
class MyServer(asyncore.dispatcher):
def __init__(self, host, port):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()
self.bind((host, port))
self.listen(5)
def handle_accept(self):
conn, addr = self.accept()
print(f"Connection from {addr}")
MyHandler(conn)
class MyHandler(asyncore.dispatcher_with_send):
def __init__(self, conn):
asyncore.dispatcher_with_send.__init__(self, conn)
def handle_read(self):
data = self.recv(1024)
if data:
self.send(data)
def handle_close(self):
self.close()
if __name__ == '__main__':
server = MyServer('localhost', 8080)
asyncore.loop()Patched code sample
import asyncore
import socket
class MyServer(asyncore.dispatcher):
def __init__(self, host, port):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()
self.bind((host, port))
self.listen(5)
def handle_accept(self):
conn, addr = self.accept()
if conn is not None:
print(f"Connection from {addr}")
MyHandler(conn)
def handle_error(self):
import traceback
traceback.print_exc()
class MyHandler(asyncore.dispatcher_with_send):
def __init__(self, conn):
asyncore.dispatcher_with_send.__init__(self, conn)
def handle_read(self):
data = self.recv(1024)
if data:
self.send(data)
def handle_close(self):
self.close()
if __name__ == '__main__':
server = MyServer('localhost', 8080)
asyncore.loop()Cite this entry
@misc{vaitp:cve20103492,
title = {{Denial of Service in asyncore module}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2010},
note = {VAITP Python Vulnerability Dataset, entry CVE-2010-3492},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2010-3492/}}
}
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 ::
