How joe-desimone/mongobleed works
Purpose and Entry Points
mongobleed.py is a Python proof-of-concept scanner for CVE-2025-14847, targeting vulnerable MongoDB servers that accept unauthenticated wire-protocol connections. Its CLI is the primary entry point; it accepts target host/port, probe-length range, and output file parameters.
The local test environment starts through docker-compose.yml, then the scanner connects to that MongoDB instance.
Exploit Scanner
mongobleed.py owns the end-to-end attack workflow:
• Opens a direct network connection to MongoDB.
• Constructs malformed compressed MongoDB messages containing BSON with attacker-controlled inflated length claims.
• Iterates configured document-length offsets to alter where uninitialized memory is interpreted as BSON field-name data.
• Receives and parses server responses for leaked fragments.
• Deduplicates, reports, and writes recovered bytes to the configured output file.
Path: mongobleed.py
MongoDB Wire-Protocol Boundary
The scanner operates below normal MongoDB client APIs, communicating directly with the MongoDB server’s binary wire protocol. The critical boundary is the compressed-message/decompression path on the remote server: a claimed uncompressed size drives allocation, while the vulnerable server later treats the full allocated region as valid BSON input.
Path: mongobleed.py
Probe and Leak Extraction Stage
Each probe uses a selected BSON/document length within the --min-offset to --max-offset range. The remote parser reads beyond actual decompressed content until null terminators are encountered, so separate offsets can expose different memory regions. The scanner aggregates useful decoded fragments and tracks total leaked bytes and unique fragments.
Path: mongobleed.py
Output Persistence
Recovered memory is surfaced in console findings and persisted as a binary artifact, defaulting to leaked.bin. This output is intentionally separate from the scanner’s transient request/response processing and can contain arbitrary server-memory content.
Path: mongobleed.py
Local Vulnerable Target Infrastructure
docker-compose.yml defines the disposable MongoDB environment used to reproduce and validate the vulnerability locally. init/init-mongo.js is MongoDB initialization logic executed for that containerized test setup, establishing any seed state needed for meaningful memory-leak demonstrations.
Paths: docker-compose.yml, init/init-mongo.js
Runtime and External Dependencies
The operator runtime is Python 3 executing mongobleed.py. The target runtime is an affected MongoDB release, typically reached over TCP port 27017. Docker Compose provides local orchestration; the exploit itself depends on MongoDB’s server-side zlib decompression and BSON parsing behavior rather than a MongoDB driver or web service.
Main entry points: mongobleed.py MongoDB TCP connection · docker-compose.yml Docker Compose · init-mongo.js MongoDB initialization
Components 14
Operator scanner
- Scanner CLI · Accepts target, offset range, and output parameters.
mongobleed.py - Python 3
- Attack workflow · Coordinates probing, extraction, reporting, and persistence.
mongobleed.py - Malformed message builder · Builds compressed MongoDB messages with inflated BSON length claims.
mongobleed.py - Offset probe loop · Varies claimed document length across the configured range.
mongobleed.py - Response parser · Parses server responses for leaked BSON fragments.
mongobleed.py - Fragment aggregation · Tracks unique fragments and total recovered bytes.
mongobleed.py - Recovered bytes · Console findings and binary memory-leak output, defaulting to leaked.bin.
mongobleed.py
Local vulnerable target
- Docker Compose · Starts the disposable vulnerable MongoDB environment.
docker-compose.yml - MongoDB initialization · Establishes test state for leak demonstrations.
init/init-mongo.js - Affected MongoDB server · Accepts unauthenticated wire-protocol connections.
MongoDB vulnerability boundary
- zlib decompression allocation · Claimed uncompressed size drives allocation.
- BSON parser over-read · Treats the allocated region as valid BSON beyond actual decompressed content.
Other components
- MongoDB TCP connection · Direct binary wire-protocol connection, typically port 27017.
mongobleed.py
Connections 14
- Python 3 → Scanner CLI: executes
- Scanner CLI → Attack workflow: configures
- Attack workflow → Offset probe loop: runs
- Offset probe loop → Malformed message builder: selects length
- Malformed message builder → MongoDB TCP connection: sends compressed request
- MongoDB TCP connection → Affected MongoDB server: wire protocol
- Docker Compose → Affected MongoDB server: starts
- MongoDB initialization → Affected MongoDB server: initializes
- Affected MongoDB server → zlib decompression allocation: processes request
- zlib decompression allocation → BSON parser over-read: oversized allocation
- BSON parser over-read → MongoDB TCP connection: returns leaked response
- MongoDB TCP connection → Response parser: receives response
- Response parser → Fragment aggregation: extracts fragments
- Fragment aggregation → Recovered bytes: reports and writes