Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
mongobleed-detector — Detection Script for MongoBleed Exploitation | Kitploit
Tools/GitHubGitHub/neo23x0/mongobleed-detector
Vulnerability AnalysisScripting & AutomationForensicsDigital ForensicsThreat IntelligenceIncident ResponseDatabase SecurityLog Analysis
GitHubneo23x0/mongobleed-detector

mongobleed-detector

Detection Script for MongoBleed Exploitation

View Repository
811338 months agoReviewed by Kitploit

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

MongoBleed Detector

Offline MongoDB Analysis Tool for CVE-2025-14847 (MongoBleed)

A standalone Linux command-line tool that analyzes MongoDB data to identify likely exploitation of CVE-2025-14847 using multiple detection modules.

Table of Contents

  • Overview
  • Detection Modules
  • Requirements
  • Installation
  • Two Modes of Operation
  • Mode 1: Local Analysis
  • Mode 2: Remote Collection
  • Command-Line Options
  • Confidence Levels
  • Example Output
  • Testing
  • Caveats & Limitations
  • References & Credits
  • License

Overview

MongoBleed (CVE-2025-14847) is a memory disclosure vulnerability in MongoDB's zlib decompression that allows attackers to extract sensitive data—credentials, session tokens, PII—directly from server memory without authentication.

This tool helps incident responders detect exploitation attempts using multiple evidence sources:

  • Module A: Log correlation (connection events, metadata absence)
  • Module B1: Assert counts analysis (serverStatus.asserts snapshots)
  • Module B2: FTDC spike detection (diagnostic.data time series)

Key Features

Download Tool
  • Multi-Module Detection - Correlates multiple data sources for higher confidence
  • Offline & Agentless - No network connectivity required during analysis
  • Auto-Discovery - Automatically detects available data sources
  • Remote Collection - Collects data from multiple hosts via SSH
  • Combined Scoring - HIGH/MEDIUM/LOW confidence verdicts
  • Streaming Processing - Handles large log files efficiently

Detection Modules

Module A: Log Correlation

Analyzes MongoDB JSON logs to detect exploitation patterns:

Event IDTypeDescription
22943Connection AcceptedLogged when a client connects
51800Client MetadataLogged when a client sends driver/application info
22944Connection ClosedLogged when a client disconnects

Key insight: Legitimate MongoDB drivers always send client metadata. The MongoBleed exploit connects, extracts memory, and disconnects—but never sends metadata.

Module B1: Assert Counts

Analyzes snapshots of db.serverStatus().asserts to detect unusual patterns in asserts.user counters:

  • Multiple Snapshots: Compares snapshots over time to detect sudden spikes in user assertions
  • Single Snapshot Heuristic: When only one snapshot is available, detects suspicious patterns by comparing asserts.user to other assertion types. If user asserts are disproportionately high (ratio ≥250x) or all other types are zero, flags as suspicious (MEDIUM confidence)

Note: Cumulative counters can produce false positives. Use in combination with FTDC (Module B2) for best results.

Module B2: FTDC Spike Detection

Analyzes MongoDB's Full-Time Diagnostic Data Capture (FTDC) files to detect time-localized spikes in assertion counters. FTDC samples serverStatus periodically, enabling precise timing of potential attacks.

Requirements

Shell Script (mongobleed-detector.sh)

  • Linux or macOS (bash 4+)
  • jq - JSON processor
  • awk (gawk recommended)
  • gzip - For compressed log support

Python Components (optional, for FTDC decoding)

  • Python 3.8+
  • pymongo - For FTDC file decoding

Remote Scanner (mongobleed-remote.py)

  • Python 3.8+
  • Native SSH client (ssh, scp commands)
  • No additional Python packages required for basic operation

Install Dependencies

root@kitploit:~
# Shell script dependencies
# Debian/Ubuntu
apt-get install jq gawk gzip

# RHEL/CentOS/Fedora
dnf install jq gawk gzip

# macOS
brew install jq gawk

# Python dependencies (for FTDC decoding)
pip install -r requirements.txt

Installation

root@kitploit:~
# Clone the repository
git clone https://github.com/your-org/mongobleed-detector.git
cd mongobleed-detector

# Make scripts executable
chmod +x mongobleed-detector.sh
chmod +x mongobleed-remote.py
chmod +x ftdc-decode.py

# Install Python dependencies (optional, for FTDC support)
pip install -r requirements.txt

Two Modes of Operation

Mode 1: Local Analysis

Analyze data that has been manually collected from MongoDB hosts.

Mode 2: Remote Collection

Automatically collect data from multiple hosts via SSH, then analyze locally.

Mode 1: Local Analysis

Step 1: Collect Data

Collect data from your MongoDB hosts and organize it into this structure:

root@kitploit:~
./collected-data/
├── logs/                    # MongoDB JSON logs
│   ├── mongod.log
│   ├── mongod.log.1
│   └── mongod.log.2.gz
├── assert-counts/           # serverStatus().asserts snapshots
│   ├── asserts-2025-01-01.json
│   └── asserts-2025-01-02.json
└── ftdc-files/              # FTDC diagnostic.data contents
    ├── metrics.2025-01-02T10-00-00Z-00000
    └── metrics.interim

Collecting Logs

root@kitploit:~
# Copy from remote host
scp user@mongohost:/var/log/mongodb/mongod.log* ./collected-data/logs/

Collecting Assert Counts

Run this command on the MongoDB host (requires mongosh access):

root@kitploit:~
mongosh --quiet --eval 'JSON.stringify({
  timestamp: new Date().toISOString(),
  hostname: db.hostInfo().system.hostname,
  asserts: db.serverStatus().asserts,
  uptime: db.serverStatus().uptime
})' > asserts-$(date +%Y%m%d-%H%M%S).json

Copy the resulting JSON file to ./collected-data/assert-counts/.

Tip: Run this command multiple times (e.g., hourly) to establish a baseline and detect spikes.

Collecting FTDC Files

FTDC files are located at:

  • mongod: <storage.dbPath>/diagnostic.data/ (commonly /var/lib/mongodb/diagnostic.data/)
  • mongos: Derived from systemLog.path (e.g., /var/log/mongodb/mongos.diagnostic.data/)
root@kitploit:~
# Copy FTDC files (may require sudo)
sudo cp /var/lib/mongodb/diagnostic.data/metrics.* ./collected-data/ftdc-files/

Step 2: Run Analysis

root@kitploit:~
# Auto-discovery mode - analyzes all available data
./mongobleed-detector.sh --data-dir ./collected-data/

# With custom thresholds
./mongobleed-detector.sh --data-dir ./collected-data/ \
    -t 1440 \              # 24-hour lookback
    -c 50 \                # Lower connection threshold
    --spike-threshold 50   # Lower spike threshold

Legacy Mode (Logs Only)

For backward compatibility, you can still analyze logs directly:

root@kitploit:~
# Scan default paths
./mongobleed-detector.sh

# Scan specific log files
./mongobleed-detector.sh -p /path/to/logs/*.json

# Forensic mode (analyze multiple hosts)
./mongobleed-detector.sh --forensic-dir /evidence/

Mode 2: Remote Collection

Automatically collect data from multiple hosts and analyze:

root@kitploit:~
# Create hosts file
cat > hosts.txt << EOF
mongo-prod-01.example.com
mongo-prod-02.example.com
mongo-staging.example.com
EOF

# Collect and analyze
./mongobleed-remote.py --hosts-file hosts.txt --user admin --output-dir ./collected-data/

Remote Scanner Options

root@kitploit:~
# Use specific SSH key
./mongobleed-remote.py --hosts-file hosts.txt --user admin --key ~/.ssh/mongodb_key

# Parallel execution
./mongobleed-remote.py --hosts-file hosts.txt --user admin --parallel 10

# Skip FTDC collection (faster)
./mongobleed-remote.py --hosts-file hosts.txt --user admin --skip-ftdc

# Collect only, analyze later
./mongobleed-remote.py --hosts-file hosts.txt --user admin --collect-only

# Pass SSH options (e.g., jump host)
./mongobleed-remote.py --hosts-file hosts.txt --user admin \
    -o "ProxyJump=bastion.example.com"

# Use sudo for privileged file access (FTDC files are often restricted)
./mongobleed-remote.py --hosts-file hosts.txt --user admin --sudo

# Debug mode to troubleshoot connection issues
./mongobleed-remote.py --hosts-file hosts.txt --user admin --debug

Note on FTDC Permissions: FTDC files in /var/lib/mongodb/diagnostic.data/ are typically owned by the mongodb user and not readable by regular users. If you see "FTDC Permission Issues" warnings, use the --sudo flag. This requires the remote user to have passwordless sudo access (NOPASSWD in sudoers).

What Gets Collected

Data TypeSourceDestination
Logs/var/log/mongodb/mongod.log*<output-dir>/<hostname>/logs/
Assert Countsmongosh command<output-dir>/<hostname>/assert-counts/
FTDC Files/var/lib/mongodb/diagnostic.data/metrics.*<output-dir>/<hostname>/ftdc-files/

Command-Line Options

mongobleed-detector.sh

OptionDescriptionDefault
-d, --data-dir <path>Directory with collected data (auto-discovery mode)-
-p, --path <glob>Additional log path/glob (repeatable)-
-t, --time <minutes>Lookback window in minutes4320 (3 days)
-c, --conn-thresholdConnection count threshold100
-b, --burst-thresholdBurst rate threshold per minute400
-m, --metadata-rateMetadata rate threshold (0.0-1.0)0.10
--spike-thresholdAssert spike threshold100
--user-ratio-thresholdUser/other assert ratio for single snapshot detection250
--no-default-pathsSkip default log pathsfalse
--forensic-dir <path>Analyze subdirectories as separate hosts-

mongobleed-remote.py

OptionDescriptionDefault
-H, --host <hostname>Remote host to scan (repeatable)-
-f, --hosts-file <file>File containing hostnames (one per line)-
-u, --user <user>SSH usernameCurrent user
-k, --key <file>SSH private key filessh-agent
-P, --port <port>SSH port22
-o, --ssh-options <opt>Additional SSH options (repeatable)-
--sudoUse sudo for privileged file access (FTDC)false
-O, --output-dir <path>Directory to store collected data./collected-data
--log-path <path>Remote log path to collect (repeatable)Standard paths
--ftdc-path <path>Remote FTDC directory path (repeatable)Standard paths
--skip-logsSkip log collectionfalse
--skip-assertsSkip serverStatus().asserts collectionfalse
--skip-ftdcSkip FTDC file collectionfalse
--collect-onlyOnly collect data, don't run analysisfalse
-j, --parallel <n>Number of parallel connections5
--timeout <seconds>SSH command timeout300
-d, --debugEnable debug output (show SSH commands)false
-q, --quietSuppress progress messagesfalse

Exit Codes

CodeMeaning
0No HIGH or MEDIUM findings
1HIGH or MEDIUM findings detected
2Error (missing dependencies, no data, etc.)

Confidence Levels

The tool provides a combined confidence verdict based on all available evidence:

ConfidenceCriteriaInterpretation
HIGHFTDC peaks detected AND suspicious logs in same time windowStrong indicator of exploitation
MEDIUMFTDC peaks OR suspicious logs (not correlated)Investigation recommended
LOWOnly cumulative assert counts without spikesAnomaly detected, weak evidence
INFONo significant findingsNormal activity

Module-Specific Risk Levels

For log correlation (Module A), individual IPs are classified:

RiskCriteria
HIGHConnections ≥ threshold, metadata rate < 10%, burst rate ≥ 400/min
MEDIUMConnections ≥ threshold, metadata rate < 10%, burst rate < 400/min
LOWConnections ≥ threshold, metadata rate ≥ 10%
INFOConnections < threshold

Example Output

root@kitploit:~
INFO: Auto-discovery mode: analyzing ./collected-data/
INFO: Module A: Analyzing 3 log file(s)...
INFO: Module B1: Analyzing assert-counts...

╔══════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║                              MongoBleed (CVE-2025-14847) Detection Results                                       ║
╚══════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

Module Status:
  [✓] Module A (Log Correlation): 3 log file(s) found
  [✓] Module B1 (Assert Counts): 4 snapshot(s) found
  [−] Module B2 (FTDC Spikes): No FTDC files or decoder unavailable

Analysis Parameters:
  Time Window:        4320 minutes
  Connection Thresh:  100
  Burst Rate Thresh:  400/min
  Metadata Rate:      0.10
  Spike Threshold:    100
  User Ratio Thresh:  250x

Module A - Log Correlation Findings:

Risk     SourceIP                                  ConnCount  MetaCount  DiscCount    MetaRate%    BurstRate/m FirstSeen (UTC)        LastSeen (UTC)        
-------- ---------------------------------------- ---------- ---------- ---------- ------------ -------------- ---------------------- ----------------------
HIGH     137.137.137.137                                8172          0       8172        0.00%         490.32 2025-12-27T12:55:52Z   2025-12-27T13:12:32Z  

Module B1 - Assert Counts Analysis:
  Analyzed 4 snapshots from 2025-01-01T10:00:00Z to 2025-01-01T11:30:00Z
    asserts.user: 100 -> 860 (delta: 760)
  SPIKE DETECTED: 2025-01-01T10:30:00Z to 2025-01-01T11:00:00Z
    Delta: +740 user asserts (110 -> 850)

═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Combined Verdict:
  MEDIUM CONFIDENCE - Investigation recommended
    - Suspicious connection patterns but FTDC data unavailable for correlation

⚠ IMPORTANT: If exploitation is confirmed, patching alone is insufficient.
  - Rotate all credentials that may have been exposed
  - Review accessed data for sensitive information disclosure
  - Check for lateral movement from affected systems
  - Preserve logs for forensic analysis

Caveats:
  - Connection metadata absence is PoC-specific and can be evaded
  - Assertion counters are cumulative - false positives possible without baseline
  - FTDC provides timing but not perfect attribution
  - Patch + rotate secrets remains mandatory regardless of detection results

Testing

The repository includes a test suite to validate the detector.

Real-World Example Data

The example-data/ directory contains real data from a MongoDB 8.0.16 instance that was attacked using the MongoBleed PoC:

root@kitploit:~
example-data/
├── logs/                    # Real MongoDB logs with attack patterns
│   ├── mongod.log
│   └── mongod.log.1.gz
├── assert-counts/           # Post-attack serverStatus().asserts snapshot
│   └── asserts-post-attack.json
└── ftdc-files/              # Real FTDC diagnostic data files
    └── metrics.*

This data shows:

  • 16,344 connections from attacker IP 137.137.137.137 with 0% metadata
  • 37,384 user asserts accumulated during the attack
  • FTDC files spanning the attack window

Generate Synthetic Test Data

root@kitploit:~
./test/generate-test-logs.sh

This creates additional synthetic test data with various patterns:

  • Log files with HIGH/MEDIUM/LOW/INFO risk patterns
  • Assert-counts JSON snapshots (with and without spikes)
  • Edge cases (IPv6, malformed input, etc.)

Run Tests

root@kitploit:~
./test/test-detector.sh

Expected output:

root@kitploit:~
╔════════════════════════════════════════════════════════╗
║       MongoBleed Detector Test Suite                   ║
╚════════════════════════════════════════════════════════╝

Module A Tests (Log Correlation):
✓ PASS: Exit code is 1 (findings detected)
✓ PASS: Detected source IP 137.137.137.137
...

Module B1 Tests (Assert Counts):
✓ PASS: Shows Module B1 status
✓ PASS: Detected assert spike
...

Auto-Discovery Mode Tests:
✓ PASS: Shows Module A status
✓ PASS: Shows combined verdict
...

Results:
  Passed: 24
  Failed: 0

All tests passed!

Caveats & Limitations

⚠️ Important Limitations

Detection Limitations

  1. PoC-Specific Detection: The metadata absence detection is based on the known MongoBleed PoC behavior. A sophisticated attacker could modify the exploit to send fake metadata, though this would reduce exploitation speed.

  2. Cumulative Counters: asserts.user is cumulative since mongod restart. Without baseline snapshots, high values may be normal for long-running instances. Multiple snapshots over time significantly improve accuracy.

  3. FTDC Timing: FTDC provides timing information but not perfect attribution. Use in conjunction with log correlation for best results.

  4. Log Retention: Can only analyze logs that exist. Aggressive rotation or attacker log clearing will destroy evidence.

Technical Requirements

  1. JSON Logging Required: MongoDB 4.4+ defaults to JSON logs. Legacy text logs are not supported.

  2. FTDC Decoder: FTDC decoding requires Python 3 with pymongo. Without it, Module B2 is unavailable.

  3. mongosh Access: Collecting assert counts requires mongosh with appropriate permissions.

Post-Detection Actions

If HIGH or MEDIUM findings are confirmed:

  1. Preserve Evidence - Copy logs before they rotate
  2. Credential Rotation - Rotate all MongoDB credentials and any secrets that may have been in memory
  3. Data Review - Assess what sensitive data may have been exposed
  4. Lateral Movement - Check for attacker movement to other systems
  5. Patch Immediately - Apply MongoDB security updates
  6. Report - Follow your incident response procedures

References & Credits

Detection Research

The detection logic in this tool is based on research by Eric Capuano and Tamir Zimerman:

  • Hunting MongoBleed (CVE-2025-14847) - Eric Capuano's writeup on the vulnerability and detection methodology
  • A Different MongoBleed Perspective - Tamir Zimerman's analysis of assertion-based detection

MongoDB Documentation

  • serverStatus Command - asserts field documentation
  • Full Time Diagnostic Data Capture - FTDC storage locations
  • What is MongoDB FTDC - FTDC format background

Affected Versions

VersionVulnerableFixed In
8.2.x8.2.0 - 8.2.28.2.3
8.0.x8.0.0 - 8.0.168.0.17
7.0.x7.0.0 - 7.0.277.0.28
6.0.x6.0.0 - 6.0.266.0.27
5.0.x5.0.0 - 5.0.315.0.32
4.4.x4.4.0 - 4.4.294.4.30
4.2.x4.2.0+No fix
4.0.x4.0.0+No fix
3.6.x3.6.0+No fix

License

See LICENSE file.

Contributing

Contributions welcome! Please submit issues and pull requests.

If you test this tool against production data, we'd especially appreciate feedback on:

  • False positive rates
  • Legitimate traffic patterns
  • Edge cases or parsing failures
  • FTDC decoding issues