
CVE-2026-52813 (Gogs Path Traversal → Git Hooks RCE) defensive writeup: root-cause & patch analysis, Sigma/SIEM detection rules, IOCs, non-intrusive version scanner. No weaponized PoC.
Security research / Blue team writeup. This repository does not contain weaponized PoC. Researchers needing reproduction should use the public PoC referenced in the official advisory.
| Item | Content |
|---|---|
| CVE | CVE-2026-52813 |
| Alias | GHSA-c39w-43gm-34h5 / GO-2026-5305 |
| Affected Versions | Gogs < 0.14.3 |
| Fixed Version | 0.14.3 — PR #8334 |
| CVSS 3.1 | 10.0 Critical AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H |
| CWE | CWE-23 Relative Path Traversal → RCE |
| Prerequisite | A regular registered account (when open registration is enabled = unauthenticated RCE) |
When creating an organization in Gogs, the Web form has AlphaDashDot character validation intercepting /, but the REST API POST /api/v1/user/orgs does not. An attacker submits an organization name containing ../ via the API, bypassing validation and directly reaching os.MkdirAll(repoutil.UserPath(org.Name), 0777) (internal/database/org.go:165), placing the repository directory at an arbitrary filesystem path. Combined with Gogs' web editor temporary working tree (local-r/<repo_id>/), a malicious hooks/update can be placed inside the local checkout of another repository, automatically executed by git → RCE as the git user.
| Gogs Version | Status |
|---|---|
< 0.14.3 | Affected, upgrade immediately |
>= 0.14.3 | Fixed |
Upgrading is the only complete fix:
# Docker
docker pull gogs/gogs:0.14.3
# Or from source
git checkout v0.14.3 && go build
Temporary mitigations (when upgrading is not possible):
app.ini → [service] DISABLE_REGISTRATION = true), downgrading the prerequisite from "unauthorized" to "requires existing account";POST /api/v1/user/orgs and POST /api/v1/org/*/repos request bodies where username / name fields contain .. or / (see detection/);/data/gogs/data/tmp/ (selinux/apparmor).Web form (internal/form/org.go, v0.14.2):
type CreateOrg struct {
OrgName string `binding:"Required;AlphaDashDot;MaxSize(35)"` // regex ^[a-zA-Z0-9._-]+$
}
API (internal/route/api/v1/org/org.go, v0.14.2):
// api.CreateOrgOption (go-gogs-client) binding tag:
type CreateOrgOption struct {
UserName string `json:"username" binding:"Required"` // ← no AlphaDashDot!
}
→ The username field in POST /api/v1/user/orgs can carry arbitrary characters directly to the DB layer.
internal/database/users.go:1532 isNameAllowed only intercepts reserved names/prefixes (e.g. admin, -bot), does not validate character set, so ../ passes.
internal/repoutil/repoutil.go (v0.14.2):
func UserPath(user string) string {
return filepath.Join(conf.Repository.Root, strings.ToLower(user)) // ← direct concatenation
}
internal/database/org.go:165:
os.MkdirAll(repoutil.UserPath(org.Name), os.ModePerm) // org.Name contains ../ → arbitrary path write
When Gogs processes Web/API file editing, it checks out the repository into /data/gogs/data/tmp/local-r/<repo_id>/. <repo_id> happens to be the database id of the repository. The attacker:
writer, resulting in id == n;username = "../../../../data/gogs/data/tmp/local-r/n/nested" → physical directory lands inside writer's working tree;rce-x under that organization → lands in local-r/n/nested/rce-x.git;writer, adds nested/rce-x.git/hooks/update as a normal file, commits and pushes (it lands inside writer's working tree);writer → Gogs runs git in local-r/n/ → git executes hooks/update → RCE.Key point: the malicious hook is introduced as normal repository content via a normal push, no need for
ENABLE_GIT_HOOKSconfiguration — this is what distinguishes it from the "traditional git hooks abuse" approach.
Detailed patch diff analysis in patch/ANALYSIS.md.
Complete rules in detection/:
../) and successful exploitation (filesystem landing)The two most critical ones:
POST /api/v1/user/orgs and POST /api/v1/org/*/repos JSON body where username/name fields contain .. or /./data/gogs/data/tmp/local-r/*/ (e.g., nested/, rce-*.git, hooks/update).< 0.14.3 via GET /api/v1/version, supports batch scanning, CSV output, suitable for asset inventory.This repository does not provide weaponized exploitation tools. For reproduction, use the public PoC referenced in the official advisory, and only in isolated self-hosted environments.
detection/ rules need validation on an affected Gogs instance, lab/docker-compose.yml provides an isolated Gogs 0.14.2 environment for blue teams to test detection rule hits. Do not expose to the public internet, local use only.
| Date | Event |
|---|---|
| 2026-06-08 | CVE reserved |
| 2026-06-24 | Public disclosure, Gogs 0.14.3 released |
| 2026-06-24 | Official advisory GHSA-c39w-43gm-34h5 published |
Some online sources describe this CVE as "Gogs gitrebase parameter injection remote code execution" — that is incorrect. This vulnerability has nothing to do with git rebase / gitrebase; the root cause is API path traversal. This document analyzes the real vulnerability.
MIT — see LICENSE.