
MongoBleed (CVE-2025-14847) Lab & PoC : A complete educational environment to reproduce the critical unauthenticated memory leak in MongoDB. Includes a vulnerable Docker container with multi-database seeding (PII, API keys) and a Python exploit to demonstrate data extraction. Ideal for security research and awareness. 1-day analysis.
This laboratory is designed to reproduce and analyze MongoBleed (CVE-2025-14847), a critical vulnerability in MongoDB. This flaw allows unauthenticated attackers to read sensitive data from the server's memory due to improper handling of compressed messages.
The environment includes a vulnerable MongoDB instance populated with dummy sensitive data (PII, API keys, financial records) to demonstrate the severity of the leak.
CVE ID: CVE-2025-14847
Name: MongoBleed
Component: Wire Protocol (OP_COMPRESSED)
Vulnerable Versions: MongoDB 6.0.x < 6.0.27, 7.0.x < 7.0.28, 8.0.x < 8.0.17 (and others)
URL: Click on it -> NVD CVE-2025-14847
The vulnerability resides in the way MongoDB handles OP_COMPRESSED messages using the zlib compression algorithm.
uncompressed_size field in the header is intentionally set to a value much larger than the actual decompressed data size.uncompressed_size.zlib decompressor writes the actual (small) payload to the beginning of this buffer. The rest of the buffer remains uninitialized, containing residual data from previous operations (RAM artifacts).The lab consists of:
admin / secretpassword).init-mongo.js) that populates 3 distinct databases to simulate a real Cloud Infrastructure SaaS environment:
compute_instances: Sensitive metadata (User Data scripts, API keys).deployment_secrets: High-value targets (K8s tokens, CI/CD keys, Slack webhooks).users: User credentials, password hashes (Argon2), and MFA backup codes (leaked in plain text).query_logs: Contains historical queries, some including leaked credentials (e.g., AWS keys).exploit.py) implementing the reverse-engineered protocol attack.Launch the vulnerable container. This will automatically create the databases and populate them with data.
docker-compose up -d
Wait about 10-15 seconds for the database to initialize and load the data.
Note: If you have run this lab before, ensure you reset the volume to load the latest data structure:
docker-compose down -v
docker-compose up -d
You can install the required dependencies using pip with the legacy requirements.txt or the modern pyproject.toml.
Option A: Using requirements.txt (Standard)
pip install -r requirements.txt
Option B: Using pyproject.toml (Modern) This will install the project and its dependencies in the current environment.
pip install .
We have provided a verification script to ensure the database is reachable and the data has been seeded correctly.
python verify_lab.py
This script uses the admin credentials to check the existence of databases like sensitive_db, legacy_crm, etc.
Execute the Python script to attack the server. No credentials are required for this step, demonstrating the unauthenticated nature of the vulnerability.
python exploit.py --host localhost --port 27017 --min 100 --max 5000
The script performs the following steps:
OP_COMPRESSED header with a faked, inflated size.Expected Output: You should see output indicating leaks found at various offsets, followed by a summary of detected secrets.
[*] MongoBleed Exploit (Custom Implementation)
[*] Target: localhost:27017
[*] Scanning memory offsets 100 to 5000...
[+] Offset 120 | ... dbmongotesting ... compute_instances ...
[+] Offset 145 | ... field name 'AKIAIOSFODNN7EXAMPLE' is not valid ... [!] FOUND AKIA
[+] Offset 210 | ... "token": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ik16UTBOVFZ... [!] FOUND token
[*] Scan completed in 12.45s
[*] Total bytes leaked: 4502
[*] Unique fragments: 156
[*] Secrets Summary:
[!] Found pattern: AKIA
[!] Found pattern: token
[!] Found pattern: password
To fix this vulnerability in production environments:
This project is licensed under the MIT License. See the LICENSE file for details.
This material is for educational and research purposes only. Do not use this exploit on systems you do not own or have explicit permission to test. The author is not responsible for any misuse of this information or tool.
Joseph Meneses (ElJoamy)
Backend and AI Developer · Cybersecurity Engineer · DBA · Penetration Tester