CVE-2026-52804: Gogs.io/gogs Gogs Vulnerable To Privilege Escalation Vulnerability

MODERATE
Advisory Identifier: GHSA-4565-r4x7-hg8j
CWE-193
Published
Advisory Summary

CVE-2026-52804 is a MODERATE gogs vulnerable to privilege escalation vulnerability (CWE-193: Off-by-one Error) affecting Gogs.io/gogs libraries in the Go ecosystem. The issue involves gogs vulnerable to privilege escalation via collaboration access mode validation. Remediation is available by upgrading affected packages to version 0.14.3.

CVE-2026-52804 at a Glance

CVE Identifier CVE-2026-52804
GHSA Identifier GHSA-4565-r4x7-hg8j
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-193: Off-by-one Error
Affected Product Gogs.io/gogs
Package Ecosystem Go
Published Date
Last Updated

How to Fix CVE-2026-52804

To remediate this vulnerability, upgrade all affected Gogs.io/gogs dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

gogs.io/gogs fixed: 0.14.3
Upgrade gogs.io/gogs to 0.14.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for gogs.io/gogs

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-52804, inspect your project dependencies for Gogs.io/gogs:

inspect dependencies for gogs.io/gogs

Analyze the terminal output to locate any version of Gogs.io/gogs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.14.3), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-193: Off-by-one Error, where a product calculates or uses an incorrect maximum or minimum value that is 1 more, or 1 less, than the correct value. In Gogs.io/gogs, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary A repository admin collaborator can escalate their privileges to owner-level access by exploiting an off-by-one error in the `ChangeCollaborationAccessMode` function. ## Vulnerable Code 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. ## Impact A repository admin collaborator (AccessModeAdmin = 3) can escalate to owner-level access (AccessModeOwner = 4), gaining the ability to: - **Delete the repository** - **Transfer repository ownership** to another user - **Erase wiki data** - Perform all other owner-only operations The `access` table is also updated (line 181), so the escalated permissions persist across sessions. ## Contrast 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. ## Steps to Reproduce 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 ## Suggested Fix 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 { ```

CVE-2026-52804 Affected Gogs.io/gogs Versions

1 component(s)
Fixed Versions:
0.14.3
Product / Package Ecosystem Affected Versions Fixed Version
gogs.io/gogs
Go
< 0.14.3
0.14.3

References

Frequently Asked Questions

What is CVE-2026-52804?
CVE-2026-52804 is a security vulnerability in Gogs.io/gogs involving Gogs Vulnerable to Privilege Escalation via Collaboration Access Mode Validation under CWE-193: Off-by-one Error.
Which Gogs.io/gogs versions are affected?
Affected versions include releases prior to 0.14.3 across affected packages: gogs.io/gogs.
What version fixes CVE-2026-52804?
Upgrading to 0.14.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gogs.io/gogs affected?
Yes, gogs.io/gogs is affected in releases prior to 0.14.3. Upgrade your dependency to 0.14.3 or later.
What CWE is associated with CVE-2026-52804?
CVE-2026-52804 is classified under 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.).
How can I check Go dependencies for CVE-2026-52804?
Run the dependency tree command: 'inspect dependencies for gogs.io/gogs'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-4565-r4x7-hg8j",
  "modified" : "2026-07-21T13:17:09Z",
  "published" : "2026-06-23T16:52:30Z",
  "aliases" : [ "CVE-2026-52804" ],
  "summary" : "Gogs Vulnerable to Privilege Escalation via Collaboration Access Mode Validation",
  "details" : "## Summary\n\nA repository admin collaborator can escalate their privileges to owner-level access by exploiting an off-by-one error in the `ChangeCollaborationAccessMode` function.\n\n## Vulnerable Code\n\nIn `internal/database/repo_collaboration.go`, line 129:\n\n```go\nfunc (r *Repository) ChangeCollaborationAccessMode(userID int64, mode AccessMode) error {\n    // Discard invalid input\n    if mode <= AccessModeNone || mode > AccessModeOwner {\n        return nil\n    }\n```\n\n`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`.\n\nThe web route at `internal/route/repo/setting.go:413-416` takes the mode as a raw integer from query parameters:\n\n```go\nfunc ChangeCollaborationAccessMode(c *context.Context) {\n    if err := c.Repo.Repository.ChangeCollaborationAccessMode(\n        c.QueryInt64(\"uid\"),\n        database.AccessMode(c.QueryInt(\"mode\"))); err != nil {\n```\n\nThis allows an admin collaborator to POST `mode=4` and escalate to owner.\n\n## Impact\n\nA repository admin collaborator (AccessModeAdmin = 3) can escalate to owner-level access (AccessModeOwner = 4), gaining the ability to:\n- **Delete the repository**\n- **Transfer repository ownership** to another user\n- **Erase wiki data**\n- Perform all other owner-only operations\n\nThe `access` table is also updated (line 181), so the escalated permissions persist across sessions.\n\n## Contrast\n\nThe 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.\n\n## Steps to Reproduce\n\n1. User A creates a private repository\n2. User A adds User B as a collaborator with **Admin** access (mode=3)\n3. User B logs in and navigates to the repository settings collaboration page\n4. User B sends a POST request:\n   ```\n   POST /{owner}/{repo}/settings/collaboration/access_mode?uid={B_uid}&mode=4\n   ```\n5. User B now has **Owner** access - the \"Danger Zone\" section appears with \"Delete This Repository\" and \"Transfer Ownership\" buttons\n\n## Suggested Fix\n\nChange the validation in `internal/database/repo_collaboration.go` line 129 from:\n```go\nif mode <= AccessModeNone || mode > AccessModeOwner {\n```\nto:\n```go\nif mode <= AccessModeNone || mode >= AccessModeOwner {\n```",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "gogs.io/gogs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.14.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/security/advisories/GHSA-4565-r4x7-hg8j"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-52804"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/pull/8227"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/commit/1fdc9cc28e159135cfa4d6b11ecd5daa0f8ce22b"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gogs/gogs"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gogs/gogs/releases/tag/v0.14.3"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-193" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-23T16:52:30Z",
    "nvd_published_at" : "2026-06-24T21:16:56Z"
  }
}