CVE-2025-14847 — MongoBleed
- CVE-2025-14847 (MongoBleed) leaks MongoDB server heap memory without authentication.
- The root cause is trusting the client-supplied uncompressedSize during OP_COMPRESSED decompression.
- Leaked memory can expose usernames, passwords, tokens and configuration; patch to the fixed releases.
CVE-2025-14847, also known as MongoBleed, is a vulnerability that allows attackers to read unauthorised data from the heap memory of the server running MongoDB — without any authentication.
MongoDB is a document-oriented, open-source NoSQL database. It stores data in formats such as JSON, BSON and XML, and supports search, delete and update operations over that data.
Background
MongoDB uses a socket-based protocol called the MongoDB Wire Protocol between client and server. After a connection is established, communication happens by sending and receiving OP_MSG message packets. For performant transfer of large payloads, MongoDB uses the OP_COMPRESSED packet format.
The parameter that matters is uncompressedSize — “the size the compressed data sent from client to server will occupy in memory once it is decompressed on the server.”
Root cause
// line 72 — client value assigned to length length = uncompressedSize; // line 73 — uncompress computes the real size into length uncompress(output.data(), &length, input.data(), input.size()); // line 83 — ROOT CAUSE // length was updated, but output.length() still returns the client's size! return SharedBuffer::allocate(output.length());
Inside decompressData, memory is allocated according to the client-supplied uncompressedSize. Data is read from the server's heap in the size the client chose, and returned to the client as if it were the result of decompression. The leaked memory can contain usernames, passwords, tokens and system configuration data.
The BSON leak
Objects in MongoDB are serialised/deserialised to the client in BSON (Binary JSON). During parsing, the end of a value is detected by a \0 null terminator. When the client-supplied BSON does not end with \0, Mongo keeps scanning the allocated region for one. Since no valid BSON object forms, an error is thrown — and that error message leaks memory contents.
The fix
The vulnerability was resolved by using the real length of the decompressed data during the decompressData operation, rather than the client-supplied value.
- 8.2.x — 8.2.2 and earlier
- 8.0.x — 8.0.16 and earlier
- 7.0.x — 7.0.27 and earlier
- 6.0.x — 6.0.26 and earlier
- 5.0.x — 5.0.31 and earlier
Frequently asked questions
What is MongoBleed (CVE-2025-14847)?
An unauthenticated heap memory-leak in MongoDB. By sending a crafted OP_COMPRESSED packet, an attacker makes the server return more memory than intended, leaking heap contents such as credentials and tokens back to the client.
Which MongoDB versions are affected and how do I fix it?
Versions up to 8.2.2, 8.0.16, 7.0.27, 6.0.26 and 5.0.31 are affected. The fix uses the real decompressed length instead of the client-supplied size, so upgrading to a patched release closes the leak.

