From MQTT Fundamentals to CVE
The Eclipse Mosquitto MQTT broker mishandles a failed socket write when the send() call returns EAGAIN, treating it as success and leaving the packet in memory forever. An attacker could repeatedly send QoS 2 PUBLISH packets without completing the handshake to leak memory and eventually exhaust the broker's resources.
Published on blog.compass-security.com
Internet of Things (IoT) and Operational Technology (OT) is an area that has grown strongly in recent years and is increasingly being used in the business world. To be able to test the security in this area, let’s take a closer look at the Message Queuing Telemetry Transport (MQTT) protocol to understand the strengths…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the error handler for a failed send() call (EAGAIN) returns success instead of retrying or freeing the packet, so the packet is retained in memory indefinitely.
Impact
An attacker could exhaust the broker's memory and render it unresponsive; only a configured memory_limit was found to block the attack.
What the attacker needed
Network access to the MQTT broker; no authentication needed for the test
The fix
Version 2.0.16 of Eclipse Mosquitto includes a proper fix, and a quick fix would free the failed packet's memory instead of returning success.
How it was found
- Establish a connection to the broker and send a CONNECT packet for MQTT v3.1.1.
- Repeatedly send the first packet of a QoS 2 PUBLISH message without ever confirming it.
- Observe the broker's memory consumption rising and staying high.
- Run the broker under heaptrack and repeat the attack to identify the allocating functions.
- Debug the code to trace the failed send() and the EAGAIN handling path.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
MQTT is a messaging protocol used by small devices like sensors to talk to a central server called a broker. When the broker tried to reply to a client but the network was temporarily busy, it wrongly treated that failure as a success and kept the unsent message in memory forever. By repeating this many times, an attacker can make the broker use up all its memory and stop working.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.