Skip to content
Memory corruption Write-up Intermediate

I discovered a critical exploit in ZeroMQ with mostly pure luck

The CurveZMQ authentication protocol placed incoming metadata into a fixed-size stack buffer without any size check, and decrypted the payload into another fixed-size buffer. An attacker could send an oversized metadata field to overflow the stack and crash the process, potentially leading to remote code execution.

fangpenlin.com

Published on fangpenlin.com

If you work in the tech industry, I bet you have heard the crazy story of the XZ backdoor. Long story short, an open-source contributor known as Jia Tan contributed to the XZ library.

Fang-Pen Lin, on fangpenlin.com

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 write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the code copied attacker-controlled metadata into fixed-size stack buffers without validating the length, causing a stack buffer overflow.

Impact

An attacker could crash the ZeroMQ process and potentially execute remote code, though the text only confirms a crash and describes the bug as critical with a CVSS score of 9.8.

What the attacker needed

Ability to connect to a CurveZMQ socket; send oversized metadata field

The fix

The ZeroMQ maintainers created a patch and released a new version to major Linux distributions.

How it was found

  1. Read the CurveZMQ source code and notice the fixed-size stack buffers with no size check.
  2. Write code that connects to a CurveZMQ socket and sends a very large metadata field.
  3. Observe that the process crashes.
  4. Use a debugger and a co-worker to confirm the crash is a real stack overflow vulnerability.

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 write-up has not been written yet. The Original tab links to the source.

A stack buffer is a small, fixed-size area of memory a program uses for temporary data. If a program copies more data into it than it can hold without checking the size, the extra data spills over and corrupts nearby memory, which can crash the program or let an attacker run their own code. Here, the metadata field in a messaging protocol had no length limit, so sending a huge value caused this overflow.

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.

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.