A critical remote code execution issue exists in the `diffpatch` API endpoint. The flaw allows an attacker with repository write access to install a malicious Git hook, specifically `hooks/post-index-change`, which is then executed by the Gitea service account. This occurs because Gitea applies patches in a bare temporary clone using `git apply -3`. When the same crafted patch is submitted twice, an add/add collision triggers a three-way merge that writes the payload directly to the active hooks directory in the `$GIT DIR`.
On instances where open user registration is enabled, unauthenticated attackers can exploit this by registering an account and creating their own repository to gain the necessary write permissions.
This issue has been actively exploited in a multinational campaign by a threat actor known as Red Heron. The actor scanned over 1,800 instances globally, targeting sectors such as defense, energy, aerospace, and government in countries including Canada, Argentina, Taiwan, the United States, Sri Lanka, and Qatar. Post-exploitation activities included source-code theft, credential collection using bcrypt, and the deployment of the JITTERLY Linux implant and SIXZUT LD PRELOAD rootkit to maintain persistence and hide activity by filtering filesystem and network data.