Skip to content

Improve mongobleed checks#21275

Merged
adfoster-r7 merged 1 commit intorapid7:masterfrom
adfoster-r7:improve-mongobleed-checks
Apr 16, 2026
Merged

Improve mongobleed checks#21275
adfoster-r7 merged 1 commit intorapid7:masterfrom
adfoster-r7:improve-mongobleed-checks

Conversation

@adfoster-r7
Copy link
Copy Markdown
Contributor

Added multiple improvements to the cve_2025_14847_mongobleed.rb module, such as adding new a dedicated check method,improved compression support detection as only zlib can be exploited, and resolving other false positives

Verification

Check vuln

msf6 > use auxiliary/scanner/mongodb/cve_2025_14847_mongobleed
msf6 auxiliary(scanner/mongodb/cve_2025_14847_mongobleed) > set RHOSTS 192.168.1.100
RHOSTS => 192.168.1.100
msf6 auxiliary(scanner/mongodb/cve_2025_14847_mongobleed) > check

[+] 192.168.1.100:27017 - The target is vulnerable. Server leaks memory via crafted OP_COMPRESSED message (MongoDB 4.4.26)

Network issues now bubbled up correctly:

msf auxiliary(scanner/mongodb/cve_2025_14847_mongobleed) > recheck rhost=127.0.0.1
[*] Reloading module...
[*] 127.0.0.1:27017 - Cannot reliably check exploitability. Could not connect to the target
msf auxiliary(scanner/mongodb/cve_2025_14847_mongobleed) > run rhost=127.0.0.1
[-] 127.0.0.1:27017       - Cannot reach 127.0.0.1:27017 - The connection was refused by the remote host (127.0.0.1:27017).
[*] 127.0.0.1:27017       - Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf auxiliary(scanner/mongodb/cve_2025_14847_mongobleed) >

Check Not vuln - no zlib compression enabled

msf auxiliary(scanner/mongodb/cve_2025_14847_mongobleed) > recheck 192.168.123.144
[*] Reloading module...
[*] 192.168.123.144:27017 - The target is not exploitable. Server does not have zlib compression enabled (MongoDB 4.4.26)
msf auxiliary(scanner/mongodb/cve_2025_14847_mongobleed) > 

Check not vuln - patched

msf auxiliary(scanner/mongodb/cve_2025_14847_mongobleed) > check tcp://127.0.0.1:30000
[*] 127.0.0.1:30000 - The target is not exploitable. Version 8.2.6 is patched

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the CVE-2025-14847 “Mongobleed” MongoDB scanner by making the framework check workflow more accurate, reducing false positives against non-MongoDB services, and tightening zlib/compression handling.

Changes:

  • Replaces the custom ACTION=CHECK flow with a standard scanner check_host implementation returning Exploit::CheckCode values.
  • Improves compressor detection by negotiating hello/isMaster with a BSON array (and adds BSON array building support).
  • Adds additional wire-protocol validation/sanity checks to reduce false positives and improve robustness.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
modules/auxiliary/scanner/mongodb/cve_2025_14847_mongobleed.rb Adds standard check_host, strengthens protocol validation, and refines compression detection logic (zlib-focused).
documentation/modules/auxiliary/scanner/mongodb/cve_2025_14847_mongobleed.md Updates usage docs to reflect the new check workflow and revised behavior/output.

Comment thread modules/auxiliary/scanner/mongodb/cve_2025_14847_mongobleed.rb
Comment thread modules/auxiliary/scanner/mongodb/cve_2025_14847_mongobleed.rb Outdated
Comment thread modules/auxiliary/scanner/mongodb/cve_2025_14847_mongobleed.rb
Comment thread documentation/modules/auxiliary/scanner/mongodb/cve_2025_14847_mongobleed.md Outdated
Comment thread documentation/modules/auxiliary/scanner/mongodb/cve_2025_14847_mongobleed.md Outdated
Comment thread modules/auxiliary/scanner/mongodb/cve_2025_14847_mongobleed.rb
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread modules/auxiliary/scanner/mongodb/cve_2025_14847_mongobleed.rb Outdated
Comment thread modules/auxiliary/scanner/mongodb/cve_2025_14847_mongobleed.rb
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread modules/auxiliary/scanner/mongodb/cve_2025_14847_mongobleed.rb Outdated
Comment thread modules/auxiliary/scanner/mongodb/cve_2025_14847_mongobleed.rb Outdated
Comment thread modules/auxiliary/scanner/mongodb/cve_2025_14847_mongobleed.rb Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment on lines 106 to +110
version_info = get_mongodb_version
compressors = get_server_compressors
is_mongodb = !version_info.nil? || !compressors.nil?

return Exploit::CheckCode::Safe('Target does not appear to be a MongoDB service') unless is_mongodb
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_host performs get_server_compressors before returning early for patched versions. If the version lookup succeeds but the compression probe hits a transient connection error, the rescue will return CheckCode::Unknown even though we already know the version is patched. Consider checking vuln_status == :patched and returning Safe before making the additional network call, or handling compressor lookup failures in a way that doesn’t override a definitive version-based result.

Copilot uses AI. Check for mistakes.
Comment on lines +177 to +181
if opcode == OP_COMPRESSED && response.length > 25
payload = Zlib::Inflate.inflate(response[25, msg_len - 25])
end
rescue Zlib::Error
# Decompression failed, check raw response
# Decompression failed — can't meaningfully scan compressed bytes
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

send_magic_packet_check attempts to zlib-inflate any OP_COMPRESSED response without checking the response’s compressorId. If the server replies with OP_COMPRESSED using snappy/zstd (or any non-zlib id), this will raise Zlib::Error and the method returns :unknown, making the check inconclusive. Parse and validate the compressorId byte (offset 24) and only inflate when it indicates zlib; otherwise handle the response in a way that preserves deterministic results (e.g., treat as inconclusive with an explicit reason).

Copilot uses AI. Check for mistakes.
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in Metasploit Kanban Apr 16, 2026
@adfoster-r7 adfoster-r7 added the rn-enhancement release notes enhancement label Apr 16, 2026
@adfoster-r7
Copy link
Copy Markdown
Contributor Author

Release Notes

Adds multiple improvements to the cve_2025_14847_mongobleed module, such as adding new a dedicated check method, improved compression support detection as only zlib can be exploited, and resolving other false positives

@adfoster-r7 adfoster-r7 merged commit c887384 into rapid7:master Apr 16, 2026
23 checks passed
@adfoster-r7 adfoster-r7 deleted the improve-mongobleed-checks branch April 16, 2026 13:22
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Metasploit Kanban Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rn-enhancement release notes enhancement

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants