Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
CVE-2026-52811
Summary
`(*Repository).UploadRepoFiles` checks for symlinks only on the leaf of the upload target `osx.IsSymlink(targetPath)`. The siblings `UpdateRepoFile`, `DeleteRepoFile`, and `GetDiffPreview` use `hasSymlinkInPath`, which lstats every component -- `UploadRepoFiles` is the lone outlier. An attacker with repo-write access plus a multipart upload whose filename contains a literal backslash (preserved by `filepath.Base` on Linux, then converted to `/` by `pathx.Clean`) redirects the write through a previously-committed directory symlink. `iox.CopyFile` opens the destination with `os.Create` (no `O_NOFOLLOW`), so the kernel follows the parent symlink and writes attacker bytes anywhere the gogs UID can write -- `~git/.ssh/authorized_keys` - SSH foothold, or `<repo>.git/hooks/post-receive` - next-push RCE. Windows builds are unaffected: 'filepath.Base' treats '\' as a separator (strips the multi-segment trick) and git defaults 'core.symlinks=false' at checkout (committed mode-120000 entries become text files, not real symlinks). This issue affects Gogs versions through 0.14.2.
- LOW
- NETWORK
- NONE
- LOW
CWE-22 - Path Traversal
Path traversal (or directory traversal), is a vulnerability that allows malicious users to traverse the server's root directory, gaining access to arbitrary files and folders such as application code & data, back-end credentials, and sensitive operating system files. In the worst-case scenario, an attacker could potentially execute arbitrary files on the server, resulting in a denial of service attack. Such an exploit may severely impact the integrity, confidentiality, and availability of an application.
References
Advisory Timeline
- Published