VAITP Dataset

← Back to the dataset

CVE-2018-1000518

Websockets v4 improper handling of compressed data DoS via memory exhaustion

  • CVSS 7.5
  • CWE-400 Uncontrolled Resource Consumption
  • Resource Management
  • Remote

aaugustin websockets version 4 contains a CWE-409: Improper Handling of Highly Compressed Data (Data Amplification) vulnerability in Servers and clients, unless configured with compression=None that can result in Denial of Service by memory exhaustion. This attack appear to be exploitable via Sending a specially crafted frame on an established connection. This vulnerability appears to have been fixed in 5.

CVSS base score
7.5
Published
2018-06-26
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Affected component
websockets
Fixed by upgrading
Yes

Solution

Update to aaugustin websockets version 5 or higher.

Vulnerable code sample

import websockets
import asyncio

async def echo(websocket, path):
    async for message in websocket:
        await websocket.send(message)

start_server = websockets.serve(echo, "localhost", 8765)  # Compression is enabled by default

asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()

Patched code sample

import websockets
import asyncio

async def echo(websocket, path):
    async for message in websocket:
        await websocket.send(message)

start_server = websockets.serve(echo, "localhost", 8765, compression=None)

asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()

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.

  • Security fix: defend against zip bombs. (aaugustin/websockets)
    websockets/extensions/base.py · Extension.decode, websockets/extensions/permessage_deflate.py, websockets/extensions/permessage_deflate.py · PerMessageDeflate.decode, websockets/framing.py · Frame.read

Cite this entry

@misc{vaitp:cve20181000518,
  title        = {{Websockets v4 improper handling of compressed data DoS via memory exhaustion}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2018},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2018-1000518},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2018-1000518/}}
}

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.