CVE-2026-60004: Gitea Pre-Auth Remote Code Execution Analysis
Halil Deniz provides a detailed technical analysis of CVE-2026-60004 (CVSS 9.8), a critical remote code execution vulnerability in Gitea versions 1.17.0 through 1.27.0. The flaw exists in the repository patch parsing mechanism exposed via the REST API endpoint POST /api/v1/repos/{owner}/{repo}/diffpatch. Gitea initializes temporary repositories as bare repositories (git init --bare), where $GIT_DIR coincides with the working root. When git apply encounters merge collisions and triggers a three-way merge fallback (Git >= 2.32), it writes intermediate file blobs to disk using paths relative to the repository root. An attacker can craft patch paths to write a malicious script into hooks/post-index-change, which Git automatically executes on the next index-modifying operation. Default open registration (DISABLE_REGISTRATION=false) makes this a practical pre-auth RCE vector. Fixed in Gitea 1.27.1. The analysis includes code snippets, the full exploit chain, and remediation guidance.
Research notes
- Root causeGitea initializes temporary patch-application repositories as bare repositories (git init --bare), where $GIT_DIR coincides with the working root. When git apply triggers a three-way merge fallback on patch conflicts, it writes intermediate file blobs to disk using paths relative to the repository root, allowing an attacker to inject a malicious script into hooks/post-index-change.
- Exploit chainThe attack chain: (1) register an account via default open registration, (2) create a repository to gain write access, (3) send a crafted diff patch to POST /api/v1/repos/{owner}/{repo}/diffpatch that triggers a three-way merge fallback, (4) the fallback writes a malicious script to hooks/post-index-change in the bare temporary repository, (5) the next Git index operation automatically executes the hook, achieving RCE.
- Technical detailThe vulnerability is a practical pre-auth RCE because default Gitea installations leave public account creation open (DISABLE_REGISTRATION=false), allowing an unauthenticated attacker to register, create a repository, and exploit the patch-handling flaw without any administrator approval.