# Gitea RCE (CVE-2026-60004): Any Registered User Can Execute Shell Commands via Malicious Patch


## The Threat


A critical remote code execution vulnerability in Gitea allows any user with repository write access to plant a Git hook that runs arbitrary shell commands as the Gitea service account. The attack weaponizes the platform's patch-apply API endpoint — specifically POST /api/v1/repos/{owner}/{repo}/diffpatch — by exploiting how Gitea creates bare temporary clones when applying patches. In a bare repository, the working tree root is $GIT_DIR itself. An attacker who submits a crafted patch twice can trigger an add/add merge collision; the three-way fallback (available when the server runs Git 2.32 or later) checks out the conflicting path directly into that directory, placing an executable file at hooks/post-index-change — exactly where Git looks for hooks to run during index updates.


The second piece that makes this devastating in practice: Gitea ships with open registration enabled by default. New accounts require no email verification, no admin approval, and carry no restrictions on repository creation. That means an untrusted outsider can create a fresh account, spin up a private repository, and exploit this bug without any pre-existing foothold on the installation. The attack is entirely self-contained — the PoC doesn't even require an outbound callback channel. Command output is written into Git objects, pushed to a branch, and fetched back over authenticated smart HTTP.


What an attacker gains depends on how tightly the Gitea instance is isolated, but the service account typically has access to application secrets, OAuth credentials, mounted repositories, database connection strings, and anything else reachable on the internal network. This is not a privilege escalation within Gitea — it is host-level code execution as whatever OS account runs the service.


## Severity and Impact


| Field | Detail |

|---|---|

| CVE | CVE-2026-60004 |

| CVSS Score | 9.8 (Critical) |

| Attack Vector | Network |

| Attack Complexity | Low |

| Privileges Required | Low (trivially obtained via open registration on default installs) |

| User Interaction | None |

| CWE | CWE-77 — Improper Neutralization of Special Elements Used in a Command |

| Exploit Available | Yes — public PoC included in Gitea's own advisory |

| Exploitation in the Wild | Not confirmed as of July 29, 2026 |


## Affected Products


Gitea (self-hosted)

  • All versions ≥ 1.17 and < 1.27.1
  • Requires Git 2.32 or later on the server for the three-way fallback path
  • Requires the diffpatch route to be enabled (on by default)
  • Requires a writable, executable temporary filesystem

  • Not affected:

  • Gitea Cloud — auto-upgraded by Gitea on July 27, 2026
  • Installations running Git < 2.32 are not vulnerable via the three-way path (but should still upgrade)
  • Gitea < 1.17 (endpoint did not exist)

  • ## Mitigations


    Primary fix — upgrade immediately:

  • Update to Gitea 1.27.1, released July 27, 2026
  • The underlying change converts the temporary clone from bare to non-bare, preventing $GIT_DIR from coinciding with the checkout path

  • Workarounds while patching:

  • Disable open registration (service.DISABLE_REGISTRATION = true in app.ini) — this eliminates the unauthenticated account-creation path, but does not protect against existing users who already have repository write access
  • Enable email verification and manual approval for new accounts if registration must stay open
  • Mark new users as restricted so they cannot create repositories without admin approval
  • Review repository write-access grants — the exploit requires write permission, so minimizing that surface limits exposure
  • Network segment Gitea — restrict what the Gitea service account can reach internally, particularly databases and secrets stores, to limit blast radius on successful exploitation

  • Verification:

    Confirm your version with gitea --version or via the admin panel. If you are running a containerized deployment, pull the updated image and verify the base version before assuming you are patched.


    ## References


  • [Gitea Security Advisory — July 28, 2026](https://blog.gitea.com/security-release-v1.27.1/)
  • [Gitea 1.27.1 Release](https://github.com/go-gitea/gitea/releases/tag/v1.27.1)
  • [NVD Entry for CVE-2026-60004](https://nvd.nist.gov/vuln/detail/CVE-2026-60004)
  • [Researcher disclosure by Shai Rod (NightRang3r)](https://github.com/NightRang3r)

  • ---


    ## HackWire Analysis


    Two things about this vulnerability deserve more attention than the patch headline suggests.


    First, the changelog burial. Gitea merged the fix on July 26 and shipped 1.27.1 on July 27 — a competent turnaround. But the release notes categorized the critical change as a MISC refactor: *"refactor: git patch apply."* No SECURITY tag. No CVE callout. No hint that this was anything other than housekeeping. For any operator running automated dependency checks keyed to SECURITY-labeled changes, this was effectively invisible. That is not a minor process failure — it is exactly the kind of omission that allows critical patches to sit undeployed for weeks on self-managed infrastructure while teams assume nothing important shipped.


    Second, the default-configuration attack surface is the real story. Gitea's open-registration default is a reasonable choice for internal developer tooling behind a VPN, where friction on new contributors matters. It becomes a liability the moment an instance is internet-exposed — and self-hosted Git servers routinely end up public-facing. The combination of open registration, unrestricted repository creation, no email verification, and no restricted-user default means a fresh Gitea install is functionally open to unauthenticated exploitation by anyone who can reach port 3000. Operators who hardened registration are naturally protected from the public-account path. Everyone else should assume their exposure window started the moment 1.17 shipped in their environment.


    For defenders: treat this like a CI/CD supply chain risk, not just a web application vuln. Gitea is often positioned upstream of build pipelines, secret vaults, and artifact registries. Compromise of the Gitea service account can cascade into those systems. Inventory your Gitea instances, check what the service account can reach, and patch before the PoC gets scripted into mass-scanning toolkits — which, with a public exploit and a 9.8 score, is a question of days, not weeks.


    — HackWire Editorial


    ---


    ## Related Coverage


  • Read more in our [Vulnerabilities](https://www.hackwire.news/category/vulnerabilities) coverage
  • Cross-reference with [Breaches](https://www.hackwire.news/category/breaches) and [Malware](https://www.hackwire.news/category/malware)
  • Stay current via the [HackWire homepage](https://www.hackwire.news/)