Skip to content
Memory corruption Advisory Advanced CVE-2017-2892

Cesanta Mongoose MQTT Payload Length Remote Code Execution

The MQTT packet parser in Cesanta Mongoose 6.8 does not validate the calculated payload length against the actual received packet, allowing an integer overflow that leads to out-of-bounds memory read and write. An attacker can send a crafted MQTT packet to cause information disclosure, denial of service, or potentially remote code execution.

Aleksandar Nikolic Follow

Originally disclosed on Cisco Talos

Medium 6.8 View original

An exploitable arbitrary memory read vulnerability exists in the MQTT packet parsing functionality of Cesanta Mongoose 6.8. A specially crafted MQTT packet can cause an arbitrary out-of-bounds memory read and write potentially resulting in information disclosure, denial of service and remote code execution.

Aleksandar Nikolic, on Cisco Talos

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 report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely, the MQTT variable-length header is decoded without validating the resulting length, and a subsequent pointer comparison can overflow, causing the end pointer to wrap around and point before the buffer start.

Impact

An attacker could cause information disclosure, denial of service, and potentially remote code execution, though the proof of concept may not crash depending on memory layout.

What the attacker needed

Network access to MQTT broker; send crafted MQTT packet

How it was found

  1. Send a specially crafted MQTT packet with a manipulated variable-length header to the mqtt_broker application.
  2. The parser calculates an arbitrarily large payload length without checking it against the actual packet size.
  3. The end pointer wraps around due to integer overflow, pointing before the message buffer.
  4. A PUBLISH command uses the wrapped end pointer to compute a huge payload length.
  5. The oversized payload length is used when notifying subscribed clients, causing out-of-bounds memory read and write.

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 report has not been written yet. The Original tab links to the source.

MQTT is a messaging protocol used by IoT devices. The library that parses MQTT packets fails to check if the length field in a packet matches the actual data received, so a malicious packet can make the program read or write memory outside its intended bounds. This can crash the device, leak data, or let an attacker run their own code.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Aleksandar Nikolic

View all

147 more disclosed reports, best first.

More from Cisco Talos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.