CVE-2025-66023

Source: security-advisories@github.com

MEDIUM
6.9
Published: January 1, 2026 at 03:15 PM
Modified: January 2, 2026 at 04:45 PM

Vulnerability Description

NanoMQ MQTT Broker (NanoMQ) is an all-around Edge Messaging Platform. Versions prior to 0.24.5 have a Heap-Use-After-Free (UAF) vulnerability within the MQTT bridge client component (implemented via the underlying NanoNNG library). The vulnerability is triggered when NanoMQ acts as a bridge connecting to a remote MQTT broker. A malicious remote broker can trigger a crash (Denial of Service) or potential memory corruption by accepting the connection and immediately sending a malformed packet sequence. Version 0.34.5 contains a patch. The patch enforces stricter protocol adherence in the MQTT client SDK embedded in NanoMQ. Specifically, it ensures that CONNACK is always the first packet processed in the line. This prevents the state confusion that led to the Heap-Use-After-Free (UAF) when a malicious server sent a malformed packet sequence immediately after connection establishment. As a workaround, validate the remote broker before bridging.

CVSS Metrics

Base Score
6.9
Severity
MEDIUM
Vector String
CVSS:4.0/AV:N/AC:H/AT:P/PR:H/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:H/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

Weaknesses (CWE)

Source: security-advisories@github.com

AI Security Analysis

01 // Technical Summary

NanoMQ MQTT Broker versions prior to 0.24.5 are vulnerable to a Heap-Use-After-Free (UAF) vulnerability, allowing a malicious remote MQTT broker to trigger a Denial of Service (DoS) or potentially remote code execution (RCE). This vulnerability arises from improper handling of malformed packet sequences during bridge client connections, leading to memory corruption. Successful exploitation could disrupt critical messaging infrastructure and compromise sensitive data.

02 // Vulnerability Mechanism

Step 1: Connection Establishment: The vulnerable NanoMQ instance acts as a bridge, connecting to a remote, malicious MQTT broker. Step 2: Malformed Packet Sequence: The malicious broker immediately sends a malformed packet sequence to the NanoMQ bridge client, bypassing the expected CONNACK packet. Step 3: State Corruption: The NanoMQ client's internal state becomes corrupted due to the unexpected packet sequence. Step 4: Memory Corruption: When the client attempts to process subsequent packets, it accesses freed memory (Heap-Use-After-Free), leading to memory corruption. Step 5: Exploitation: This memory corruption can result in a crash (DoS) or, with careful crafting, potentially lead to arbitrary code execution.

03 // Deep Technical Analysis

The vulnerability stems from a Heap-Use-After-Free (UAF) condition within the NanoMQ MQTT bridge client, specifically within the NanoNNG library. The root cause lies in the MQTT client's failure to properly validate the incoming packet sequence from a remote MQTT broker. When a malicious broker sends a malformed packet sequence immediately after the connection is established (e.g., a packet other than CONNACK), the client's internal state becomes inconsistent. This leads to the use of freed memory when processing subsequent packets, resulting in a crash or potentially allowing for arbitrary code execution. The patch addresses this by enforcing stricter protocol adherence, ensuring that CONNACK is always the first packet processed, thus preventing the state confusion.

04 // Exploitation Status

Discovery Only. While the vulnerability is well-understood, a public Proof-of-Concept (PoC) is not currently available. However, the nature of the vulnerability suggests that a skilled attacker could develop a working exploit.

05 // Threat Intelligence

While no specific APT groups are directly linked to exploiting this vulnerability, the potential for DoS and RCE makes it attractive to various threat actors. Given the critical role of MQTT brokers in IoT and industrial control systems (ICS), exploitation could have significant impact. CISA KEV status: Not Listed.

06 // Detection & Hunting

  • Monitor network traffic for unusual MQTT packet sequences, particularly those deviating from the standard connection handshake.

  • Analyze MQTT bridge client logs for error messages or unexpected behavior related to packet processing.

  • Implement intrusion detection systems (IDS) with rules to identify malformed MQTT packets.

  • Monitor system resource usage (CPU, memory) for spikes or unusual patterns that may indicate exploitation.

  • Review bridge client configuration for any unnecessary or overly permissive settings.

07 // Remediation & Hardening

  • Upgrade NanoMQ to version 0.24.5 or later to patch the vulnerability.

  • If upgrading is not immediately possible, validate the remote broker before bridging to it. This can involve checking the broker's identity and reputation.

  • Implement network segmentation to isolate the MQTT broker from untrusted networks.

  • Regularly review and update security configurations for the MQTT broker and underlying systems.

  • Monitor the system for any signs of compromise or unusual activity.

08 // Affected Products

NanoMQ MQTT Broker versions prior to 0.24.5
Advertisement