Repository navigation
security: close SSRF in repository migration and recurring mirror sync - #8324
Merged
Merged
Conversation
Pin git's followRedirects to false when cloning the migration source and its wiki, and when probing the wiki URL. The clone address is validated against the local-network blocklist up front, but git was free to follow a 302 to an internal endpoint, so a public-looking URL could still pull contents from a host the validator would have rejected.
Apply the same redirect-disable to git remote update on both the repo and wiki sync. Also re-check the mirror's hostname against the local network blocklist before each sync, so a DNS flip after the mirror was created cannot turn a previously-validated source into an internal one.
unknwon
force-pushed
the
GHSA-g2f5-gjr4-qjvm
branch
from
June 6, 2026 01:52
1771888 to
508672b
Compare
git was being asked to fetch over the network with no terminal attached, and on the failure path it tried to prompt for credentials. The server process then hung on a prompt that no one was answering. Set GIT_TERMINAL_PROMPT=0 and clear the askpass so any auth failure surfaces immediately as an error.
unknwon
added a commit
that referenced
this pull request
Jun 7, 2026
#8324 imports gogs.io/gogs/internal/netx, which is the renamed netutil on main. The rename is not part of the 0.14.3 backport, so use the original netutil package on release/0.14.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related SSRFs in the migration / mirror path. Both reduce to the same defense: the up-front clone address validation is the only place Gogs checks where it's about to talk to, and git was free to talk to a different place later.
ParseRemoteAddrvalidates the submitted URL against the local-network blocklist, butgit clone --mirrorfollowed HTTP redirects with no revalidation. A public-looking source could302to an internal endpoint and the contents would land in the new repository.git remote update, plus no re-validation of the stored URL's hostname at sync time. An attacker who set up a mirror with a benign URL could later flip DNS or start serving redirects to an internal target and the next sync would pull from it.Ref: GHSA-g2f5-gjr4-qjvm
What changed
-c http.followRedirects=falseto every remote-touching git call in the migration and mirror paths: source clone, wiki clone, wiki URL probe, periodicgit remote update(repo + wiki).netx.IsBlockedLocalHostnamebefore each sync, so a DNS flip after creation cannot turn a previously-public source into an internal one.git.Clonewrapper hardcodescloneas the first arg, so adding the git-level-cflag required dropping that wrapper for directprocess.ExecTimeoutcalls, matching the pattern already used elsewhere in the package.Test plan
moon run gogs:lintgo test ./internal/database/...http://127.0.0.1:<port>/..., confirm migration fails instead of importing the internal repo.127.0.0.1, confirm the next sync aborts with a notice instead of pulling.