The vulnerability is a Server-Side Request Forgery (SSRF) in the repository migration and mirroring functionality of Gogs. The root cause is that the application validates the user-provided remote URL at the beginning of the process, but the underlying git clone and git remote update commands were configured to follow HTTP redirects. An attacker could provide a seemingly benign public URL which, upon being accessed by the Gogs server, would redirect to a blocked internal IP address (e.g., 127.0.0.1). This would cause the git process to clone or sync from the internal repository, effectively bypassing the security controls designed to prevent access to local and private network resources.
The patch addresses this by introducing a new function, mirrorGitArgs, which returns the git command-line argument -c http.followRedirects=false. This argument is then consistently applied to all git commands that interact with remote repositories, specifically in the MigrateRepository and runSync functions. By disabling HTTP redirects at the git level, the application ensures that even if a redirect is encountered, it will not be followed, thus mitigating the SSRF vulnerability.