top of page
perceptive_background_267k.jpg

New Gitea RCE Lets Repository Writers Plant a Git Hook to Run Shell Commands

Published:

29 July 2026 at 09:47:19

Alert date:

29 July 2026 at 12:01:29

Source:

thehackernews.com

Click to open the original link from this advisory

Web Technologies, Zero-Day Vulnerabilities, Supply Chain & Dependencies

Gitea, a self-hosted Git platform, has disclosed a critical remote code execution vulnerability tracked as CVE-2026-60004 with a CVSS score of 9.8. The flaw allows any user with ordinary repository write access to plant attacker-controlled content into a Git hook, enabling execution of arbitrary shell commands under the Gitea service account. The vulnerability affects Gitea versions 1.17 and later up to (but not including) 1.27.1. A patch has been released in version 1.27.1. The high CVSS score and low privilege requirement make this a significant threat for organizations running self-hosted Gitea instances. Administrators are strongly advised to upgrade to version 1.27.1 immediately to mitigate the risk of exploitation.

Technical details

CVE-2026-60004 is a critical RCE vulnerability (CVSS 9.8) in Gitea versions 1.17 through 1.27.0. The flaw resides in the POST /api/v1/repos/{owner}/{repo}/diffpatch API endpoint. The endpoint applies a user-supplied patch inside a shared bare temporary clone using 'git apply' with --index, --recount, --cached, and --binary flags. On servers running Git 2.32 or later, the -3 three-way fallback option is also added. An attacker submits the same patch twice to create an add/add merge collision. The three-way fallback then checks out the indexed path to the filesystem even though --cached is specified. Because the temporary clone is bare, its root is $GIT_DIR. An executable file placed at hooks/post-index-change lands in Git's hook directory and becomes active, executing shell commands as the Gitea service account when Git updates the index. The PoC requires no outbound callback — it stores command output in Git objects, creates a branch with the result, and allows retrieval over authenticated smart HTTP. Exploitation requires: repository write access (obtainable via free registration on default installs), Git 2.32+, an enabled diffpatch route, and a writable/executable temporary filesystem. The fix changes the temporary clone from bare to non-bare, preventing $GIT_DIR from being the working root. A separate file-inclusion vulnerability was also previewed by the same researcher, involving Gitea's Org-mode renderer allowing #+INCLUDE directives to read server filesystem files (e.g., /etc/passwd); fixed in 1.27.1 by returning #+INCLUDE paths as plain text instead of resolving them.

Mitigation steps:

1. Upgrade Gitea to version 1.27.1 immediately — this is the only complete fix. Gitea Cloud instances were upgraded automatically on July 27, 2026. 2. As a temporary mitigation (not a fix), disable open user registration to prevent unauthenticated outsiders from creating accounts and exploiting the vulnerability. Note: this does not protect against existing users who already have repository write access. 3. Audit existing users with repository write access on your Gitea instances for suspicious activity. 4. Ensure Git version on the server is noted — instances running Git 2.32 or later are most vulnerable due to the -3 three-way fallback being enabled. 5. Monitor for unusual branch creation or unexpected Git hook files (hooks/post-index-change) in repository directories. 6. Review Gitea service account privileges and apply principle of least privilege to limit blast radius of exploitation. 7. Check for exposure of application secrets, database credentials, OAuth tokens, and internal services accessible by the Gitea OS account.

Affected products:

Gitea 1.17.x through 1.27.0 (all versions >= 1.17 and < 1.27.1)

Related links:

Related CVE's:

Related threat actors:

IOC's:

POST /api/v1/repos/{owner}/{repo}/diffpatch - malicious API endpoint abuse, hooks/post-index-change file created in a bare Git clone's $GIT_DIR, Duplicate patch submissions to the diffpatch API endpoint, Unexpected branch creation containing encoded command output in Git objects

This article was created with the assistance of AI technology by Perceptive.

© 2025 by Perceptive Security. All rights reserved.

email: info@perceptivesecurity.com

Disclaimer: Deze website toont informatie afkomstig van externe bronnen. Perceptive aanvaardt geen verantwoordelijkheid voor de inhoud, juistheid of volledigheid van deze informatie.

bottom of page