Dubbed 'MongoBleed', this vulnerability mimics the infamous Heartbleed bug. By sending a crafted compressed packet, an unauthenticated attacker can trick the server into treating uninitialized heap memory as valid data. When the parser inevitably chokes on the garbage data, it helpfully echoes it back in an error message, leaking sensitive secrets like admin credentials and session tokens.
A critical, unauthenticated heap memory disclosure vulnerability in MongoDB's wire protocol handling allows attackers to bleed secrets—including passwords and AWS keys—directly from server memory.
If you thought we learned our lesson from OpenSSL's Heartbleed in 2014, you were wrong. CVE-2025-14847, affectionately nicknamed MongoBleed, brings that same chaotic energy to MongoDB. It is an unauthenticated remote memory disclosure vulnerability that affects the network transport layer of the database server.
Why is this terrifying? Because databases are the ultimate treasure chests of an infrastructure. They don't just hold data; they hold the keys to the data. When you bleed memory from a web server, you might get a session ID. When you bleed memory from a database process, you get connection strings, admin passwords, AWS secret keys, and fragments of queries from other concurrent users.
This isn't a complex ROP chain or a heap feng-shui masterpiece. It is a logic error so simple it hurts: the server trusts the client to tell it how big a buffer it needs, and then forgets to check if it actually filled that buffer with valid data before trying to read it.
The vulnerability lives in message_compressor_zlib.cpp, specifically within the handling of the OP_COMPRESSED opcode (2012). This opcode allows clients (drivers) to send compressed requests to save bandwidth. The header for this message includes a field called uncompressed_size.
Here is the logic failure: The server reads uncompressed_size from the packet header and immediately allocates a heap buffer of that size. It then decompresses the attached payload into this buffer. Crucially, the server code assumed that the decompression process would fill the entire buffer. It did not calculate the actual length of the decompressed bytes written.
If an attacker says "I have 8KB of data" but provides a compressed payload that only expands to 10 bytes, the server allocates 8KB, writes 10 bytes at the start, and leaves the remaining 8182 bytes exactly as they were on the heap. This trailing memory is full of "ghosts"—sensitive data left over from previous operations.
Sometimes the most devastating bugs are the shortest. The flaw boils down to the return value of the decompression helper function. It was returning the capacity of the buffer (which was trusted from user input) rather than the actual amount of data processed.
Below is the conceptual diff. In the vulnerable version, the code returns output.length(), which is the total size of the allocated vector. In the patched version, it returns length, which is the integer value returned by the zlib decompression routine indicating how many bytes were actually written.
// VULNERABLE CODE (Simplified)
// 'output' is a vector resized to the attacker-controlled 'uncompressed_size'
size_t length = decompress(input, output);
// The bug: We return the total buffer size, not the data size
return { output.length() };
// PATCHED CODE
size_t length = decompress(input, output);
// The fix: We return the actual amount of valid data
return length;Because the function returned the full size, the caller (the BSON parser) assumed the entire buffer was valid BSON data. It would parse the 10 bytes of real data, and then continue blindly parsing the 8KB of uninitialized heap memory.
How do we get the data out? We don't need a side channel; MongoDB hands it to us on a silver platter. The exploit flow is brutally efficient:
OP_COMPRESSED message. Set the uncompressed_size to something large (e.g., 64KB). Set the payload to a valid zlib stream of just a few bytes (e.g., an empty BSON object {}).InvalidBSON or Unrecognized field. Crucially, to be helpful, the error message often quotes the offending data. "Error: Field 'x\x00\xFFadmin_pass...' is not valid." That quoted string is your stolen memory.Since this is a heap leak, the contents are nondeterministic but highly sensitive. In a high-traffic database, the heap is constantly recycling memory used for authentication, query processing, and disk I/O.
Researchers and attackers exploiting this in the wild have recovered:
lsids (logical session IDs) which can be used to hijack active sessions.With CISA adding this to the KEV (Known Exploited Vulnerabilities) catalog in late 2025, it is confirmed that ransomware groups are using this to harvest credentials before deploying encryption payloads.
The remediation is straightforward but urgent. MongoDB has released patches for all supported versions (from 4.4 to 8.2). If you are on an End-of-Life version like 3.6 or 4.0, you are out of luck—you must upgrade major versions or stay vulnerable.
If you cannot patch immediately (hello, enterprise change management boards), you have one kill-switch: Disable zlib.
This vulnerability is specific to the zlib compressor. You can edit mongod.conf to remove zlib from the allowed compressors list. This breaks the exploit chain completely without requiring a binary update, though it may increase network bandwidth usage slightly.
net:
compression:
compressors: snappy,zstd # zlib removedCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N| Product | Affected Versions | Fixed Version |
|---|---|---|
MongoDB Server MongoDB Inc. | 8.2.0 - 8.2.2 | 8.2.3 |
MongoDB Server MongoDB Inc. | 8.0.0 - 8.0.16 | 8.0.17 |
MongoDB Server MongoDB Inc. | 7.0.0 - 7.0.27 | 7.0.28 |
MongoDB Server MongoDB Inc. | 6.0.0 - 6.0.26 | 6.0.27 |
MongoDB Server MongoDB Inc. | 5.0.0 - 5.0.31 | 5.0.32 |
MongoDB Server MongoDB Inc. | 4.4.0 - 4.4.29 | 4.4.30 |
MongoDB Server MongoDB Inc. | 3.6, 4.0, 4.2 | None (EOL) |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-200 (Exposure of Sensitive Information) |
| CVSS v4.0 | 8.7 (High) |
| Attack Vector | Network (Unauthenticated) |
| EPSS Score | 77.17% |
| Exploit Status | Active / Weaponized |
| Component | message_compressor_zlib.cpp |
| Protocol | OP_COMPRESSED (2012) |
The product exposes sensitive information to an unauthorized actor by sending it back in an error message or other response.
Get the latest CVE analysis reports delivered to your inbox.