MQTT: Missing upper bound on incoming Remaining Length allows server-controlled long wait
Curl's MQTT client accepts any Remaining Length value from a server without an upper bound, so a malicious server can claim a huge packet size and send only a few bytes, causing curl to wait indefinitely for the rest. This is a low-severity client-side denial of service (hang), partially mitigated by existing timeout and size options.
Originally disclosed on HackerOne
- Disclosed after under an hour
Curl's MQTT implementation accepts any valid Remaining Length advertised by the server without an explicit upper bound (beyond the MQTT spec maximum of 268,435,455 bytes). A malicious server can send a PUBLISH packet claiming this maximum size but provide only minimal payload, causing curl to wait indefinitely for the remaining data.
This is a low-severity client-side DoS (hang), mitigated by --max-time and --max-filesize. No memory exhaustion occurs as data is processed in small buffered chunks.
##Affected Code:
lib/mqtt.c (around line 737)
data->req.size = remlen;
mq->npacket = remlen;
##Proof of Concept:
A Malicious MQTT Server Sends a Publish Packet With an Excessive Remaining Length Although labeled as 0xFF FF FF 7F, which equals 268,435,455 bytes, the system transmits just several bytes. This discrepancy occurs despite the initial size declaration. From time to time, actual data volume stays minimal. Size indications do not always reflect transmitted content. What appears large may carry little information.
Curl accepts the stated Remaining Length without verification, adjusting its expectations accordingly; only when communication ends or time expires does it respond. Though designed to follow protocol, reliance on external signals leaves room for unintended behavior under edge conditions.
Attached screenshots show:
- From beyond, the harmful server transmits an exaggerated Remaining Length
- Logs from curl show remaining data volume: 268435455 bytes
Impact
- Low severity / protocol hardening issue
- No crash
- No memory corruption
- No excessive memory allocation
- A malicious server can cause curl to wait for a very large transfer
- Partially mitigated by existing options such as --max-time and --max-filesize
##Recommended Hardening: Apply the same MAX_MQTT_MESSAGE_SIZE limit to incoming packets as is already used for outgoing packets.
if(remlen > MAX_MQTT_MESSAGE_SIZE) {
failf(data, "MQTT message too large (%zu bytes, max %d)",
remlen, MAX_MQTT_MESSAGE_SIZE);
result = CURLE_WEIRD_SERVER_REPLY;
goto end;
}
Attachments



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 client code sets the expected packet size directly from the server-provided Remaining Length without checking it against a maximum limit.
Impact
A malicious server can cause curl to wait for a very large transfer, resulting in a client-side hang; this is partially mitigated by options such as --max-time and --max-filesize.
What the attacker needed
Curl built with MQTT support; user connects to a malicious MQTT server
The fix
The MQTT client should apply the same maximum message size limit to incoming packets as it already does for outgoing packets.
How it was found
- Set up a malicious MQTT server that sends a PUBLISH packet with a very large Remaining Length value.
- The server sends only a few bytes of actual payload after the header.
- Curl connects to this server and receives the packet header.
- Curl waits for the remaining data based on the claimed size, causing a hang until a timeout or connection close.
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.
When curl talks to an MQTT server, the server first says how big the next message will be. Curl trusts that number and waits for all the data. A bad server can say a huge number but send almost nothing, so curl just sits there waiting. This is a denial of service because the program hangs, but it does not crash or use lots of memory.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.