{"id":2077,"date":"2026-07-29T10:05:10","date_gmt":"2026-07-29T10:05:10","guid":{"rendered":"https:\/\/thedigitalfortress.us\/?p=2077"},"modified":"2026-07-29T10:05:10","modified_gmt":"2026-07-29T10:05:10","slug":"new-gitea-rce-lets-repository-writers-plant-a-git-hook-to-run-shell-commands","status":"publish","type":"post","link":"https:\/\/thedigitalfortress.us\/?p=2077","title":{"rendered":"New Gitea RCE Lets Repository Writers Plant a Git Hook to Run Shell Commands"},"content":{"rendered":"<div>\n<p><span class=\"p-author\"><i class=\"icon-font icon-user\">\ue804<\/i><span class=\"author\">Swati Khandelwal<\/span><i class=\"icon-font icon-calendar\">\ue802<\/i><span class=\"author\">Jul 29, 2026<\/span><\/span><span class=\"p-tags\">Vulnerability \/ DevOps<\/span><\/p>\n<\/div>\n<div id=\"articlebody\">\n<div class=\"separator\" style=\"clear: both;\"><a href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjm9I3aoAsUS5yCtKTvSX6LYxjKfJu-RShA1QmcUiBLu760VFfeqd6D4NfH3ttKHoQkfWT57oL0_4KJBovY7nshgiGQ4R5wimWh-2k48f9qjdlJtjKqK0oM5vxquJFPuguLbBkbqzA7xc4NgjQaxkcU7tVSQ0a3GyXreEyvdvR4NmERWPbkiR6Um2thKfY\/s1700-e365\/Gitea-rce.jpg\" style=\"clear: left; display: block; float: left;  text-align: center;\"><\/a><\/div>\n<p>Gitea, the self-hosted Git platform, has patched a critical remote code execution vulnerability. A user with ordinary repository write access can turn attacker-controlled patch content into a live Git hook and run shell commands as the Gitea service account.<\/p>\n<p>Tracked as <code><b>CVE-2026-60004<\/b><\/code> (CVSS score: 9.8), the flaw affects Gitea versions 1.17 and later before 1.27.1 and is fixed in 1.27.1. The vulnerable API call requires authentication and repository write permission. But Gitea enables registration by default, so an outside visitor can create a normal account and repository on an unchanged installation, then exploit the bug without pre-existing credentials.<\/p>\n<p>Upgrading to 1.27.1 is the fix. Gitea said on July 27 that Gitea Cloud instances would be upgraded automatically. Gitea&#8217;s July 28 advisory does not say the flaw has been exploited in the wild, but it includes public proof-of-concept (PoC) code.<\/p>\n<p>Disabling open registration can remove the public account-creation path while the update is deployed, but it does not fix the flaw or protect against existing users with repository write access.<\/p>\n<div class=\"dog_two clear\">\n<div class=\"cf\"><a href=\"https:\/\/thehackernews.uk\/ai-vuln-protection-d\" rel=\"nofollow noopener sponsored\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"lazyload\" alt=\"Cybersecurity\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjQl2axNwsfhbXOFynrg_uAZsvHi3OvNGSA8KJO-BKR8Xm3x7yjKV3EvfY4v5mwXx6LF0uWFb9h9d9iAV_Pi-YYhqimX9wx4OaLdDJEdR215Xrxq_PAtXkaLfQso4pTSjbj6fvh_ZTliLpzWZSZfcoZgyXtKwhN-SSDDlmbtUqGLshc0KqYQGWYHMN52Sl1\/s728-e100\/zz-d.jpg\" width=\"729\" height=\"91\"\/><\/a><\/div>\n<\/div>\n<p>The flaw was reported by security researcher <a href=\"https:\/\/x.com\/NightRang3r\/status\/2082167303190241483\">Shai Rod, who goes by NightRang3r<\/a>. Gitea credits NightRang3r as the reporter in its advisory.<\/p>\n<p><a name=\"more\"\/><\/p>\n<p>Gitea&#8217;s <a href=\"https:\/\/github.com\/go-gitea\/gitea\/blob\/v1.27.0\/routers\/api\/v1\/api.go#L1407\">affected route<\/a> invokes <code>reqToken()<\/code>, which rejects requests without a signed-in user. The no-prior-credentials path comes from the project&#8217;s <a href=\"https:\/\/docs.gitea.com\/1.27\/administration\/config-cheat-sheet\">default configuration<\/a>, which leaves registration open, requires neither email nor manual approval, does not mark new users as restricted, and imposes no default repository-creation limit.<\/p>\n<p>The bug sits in the <code>POST \/api\/v1\/repos\/{owner}\/{repo}\/diffpatch<\/code> endpoint. According to Gitea&#8217;s <a href=\"https:\/\/github.com\/go-gitea\/gitea\/security\/advisories\/GHSA-rcr6-4jqh-j84m\">security advisory<\/a>, the endpoint applies a supplied patch inside a shared bare temporary clone. Vulnerable builds invoke <code>git apply<\/code> with <code>--index<\/code>, <code>--recount<\/code>, <code>--cached<\/code>, and <code>--binary<\/code>, adding the <code>-3<\/code> three-way fallback option when the server runs Git 2.32 or later.<\/p>\n<p>An attacker submits the same patch twice to create an add\/add collision. The three-way fallback then checks the indexed path out even though the operation uses <code>--cached<\/code>. Because the temporary clone is bare, its root is <code>$GIT_DIR<\/code>. An executable file placed at <code>hooks\/post-index-change<\/code> therefore lands in Git&#8217;s hook directory and becomes active. Git runs it while updating the index.<\/p>\n<div class=\"separator\" style=\"clear: both;\"><a href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEiSY38SkVmSwWfzVCew9Uxq3fAbRzE3Wg-a6ULmInmDuYqnP2vTKCWgChKSyFLtCvynW_8i19LHXUYPZN1SiKAu1QLF7vOq1MOjaa9BpW7dSTlZWyYAcji4eljuTMPA1gq5QBDGDTvbOi-lF7KKnl28HRkQoaqMqkMP3HHP3ar87Ydn5efdZZem8_PWISw\/s1700-e365\/rce-lfi.jpg\" style=\"clear: left; display: block; float: left;  text-align: center;\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEiSY38SkVmSwWfzVCew9Uxq3fAbRzE3Wg-a6ULmInmDuYqnP2vTKCWgChKSyFLtCvynW_8i19LHXUYPZN1SiKAu1QLF7vOq1MOjaa9BpW7dSTlZWyYAcji4eljuTMPA1gq5QBDGDTvbOi-lF7KKnl28HRkQoaqMqkMP3HHP3ar87Ydn5efdZZem8_PWISw\/s1700-e365\/rce-lfi.jpg\" alt=\"\" border=\"0\" data-original-height=\"934\" data-original-width=\"1722\"\/><\/a><\/div>\n<p>The PoC signs in with a normal account, creates an initialized private repository, sends the malicious patch twice, and retrieves the command output. It needs no outbound callback. The hook stores the output in Git objects, creates a branch containing the result, and lets the attacker fetch it over authenticated smart HTTP.<\/p>\n<p>As of July 29, 2026, none of the cited primary sources reports whether the flaw was exploited before or after version 1.27.1 became available.<\/p>\n<p>Successful exploitation gives the attacker the privileges of the Gitea operating-system account. Depending on how the instance is isolated, Gitea said that could expose application and environment secrets, mounted repositories, database credentials and contents, OAuth credentials, and reachable internal services.<\/p>\n<div class=\"dog_two clear\">\n<div class=\"cf\"><a href=\"https:\/\/thn.news\/sygnia-webinar\" rel=\"nofollow noopener sponsored\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"lazyload\" alt=\"Cybersecurity\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEh3-o9La7DYm6jz5qcavVBLvRXUoQLqwrMmrvB529PbUxdg7TJZS3BMjVi4D7vd6V9vlSf_OX48mmXQWPgah_SPITaGgg4AP9YxB2AH-63YeWU39N3DXadwc_2zjIpTwCt0iyTdPZIM-KzKhDf_JDPWDGu3IbYfi1ilQE8Ly29HiKYagSIur-il4k7MMNv8\/s728-e100\/sygnia-d-3.png\" width=\"729\" height=\"91\"\/><\/a><\/div>\n<\/div>\n<p>Exploitation still requires repository write access, Git 2.32 or later, an enabled <code>diffpatch<\/code> route, and a writable, executable temporary filesystem. Default registration lets an outsider obtain the required write access on an unchanged installation.<\/p>\n<p>The fix is easy to miss in the changelog. Gitea changed the temporary clone from bare to non-bare. The <a href=\"https:\/\/github.com\/go-gitea\/gitea\/commit\/470d34b1de87d901bd9135564d5ee18c0d339e82\">code comment<\/a> explicitly warns that Git commands using <code>--index<\/code> may operate on the working tree. The change was merged and backported on July 26, 2026.<\/p>\n<p>Version <a href=\"https:\/\/github.com\/go-gitea\/gitea\/releases\/tag\/v1.27.1\">1.27.1 shipped<\/a> on July 27, and the security advisory followed on July 28. The release notes listed the change under MISC as \u00abrefactor: git patch apply,\u00bb not under SECURITY.<\/p>\n<p>Rod had <a href=\"https:\/\/x.com\/NightRang3r\/status\/2081053859581960519\">previewed the RCE alongside a separate file-inclusion issue<\/a>, with a PoC retrieving <code>\/etc\/passwd<\/code> from a Gitea 1.27.0 host. That issue appears to correspond to a separate <a href=\"https:\/\/github.com\/go-gitea\/gitea\/commit\/3e6cb7c16b837e993f90dbe1ff06dd5726b74588\">change included in 1.27.1<\/a> that altered Gitea&#8217;s Org-mode renderer so <code>#+INCLUDE<\/code> paths are returned as plain text instead of being read from the server&#8217;s filesystem. Gitea has not published a separate advisory or CVE for the file-inclusion issue.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\ue804Swati Khandelwal\ue802Jul 29, 2026Vulnerability \/ DevOps Gitea, the self-hosted Git platform, has patched a critical remote code execution vulnerability. A user with ordinary repository write access can turn attacker-controlled patch&hellip;<\/p>\n","protected":false},"author":1,"featured_media":2078,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[195,1462,1808,2780,332,2051,316,1425,1774,303,2779],"class_list":["post-2077","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-commands","tag-git","tag-gitea","tag-hook","tag-lets","tag-plant","tag-rce","tag-repository","tag-run","tag-shell","tag-writers"],"_links":{"self":[{"href":"https:\/\/thedigitalfortress.us\/index.php?rest_route=\/wp\/v2\/posts\/2077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thedigitalfortress.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thedigitalfortress.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thedigitalfortress.us\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thedigitalfortress.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2077"}],"version-history":[{"count":0,"href":"https:\/\/thedigitalfortress.us\/index.php?rest_route=\/wp\/v2\/posts\/2077\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thedigitalfortress.us\/index.php?rest_route=\/wp\/v2\/media\/2078"}],"wp:attachment":[{"href":"https:\/\/thedigitalfortress.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thedigitalfortress.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thedigitalfortress.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}