
MongoBleed: CVE-2025-14847 Memory Leak Discovery Tool
MongoBleed is a high-performance security auditing tool designed to detect and demonstrate CVE-2025-14847. This vulnerability allows an unauthenticated, remote attacker to leak fragments of uninitialized heap memory from a MongoDB server by exploiting a length-mismatch flaw in the zlib decompression logic.
To safely test this script, use the following docker-compose.yml to spin up a vulnerable MongoDB 8.2.2 instance.
Run instance with:
docker-compose up -d
Ensure you have Python 3.8+ installed. No external libraries are required (uses built-in socket, zlib, and concurrent.futures).
Basic Scan
python mongobleed.py --host 127.0.0.1 --port 27017
Advanced Options
python mongobleed.py --host 127.0.0.1 --threads 50 --range 100 10000 --output leak_dump.bin
The script sends a crafted OP_COMPRESSED (opcode 2012) message. It lies about the uncompressed length of the payload. The MongoDB server allocates a heap buffer of the "lied" size, decompresses a tiny amount of data into it, and then mistakenly returns the entire uninitialized buffer back to the client.
The only permanent way to resolve CVE-2025-14847 is to upgrade the MongoDB binary to a version that includes a fix for the OP_COMPRESSED length-validation logic.
Permanent Fix (Upgrade)
Apply the official patches from MongoDB. These versions include a mandatory check to ensure the decompressed data size matches the uncompressedSize field in the message header.
If an immediate upgrade is not possible due to uptime requirements, you can block the attack vector by modifying the server configuration.
Disable Vulnerable Compressor (Recommended)
The vulnerability is specific to the zlib implementation. You can disable zlib and force the server to use snappy or zstd, which are not affected by this specific heap-over-read bug.
Via Command Line: Restart the mongod instance with the following flag (note the exclusion of zlib):
mongod --networkMessageCompressors snappy,zstd
Via Configuration File (mongod.conf):
net:
compression:
compressors: snappy,zstd
This tool is for educational and authorized security testing purposes only. Unauthorized access to computer systems is illegal. The author is not responsible for any misuse of this tool. Patch your MongoDB instances immediately to versions 8.2.3+ or 8.0.17+.
| Major Branch | Recommended Secure Version |
|---|
| MongoDB 8.2 | Upgrade to 8.2.3 or later |
| MongoDB 8.0 | Upgrade to 8.0.17 or later |
| MongoDB 7.0 | Upgrade to 7.0.28 or later |
| MongoDB 6.0 | Upgrade to 6.0.27 or later |
| MongoDB 5.0 | Upgrade to 5.0.32 or later |
| MongoDB 4.0 | Upgrade to 4.4.30 or later |