logo

Database

Asymmetric denial of service - ReDoS In aedes

Description

Aedes has Uncaught Exception and Uncontrolled Resource Consumption

Summary

A remote Denial of Service (DoS) vulnerability, allows any remote client to cause a complete crash of the Aedes MQTT broker process. This is achieved by sending a specially crafted MQTT message (via PUBLISH or SUBSCRIBE), or by setting a Will message with such a topic, containing a highly recursive topic string (e.g., with thousands of '/' delimiters). The lack of input validation and error handling leads to an uncaught exception in an internal routing library, terminating the entire Node.js application.

Details

The Aedes broker fails to enforce limits on the depth or structural complexity of MQTT topic strings. When a client publishes to or subscribes to a topic with excessive levels of recursion, the internal routing logic cascading into the qlobber library (via mqemitter) reaches an hard-coded limit within the qlobber._split_words function.

This function throws a hard Error: too many words (found in lib/qlobber.js:604). Crucially, Aedes does not wrap the calls to these internal modules (such as in handlers/subscribe.js or the publishing logic) in try-catch blocks. Consequently, this exception propagates up to the main Node.js event loop as an unhandled exception, causing the entire broker process to crash immediately.

This vulnerability affects all stable versions of Aedes due to the underlying dependency behavior and missing perimetral validation.

Stack Trace from Crash:

aedes-broker  | /app/node_modules/mqemitter/node_modules/qlobber/lib/qlobber.js:604
aedes-broker  | 	throw new Error('too many words');
aedes-broker  | 	^
aedes-broker  | 
aedes-broker  | Error: too many words
aedes-broker  |     at Qlobber._split_words (/app/node_modules/mqemitter/node_modules/qlobber/lib/qlobber.js:604:15)
aedes-broker  |     at Qlobber._split (/app/node_modules/mqemitter/node_modules/qlobber/lib/qlobber.js:624:18)
aedes-broker  |     at Qlobber.add (/app/node_modules/mqemitter/node_modules/qlobber/lib/qlobber.js:651:43)...

The same uncaught exception can be triggered without an explicit PUBLISH/SUBSCRIBE: a client that registers a Will message with a deeply nested topic crashes the broker when the Will is published on ungraceful disconnect, because the Will publish path calls broker.publish directly and bypasses the PUBLISH handler.

PoC

Prerequisites

    Aedes MQTT Broker running and accessible over the network. For testing and replication, the broker was deployed using the official Docker image via the following command:

docker run -d --name aedes-broker -p 1883:1883 moscajs/aedes:latest

    Ability to establish an MQTT session (authenticated or unauthenticated, as per the broker's configuration).

Reproduction Steps

    Save the following Python stress testing script (mqtt_crash_poc.py):

#!/usr/bin/env python3
import argparse
import time
import paho.mqtt.client as mqtt

def on_connect(client, userdata, flags, reason_code, properties=None):
    if reason_code != 0:
        print(f"[-] Error en la conexión: {reason_code}")...

    Run the script against the target broker:python3 mqtt_crash_poc.py -d <BROKER_IP> -p 1883

    Upon execution, the Aedes broker dies instantly on the very first packet (PUB_DEEP). Checking the container logs will reveal the stack trace provided in the Details section, confirming the Error: too many words exception.

Impact

This is a Remote Denial of Service (DoS) vulnerability. It affects any infrastructure running an unpatched Aedes MQTT Broker. A successful attack terminates the service entirely, disconnecting all legitimate clients (IoT devices, applications, users) and preventing reconnection until the process is manually or automatically restarted, causing severe business and operational interruption.

Mitigation

Update Impact

Minimal update. May introduce new vulnerabilities or breaking changes.

Ecosystem
Component
Affected version
Patched versions