Repository navigation
repository: validate remote address on mirror address update - #8225
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR closes a security gap where updating a mirror’s remote address (SaveAddress) bypassed the clone-address validation that is enforced during mirror creation, enabling SSRF and local file/path abuse.
Changes:
- Apply
ParseRemoteAddrvalidation when updating a mirror address in repo settings. - Refactor clone address parsing from a
MigrateRepomethod to a sharedform.ParseRemoteAddr(options)helper and update both web + API migration paths to use it. - Add a changelog entry documenting the security fix.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/route/repo/setting.go | Validates mirror address updates using the same remote address rules as mirror creation. |
| internal/route/repo/repo.go | Switches migration to use the new shared form.ParseRemoteAddr(options) helper. |
| internal/route/api/v1/repo_repo.go | Switches API migration to use the same shared remote address parsing/validation. |
| internal/form/repo.go | Introduces ParseRemoteAddrOptions and a package-level ParseRemoteAddr function to unify validation logic. |
| CHANGELOG.md | Documents the security fix (SSRF via mirror address update validation bypass). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: E99p1ant <[email protected]>
Signed-off-by: E99p1ant <[email protected]>
Signed-off-by: E99p1ant <[email protected]>
unknwon
force-pushed
the
wh/fix-mirror-repo-check
branch
from
June 5, 2026 12:19
b215ba6 to
740d52f
Compare
unknwon
approved these changes
Jun 5, 2026
unknwon
added a commit
that referenced
this pull request
Jun 7, 2026
Signed-off-by: E99p1ant <[email protected]> Co-authored-by: Joe Chen <[email protected]> (cherry picked from commit 11e19f2)
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.
Describe the pull request
Mirror address update (
SaveAddress) bypasses all validation enforced during mirror creation (ParseRemoteAddr), including protocol whitelist (http://,https://,git://only), local network address blocking (netx.IsBlockedLocalHostname), and CRLF injection checks forgit://URLs.A mirror repository admin can exploit this by first creating a mirror with a valid URL, then changing the address to
file:///path/to/other-repo.gitto read contents of other local repositories on the server, or to internal network addresses for SSRF.This patch applies equivalent validation in the update path to match the creation path.
Ref: GHSA-wv27-2vqp-j7g5
Checklist
Test plan
file:///path/to/other-repo.git, verify it is rejected.http://127.0.0.1:3000, verify it is rejected.https://remote, verify it works and sync succeeds.