Cesanta Mongoose Websocket Protocol Packet Length Code Execution Vulnerability
An integer overflow in the websocket packet parsing of Cesanta Mongoose 6.8 allows a crafted packet to bypass a length check, leading to a heap buffer overflow. This can cause a denial of service and potentially remote code execution.
Originally disclosed on Cisco Talos
An exploitable memory corruption vulnerability exists in the Websocket protocol implementation of Cesanta Mongoose 6.8. A specially crafted websocket packet can cause an integer overflow resulting leading to heap buffer overflow resulting in denial of service and potential remote code execution.
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 code adds header_len to data_len without checking for overflow, so a huge data_len wraps to a small frame_len that passes the size check, while data_len remains huge and is used to bound a memory write loop.
Impact
The heap overflow can crash the process, causing denial of service, and may potentially lead to remote code execution.
What the attacker needed
Network access to the websocket service; ability to complete websocket handshake
How it was found
- Establish a websocket connection by sending an HTTP upgrade request.
- Send a websocket frame with the mask bit set and a payload length field set to a very large value that causes an integer overflow when added to the header length.
- The server processes the frame, and the overflow bypasses the length check, leading to a heap buffer overflow.
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.
Websocket is a protocol for two-way communication between a browser and a server. The library calculates the total packet size by adding a header length to a data length, but if the data length is extremely large, the addition can wrap around to a small number. This small number passes a safety check, but the actual data length remains huge, so a later loop writes far beyond the buffer, corrupting memory.
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.