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

Cesanta Mongoose MQTT SUBSCRIBE Multiple Topics Remote Code Execution

The MQTT broker code in Cesanta Mongoose 6.8 stores the quality-of-service value of each requested topic subscription into a fixed 512-byte stack array without checking the index. An attacker who sends a SUBSCRIBE packet with more than 512 topics can overflow that array and corrupt the stack, which the report says can lead to remote code execution.

Aleksandar Nikolic Follow

Originally disclosed on Cisco Talos

Critical 9.8 View original

An exploitable stack buffer overflow vulnerability exists in the MQTT packet parsing functionality of Cesanta Mongoose 6.8. A specially crafted MQTT SUBSCRIBE packet can cause a stack buffer overflow resulting in 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

The subscription handler writes each requested QoS byte into a fixed 512-byte stack array and increments the index without any bounds check.

Impact

A remote, unauthenticated attacker could corrupt the stack and potentially achieve remote code execution on the broker.

What the attacker needed

Network access to the MQTT broker; no authentication required

How it was found

  1. Run the sample mqtt_broker application supplied with the library.
  2. Send it a crafted MQTT SUBSCRIBE packet containing more than 512 topic subscriptions.
  3. Observe the stack buffer overflow reported by AddressSanitizer.

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 where a client asks a broker to send it messages on certain topics, and each request can list many topics at once. The broker keeps a small fixed-size list on the stack (a region of memory used for local variables) to remember the requested quality levels, but it never checks whether the list is full. By asking for more topics than the list can hold, an attacker writes past the end of that list and can overwrite other data, including the address the program returns to, which may let them 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.