
Week 11. PermX
TL;DR
This is an Ubuntu 22.04 machine running an e-learning web site made with of Chamillo LMS (Learning Management System). The version installed is Chamillo 1.11, which is vulnerable to unrestricted file upload (CVE-2023-4220) . Exploiting this vulnerability we get initial to access to the system, then move laterally to a low-priv user reusing database credentials found in a PHP configuration file. Regarding escalation, we abuse an overly permissive sudo script that allows the user to update file permissions with setfacl.
KEYWORDS
Chamilo 1.11, CVE-2023-4220, password hunting, sudo escalation, setfacl.
REFERENCES
https://www.cvedetails.com/cve/CVE-2023-4220/
https://github.com/B1TC0R3/CVE-2023-4220-PoC
ENUMERATION
Port scan.
> nmap $target -p- --min-rate=5000 -Pn --open --reason
Starting Nmap 7.93 ( https://nmap.org ) at 2024-10-10 11:34 EDT
Nmap scan report for 10.10.11.23
Host is up, received user-set (0.036s latency).
Not shown: 59940 closed tcp ports (conn-refused), 5593 filtered tcp ports (no-response)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT STATE SERVICE REASON
22/tcp open ssh syn-ack
80/tcp open http syn-ack
Nmap done: 1 IP address (1 host up) scanned in 12.90 secondsEnumerate the open ports.
Add to hosts file and enumerate with Firefox. An online e-learning site comes into view.

Fuzz for hidden subdomains.
Add the subdomain to hosts file and enumerate the subdomains with Firefox.

A Chamilo collaboration site comes into view. Fuzz again for hidden folders in the subdomain.
In the README.md file we find out the installed version is Chamilo 1.11.

A Google search provides details about an existing CVE and a GitHub exploit affecting this version.
https://www.cvedetails.com/cve/CVE-2023-4220/
https://github.com/B1TC0R3/CVE-2023-4220-PoC
USER
Download and run the exploit (exploit.py), it provides instant RCE. First we'll use it to discover the host is running Linux, then we verify nc is installed.
Everything is ready, so just start a listener and send a payload.
A reverse shell is received on port 1919.

It is a shell for user www-data so let's carry out a database password hunt in the /var/www/chamilo directory.

We have find a database password, let's check if it belongs to any of the host users.
For example, let's try if it works for user mtz

It seems that's the case and we can retrieve user flag.
ROOT
Start from the low-priv shell for user mtz and take the opportunity to enumerate the user and the system.
Check sudo configuration.
Inspect the script /opt/acl.sh
It seems the script modifies any file's permissions with setfacl binary. There are 2 conditions: the target must be a file and be inside mtz home directory.
Create a symbolic link to /etc/passwdin mtz home directory, then update its permissions so we can add new users.
All that's left is to add a new superuser and spawn a root shell.

You are root.
Last updated