CVE-2026–52813: Remote Code Execution via Organization-Name Pat
Gogs did not validate the organization name when creating an organization, so a name containing path-traversal sequences was used directly to build a filesystem path. An ordinary registered user could therefore write files outside the repository root, overwrite a Git hook in another repository's temporary working copy, and get commands executed on the server.
Published on medium.com
Gogs is an open-source, self-hosted Git service written in Go. CVE-2026–52813 stems from missing validation on the organization name at creation time, and it escalates into something far more serious: an authenticated, ordinary user can write files to an arbitrary path on the server’s filesystem, and combine that with…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The organisation name, fully controlled by the user, was passed into a path-building function that only normalises '..' segments rather than rejecting them, so the resulting directory could escape the repository root.
Impact
An authenticated ordinary user could execute arbitrary commands on the server under the git account, with no admin privileges needed.
What the attacker needed
A free user account; organisation creation enabled (default)
The fix
It was fixed in 0.14.3 by adding an allow-list and length limit on the organisation name at the API layer and by sanitising user and repository names when building paths.
How it was found
- Create an ordinary repository you own and note its internal repository ID.
- Create an organisation whose name is a path-traversal string pointing into that repository's temporary local working copy.
- Create a repository under that organisation, which lands inside the other repository's working copy.
- Clone your own repository, add a malicious hook script at the traversed path, and push it as a normal commit.
- Trigger the repository again, for example through an API call, so the hook script runs.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When you create an organisation, Gogs uses the name you type as a folder name on the server. The code never checked for '..' sequences, which mean 'go up one folder', so a crafted name could point the folder somewhere else entirely. The attacker then used that misplaced folder to plant a script that the server runs automatically on the next push, giving them command execution.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.