Skip to content
Info disclosure Write-up Intermediate

Your MongoDB Might Be Bleeding Secrets Right Now: Inside CVE‑20

A memory disclosure bug in MongoDB's zlib decompression logic, reachable before authentication, lets an attacker send malformed compressed packets and receive uninitialised heap memory in responses. This could leak credentials, session tokens, API keys and query results.

cybrNK Follow

Published on meetcyber.net

MongoBleed is one of those bugs that turns a quiet piece of infrastructure into a front row security incident, especially if you run self hosted MongoDB in production. Think Heartbleed, but for MongoDB’s wire protocol and zlib, with the same unpleasant property that an unauthenticated stranger on the internet can make…

cybrNK, on meetcyber.net

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

The decompression code returned the size of the allocated output buffer rather than the actual length of the decompressed data, so leftover heap bytes were treated as valid data.

Impact

An unauthenticated attacker could leak arbitrary chunks of process memory that may contain database credentials, session tokens, API keys, query results and internal metadata, and the bug is being exploited in the wild.

What the attacker needed

Network access to MongoDB port; zlib compression enabled; vulnerable MongoDB version

The fix

MongoDB was patched in later releases (8.2.3, 8.0.17, 7.0.28, 6.0.27, 5.0.32, 4.4.30); if patching is not possible, remove zlib from the compression settings or disable compression.

How it was found

  1. Send a single hex-encoded packet wrapping a tiny valid BSON document inside an OP_COMPRESSED message.
  2. Set the uncompressedSize header to a value larger than the real decompressed data.
  3. MongoDB allocates a larger buffer and decompresses the small payload into the start, leaving the rest uninitialised.
  4. MongoDB parses the whole buffer as BSON, fails on the dirty bytes, and often echoes them back in error messages.
  5. Watch the response for BSON signatures to confirm the leak.

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.

When MongoDB receives compressed network messages, it decompresses them into a buffer before checking who is sending them. A mistake in that decompression code means the server can send back leftover bytes from its own memory that were never meant to be seen. An attacker can keep asking and collect fragments that may include passwords or tokens.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by cybrNK

View all

4 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.