The vulnerability lies in the insufficient handling of symbolic links (symlinks) when updating repository files through the Gogs API. An attacker could create a repository containing a symlink that points to a sensitive file on the server, such as the .git/config file of another repository. By using the API to modify the content of this symlink, the attacker could overwrite the target file, leading to remote code execution (RCE). The sshCommand directive in a .git/config file can be used to execute arbitrary commands on the server during Git operations.
The patch for this vulnerability, found in commit c3eca1fca3a4750e55dfa6d9935564a897232858, introduces a new function hasSymlinkInPath that recursively checks for symlinks in a given path. This check is then applied in the UpdateRepoFile, GetDiffPreview, and DeleteRepoFile functions within internal/db/repo_editor.go to reject any operation on a path that contains a symlink. This prevents the path traversal vulnerability and stops the attacker from modifying files outside the intended repository directory.