Eclipse Foundation Paho MQTTClient-C library readPacket out-of-bounds write vulnerability
The Paho MQTTClient-C library's readPacket function reads a packet's remaining length from the message and then reads that many bytes into a fixed-size buffer without checking if it fits. An attacker can send a crafted MQTT message to cause an out-of-bounds write, leading to remote code execution on devices like the SeaConnect 370W.
Originally disclosed on Cisco Talos
An out-of-bounds write vulnerability exists in the readPacket functionality of Eclipse Foundation Embedded Paho MQTTClient-C library v1.0.0. A specially-crafted MQTT payload can lead to an out-of-bounds write.
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 readPacket function does not validate the remaining length (rem_len) against the size of the destination buffer before copying the message body into it.
Impact
A remote attacker could send a malicious MQTT message to cause an out-of-bounds write, leading to remote command execution on the SeaConnect 370W.
What the attacker needed
Ability to send MQTT messages to the device
The fix
A size check was added to ensure the remaining length does not exceed the buffer size before reading the message body.
How it was found
- The device allocates a 0x201-byte buffer for incoming MQTT messages.
- The readPacket function reads the first header byte of an MQTT packet.
- It decodes the remaining length field from the packet.
- It reads that many bytes into the fixed-size buffer without checking the length against the buffer size.
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 small devices. The library reads a message and trusts a length field inside it to decide how many bytes to copy into a buffer. Because it never checks that the length fits the buffer, a malicious message can overflow the buffer and overwrite nearby memory, which can 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.