Gogs Vulnerable to Privilege Escalation via Collaboration Access Mode Validation
A repository admin collaborator can escalate their privileges to owner-level access by exploiting an off-by-one error in the ChangeCollaborationAccessMode function.
In internal/database/repo_collaboration.go, line 129:
```go
func (r *Repository) ChangeCollaborationAccessMode(userID int64, mode AccessMode) error {
// Discard invalid input
if mode <= AccessModeNone || mode > AccessModeOwner {
return nil
}
```
AccessModeOwner has value 4. The check mode > AccessModeOwner evaluates to 4 > 4 = false, allowing AccessModeOwner to pass through. The correct check should be mode >= AccessModeOwner.
The web route at internal/route/repo/setting.go:413-416 takes the mode as a raw integer from query parameters:
```go
func ChangeCollaborationAccessMode(c *context.Context) {
if err := c.Repo.Repository.ChangeCollaborationAccessMode(
c.QueryInt64("uid"),
database.AccessMode(c.QueryInt("mode"))); err != nil {
```
This allows an admin collaborator to POST mode=4 and escalate to owner.
A repository admin collaborator (AccessModeAdmin = 3) can escalate to owner-level access (AccessModeOwner = 4), gaining the ability to:
The access table is also updated (line 181), so the escalated permissions persist across sessions.
The API route at internal/route/api/v1/repo_collaborators.go:46 uses ParseAccessMode() which only returns Read, Write, or Admin - never Owner. The API endpoint is not affected.
1. User A creates a private repository
2. User A adds User B as a collaborator with Admin access (mode=3)
3. User B logs in and navigates to the repository settings collaboration page
4. User B sends a POST request:
```
POST /{owner}/{repo}/settings/collaboration/access_mode?uid={B_uid}&mode=4
```
5. User B now has Owner access - the "Danger Zone" section appears with "Delete This Repository" and "Transfer Ownership" buttons
Change the validation in internal/database/repo_collaboration.go line 129 from:
```go
if mode <= AccessModeNone || mode > AccessModeOwner {
```
to:
```go
if mode <= AccessModeNone || mode >= AccessModeOwner {
```
This issue can be reached over the network, attack complexity is low, an attacker needs administrative privileges on the target. No user interaction is required. Rated impact: confidentiality none, integrity high, availability high.
The score comes from this vector: CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N/E:P
CVE-2026-52804 is classified as CWE-193: Off-by-one Error. A product calculates or uses an incorrect maximum or minimum value that is 1 more, or 1 less, than the correct value.
CVE-2026-52804 is recorded against 2 packages.
Published on 25 June 2026 and last revised on 21 July 2026. No public exploit is currently recorded for this entry. Record sourced from NVD.
github.com (Advisory)
github.com (Web)
github.com (Web)
github.com (Web)
gogs.io/gogs has other advisories on record. If you are patching this one, these are worth checking on the same host:
These advisories are the same class of weakness (CWE-193: Off-by-one Error) in other software:
Details
CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N/E:P
Affected Packages
| Software | From version | Fixed in |
|---|---|---|
| gogs.io/gogs | — | — |
| unknown | — | — |
References
Similar Threats
Free Vulnerability Check
BotEraser helps you identify potentially vulnerable plugins and themes by checking your installation against CVE-2026-52804 and other known CVE records.
Scan My Site Free →No credit card required · Results in minutes
ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.
Stay up to date with the latest from Boteraser.
We use cookies to improve your experience on our site. By using our site, you consent to cookies.
Manage your cookie preferences below:
Essential cookies enable basic functions and are necessary for the proper function of the website.
CloudFlare provides web performance and security solutions, enhancing site speed and protecting against threats.
Service URL: developers.cloudflare.com (opens in a new window)
These cookies are needed for adding comments on this website.
These cookies are used for managing login functionality on this website.
Statistics cookies collect information anonymously. This information helps us understand how visitors use our website.
Google Analytics is a powerful tool that tracks and analyzes website traffic for informed marketing decisions.
Service URL: policies.google.com (opens in a new window)
You can find more information in our Cookie Policy and Privacy Policy.