/

CVE-2026-52805

Severity:

HIGH RISK

(8.7)

SSRF (CWE-918) in Gogs Repository Migration Logic

CVE-2026-52805

Deferred

Vulnerability type

Category:

Server-Side Request Forgery (SSRF)

CWE:

CWE-918

Impact:

Unauthorized access to internal Git repositories and data exfiltration

Severity:

HIGH RISK

(8.7)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A Server-Side Request Forgery issue in Gogs' repository migration feature allows an attacker to abuse HTTP redirects during git clone --mirror operations.

When an authenticated user supplies a migration URL that initially appears safe but later redirects to internal addresses, they can access and mirror internal Git repositories into attacker-controlled projects.

Affected context

This vulnerability occurs in Gogs instances that expose the repository migration functionality to authenticated users.

The risk is present when the application validates only the hostname of the initially submitted migration URL, while the underlying git clone --mirror command is allowed to follow HTTP redirects without additional checks.

Deployments with internal Git services or sensitive endpoints reachable from the Gogs server, but not from the public internet, are particularly exposed.

Exploit preconditions

  • Attack surface: Repository migration endpoint used to import external Git repositories.
  • Required access: Authenticated user account with permission to perform repository migrations.
  • Trigger point: Submission of a migration URL that resolves to a public endpoint initially, then returns an HTTP redirect to a blocked or internal address (e.g., 127.0.0.1 or internal Git service).
  • Why exploitation is possible: The application validates only the first URL hostname and does not re-validate or restrict subsequent redirect targets followed by git clone --mirror, allowing internal endpoints to be reached from the server side.

Why this happens

The core issue is incomplete validation of outbound requests initiated by server-side repository migration logic.

Gogs checks only the hostname of the user-supplied URL at submission time, treating it as safe if it appears public, but delegates the actual network access to git clone --mirror, which transparently follows HTTP redirects.

Because redirect destinations are not revalidated or constrained, an attacker can craft URLs that first point to a benign host and then redirect into internal IP ranges or services, matching CWE-918: Server-Side Request Forgery, where user input controls server-initiated network requests to unintended locations.

Potential impact

  • An attacker may clone and exfiltrate internal or otherwise non-public Git repositories accessible only from the Gogs server.
  • Internal application source code could be exposed, enabling further vulnerability discovery and targeted attacks.
  • Configuration files, secrets, or credentials stored in internal repositories could be leaked and reused for lateral movement.
  • The attacker could gain visibility into internal development workflows, branches, and commit history.

General mitigation guidance

Effective mitigation focuses on constraining server-initiated network requests and reducing trust in user-supplied URLs.

Common defensive patterns include:

  • Implementing strict allow/deny lists for outbound request destinations, specifically blocking private IP ranges, loopback addresses, and internal hostnames from migration logic.
  • Re-validating and enforcing hostname and network policies on every redirect followed by the migration process, rather than only the initial URL.
  • Isolating migration functionality in a network-restricted environment, such as a proxy or sandbox that can only reach approved external Git hosts.
  • Applying least-privilege networking at the infrastructure level so application components cannot access sensitive internal services by default.
  • Logging and monitoring outbound connections initiated by repository migrations to detect suspicious access patterns.

How teams detect issues like this

Detection typically involves reviewing both application behavior and outbound network flows:

  • Use static analysis or code review to identify server-side features where user-provided URLs are passed to tools or libraries that may follow redirects, and verify that all redirect targets are validated and constrained.
  • Look for patterns where external clone or fetch commands are constructed directly from user input without robust host/IP filtering.
  • Monitor application logs for repository migration operations targeting unusual domains or IP ranges, especially private address spaces or localhost.
  • Employ network monitoring and firewall rules that alert on or block unexpected HTTP/HTTPS traffic from the application server to internal services.
  • Incorporate automated security testing and policy enforcement in CI/CD pipelines to flag SSRF-prone URL handling and missing network egress restrictions.

Sources

SourceLink
github.comgithub.com/gogs/gogs/commit/b9a0093e9cd1b2b3c7f42f9feca396dc772c4f1b
github.comgithub.com/gogs/gogs/pull/8324
github.comgithub.com/gogs/gogs/releases/tag/v0.14.3
github.comgithub.com/gogs/gogs/security/advisories/GHSA-g2f5-gjr4-qjvm

Frequently asked

questions

It requires an authenticated Gogs account with access to repository migration functionality. While the attacker can be remote, they must successfully log in and trigger a migration using crafted URLs.

The attacker needs to be an authenticated user on the Gogs instance with permission to initiate repository migrations. No direct access to internal network resources is required; the application server performs the SSRF on their behalf.

The most robust fix is to strictly control where server-side HTTP requests can go: enforce deny lists for private and loopback IP ranges, re-validate every redirect target, and, where possible, route all migration traffic through a tightly controlled proxy that only allows known Git hosting providers.

Treat all user-controlled URLs as untrusted and design server-initiated requests with strong egress controls, comprehensive IP/hostname validation, and redirect handling that enforces the same policies at every step. Incorporate SSRF-focused secure coding guidelines, code review checks, and automated scanners to catch unsafe URL handling during development.

Find out what's already
exploitable in your codebase.