Repository navigation
security: authorize Git HTTP by routed action, not client-supplied service - #8331
Merged
Merged
Conversation
unknwon
added a commit
that referenced
this pull request
Jun 7, 2026
(cherry picked from commit 7c9cf53)
unknwon
added a commit
that referenced
this pull request
Jun 7, 2026
golangci-lint flagged two issues: - internal/form/form.go used the deprecated reflect.Ptr alias in two spots. Replace with reflect.Pointer (the constant the deprecation notice points to) so govet stops reporting the inline hint. - internal/route/repo/http.go had a stray blank line between the new gitHTTPIsPull helper and HTTPContexter, leftover from the #8331 cherry-pick. Drop it to satisfy gofmt.
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
Gogs' Git smart-HTTP handler decided read vs write from the client-supplied
?service=query parameter, so aPOST /repo.git/git-receive-pack?service=git-upload-packwas authorized as a read while the route still executedgit-receive-pack. A user with read-only access could push.This branch derives the access mode from the routed action instead:
git-receive-pack(andinfo/refs?service=git-receive-pack) are the only operations that demand write access.service=is consulted only oninfo/refs, the one endpoint shared between fetch and push. Everywhere else the RPC path is authoritative.gitHTTPAction(c)call left over from the old check is removed.Security advisory: GHSA-wmfg-5p4h-5fw3
Checklist
Test plan
victimandattacker.victim, create a private repository and addattackeras a read-only collaborator.git pushand rewrites the request toPOST /victim/target.git/git-receive-pack?service=git-upload-pack.attackerwrites to the read-only repository.403 User permission denied, and the repository remains unchanged.