Interpreter — Mirth Connect RCE to f-string eval Root
OS
Linux
Difficulty
Medium
Category
LINUX
Released
2026.02.21
Exploited CVE-2023-43208 deserialization RCE in Mirth Connect 4.4.0 for a shell, dumped DB creds, and cracked a PBKDF2-HMAC-SHA256 hash to become sedric. Escalated to root via a code-injection flaw in a root-run Flask app that evals an f-string built from XML patient fields.
Want to try this box yourself?
Spoiler-free mode is on by default — every solution stays hidden behind a reveal. Peek the hints, attempt each step, then unlock the answer when you're stuck. Turn it off to read every solution inline.
Nmap
Full Port Scan
Script and Version scan
Web Enumeration

Browsing to the IP, we find a login page.
Clicking the green Launch Mirth Connect Administrator button downloads a file called webstart.jnlp.
Looking at the file, we see a version number.
Searching online for a CVE, we find one for an unauthenticated RCE.
This CVE is fairly old, so we look to see if a Metasploit module exists for it.
We find one.
Initial Foothold
Looking at the options, we need to change the RHOST, RPORT, and LHOST.
Running the module, it is vulnerable, but it does not return a reverse shell. This means we need to try a simpler payload.
We get a shell.
It is always good practice to have multiple reverse shells, so we use the shell we got from the Metasploit module to grab another one.
We then upgrade to a TTY shell.
It seems like we got a shell as a low-privileged service user, and there is another user on the box, Sedric. We get permission denied when switching to Sedric's home directory.
Privilege Escalation
Shell as Sedric
The home directory of mirth has a conf directory.
In conf
The mirth.properties file looks interesting.
These are the database credentials.
Looking at the dbdrivers.xml file, it seems like the server is running MariaDB.
We connect to the database:
Enumerating the DB
Looking online for what kind of hash this is:
In Mirth version 4.4.0, the hash format changed to PBKDF2-HMAC-SHA256 with 600,000 iterations. That is very slow to crack unless we have the salt.
The 40-byte hash is a concatenation of an 8-byte salt and a 32-byte derived key.
First, we have to format the hash into a format hashcat can crack:
We crack it using hashcat:
The hash is cracked.
The credentials for Sedric are Sedric:snowflake1.
The user flag is in the home directory of sedric.
Shell as Root
Running linPEAS on the server shows an interesting file:
...[SNIP]...
╔══════════╣ Readable files belonging to root and readable by me but not world readable
-rw-r----- 1 root sedric 33 Feb 25 10:07 /home/sedric/user.txt
-rwxr----- 1 root sedric 2332 Sep 19 09:27 /usr/local/bin/notif.py
...[SNIP]...
notif.py
#!/usr/bin/env python3
"""
Notification server for added patients.
This server listens for XML messages containing patient information and writes formatted notifications to files in /var/secure-health/patients/.
It is designed to be run locally and only accepts requests with preformated data from MirthConnect running on the same machine.
It takes data interpreted from HL7 to XML by MirthConnect and formats it using a safe templating function.
"""
from flask import Flask, request, abort
import re
import uuid
from datetime import datetime
import xml.etree.ElementTree as ET, os
app = Flask(__name__)
USER_DIR = "/var/secure-health/patients/"; os.makedirs(USER_DIR, exist_ok=True)
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]"
# DOB format is DD/MM/YYYY
try:
year_of_birth = int(dob.split('/')[-1])
if year_of_birth < 1900 or year_of_birth > datetime.now().year:
return "[INVALID_DOB]"
except:
return "[INVALID_DOB]"
template = f"Patient {first} {last} ({gender}), {{datetime.now().year - year_of_birth}} years old, received from {sender} at {ts}"
try:
return eval(f"f'''{template}'''")
except Exception as e:
return f"[EVAL_ERROR] {e}"
@app.route("/addPatient", methods=["POST"])
def receive():
if request.remote_addr != "127.0.0.1":
abort(403)
try:
xml_text = request.data.decode()
xml_root = ET.fromstring(xml_text)
except ET.ParseError:
return "XML ERROR\n", 400
patient = xml_root if xml_root.tag=="patient" else xml_root.find("patient")
if patient is None:
return "No <patient> tag found\n", 400
id = uuid.uuid4().hex
data = {tag: (patient.findtext(tag) or "") for tag in ["firstname","lastname","sender_app","timestamp","birth_date","gender"]}
notification = template(data["firstname"],data["lastname"],data["sender_app"],data["timestamp"],data["birth_date"],data["gender"])
path = os.path.join(USER_DIR,f"{id}.txt")
with open(path,"w") as f:
f.write(notification+"\n")
return notification
if __name__=="__main__":
app.run("127.0.0.1",54321, threaded=True)
Looking at the source code, we find an SSTI/code injection vulnerability here.
template = f"Patient {first} {last} ({gender}), {{datetime.now().year - year_of_birth}} years old, ..."
return eval(f"f'''{template}'''")
It builds an f-string and then evals it. The {...} in the template gets executed. The regex allows {}=+ characters, so we can inject arbitrary Python inside {} via any of the fields.
The payload goes in gender or firstname, etc. For example, we inject into gender:
This service is running on 127.0.0.1:54321, so we need to port forward it to access it on our VM shell.
Running the malicious code, we get code execution as root.
What didn't work
Using the same code did not work for a reverse shell.
XML ERROR: The Bash reverse shell payload contained single quotes inside an XML field. The quote escaping ('"'"') used to handle single quotes in Bash broke the XML structure, making it invalid XML that the parser rejected before any code even ran.
INVALID_INPUT: The regex whitelist [a-zA-Z0-9._'\"(){}=+/] blocked the comma in b64decode(...),shell=True. Even though the command was base64 encoded, the Python function call syntax itself contained a comma which is not in the allowed character set, so the input was rejected before eval.
What worked
busybox nc: Regular netcat on Debian does not support the -e flag (execute), but busybox nc does, making it capable of spawning a shell directly on connection.
base64 encoding: By encoding the full command and decoding it inside Python with b64decode(...).decode(), the payload field contained only alphanumeric characters and +/= which are all permitted by the regex whitelist. No spaces, pipes, hyphens or commas ever appeared in the XML.
Using the malicious code to send the reverse shell:
Getting a shell as root:
os.system() with single argument: Unlike subprocess.Popen which requires commas for additional arguments like shell=True, os.system() takes a single string and passes it directly to the shell, so no commas were needed keeping it within the allowed character set.
Root shell: The Flask service was running as root, so code execution through the eval injection gave a root shell directly without any additional privilege escalation needed.

