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

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.

Aleksandar Nikolic Follow

Originally disclosed on Cisco Talos

High 8.1 View original

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.

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 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

  1. Establish a websocket connection by sending an HTTP upgrade request.
  2. 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.
  3. 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.

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.