Skip to main content

Gogs CVE-2026-52804

| EUVDEUVD-2026-39072 MEDIUM
Off-by-one Error (CWE-193)
2026-06-23 https://github.com/gogs/gogs GHSA-4565-r4x7-hg8j
5.5
CVSS 4.0 · Vendor: https://github.com/gogs/gogs
Share

Severity by source

Vendor (https://github.com/gogs/gogs) PRIMARY
5.5 MEDIUM
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/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
vuln.today AI
8.8 HIGH

Network-exploitable via HTTP POST with PR:L because an existing admin collaborator role is required; high C/I/A because owner access enables full repository deletion and data destruction.

3.1 AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
4.0 AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
SUSE
MEDIUM
qualitative

Primary rating from Vendor (https://github.com/gogs/gogs).

CVSS VectorVendor: https://github.com/gogs/gogs

Attack Vector
Network
Attack Complexity
Low
Privileges Required
High
User Interaction
None
Scope
X

Lifecycle Timeline

3
CVSS changed
Jun 24, 2026 - 21:22 NVD
5.5 (MEDIUM)
Source Code Evidence Fetched
Jun 23, 2026 - 17:31 vuln.today
Analysis Generated
Jun 23, 2026 - 17:31 vuln.today

DescriptionCVE.org

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
  1. 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 {

AnalysisAI

Privilege escalation in Gogs versions prior to 0.14.3 allows repository admin collaborators to elevate their own access to owner-level by exploiting an off-by-one boundary check in the ChangeCollaborationAccessMode function. The web route accepts a raw integer mode query parameter, and the faulty guard mode > AccessModeOwner evaluates to false when mode equals 4, letting an admin (mode=3) POST mode=4 to silently receive full owner privileges - including the ability to delete the repository, transfer ownership, and erase wiki data. No public exploit identified at time of analysis, though the advisory includes complete reproduction steps that function as a de facto proof of concept.

Technical ContextAI

Gogs is a self-hosted Git service written in Go (CPE: pkg:go/gogs.io/gogs). The root cause is CWE-193 (Off-by-One Error) in internal/database/repo_collaboration.go. The access mode enumeration is an integer sequence: AccessModeNone=0, AccessModeRead=1, AccessModeWrite=2, AccessModeAdmin=3, AccessModeOwner=4. The validation guard mode > AccessModeOwner was intended to reject the owner value (4) but uses strict greater-than instead of greater-than-or-equal, so the check 4 > 4 evaluates to false and the value passes. The web route handler in internal/route/repo/setting.go deserializes the mode directly from the URL query string as a raw integer with no further sanitization, making the attack a single crafted POST. The API route is unaffected because it routes through ParseAccessMode(), which maps string labels to only Read, Write, or Admin - never Owner. The fix in v0.14.3 (PR #8227, commit 1fdc9cc) corrects the bound to mode > AccessModeAdmin and adds an actor-bound parameter so no actor can grant a level exceeding their own.

RemediationAI

Upgrade Gogs to version 0.14.3 or later, which resolves the issue via commit 1fdc9cc28e159135cfa4d6b11ecd5daa0f8ce22b and PR #8227 (https://github.com/gogs/gogs/pull/8227). The patch corrects the validation bound from AccessModeOwner to AccessModeAdmin and introduces actor-bound enforcement so no collaborator can grant a privilege level exceeding their own. If immediate upgrade is not possible, administrators should audit the collaboration and access database tables for any rows where mode=4 is set for non-owner user accounts, which would indicate prior exploitation; any such rows should be corrected manually. As a compensating control, restrict or remove admin-level collaborator grants to only the most trusted users, since exploitation requires holding that role. Blocking the web route /{owner}/{repo}/settings/collaboration/access_mode at the network perimeter or reverse proxy is a high-friction but effective mitigation with the trade-off of disabling the collaboration management UI entirely. The API endpoint requires no mitigation.

Vendor StatusVendor

SUSE

Severity: Moderate
Product Status
SUSE Linux Enterprise Server 16.1 Affected
SUSE Linux Enterprise Server for SAP applications 16.1 Affected
SUSE Linux Enterprise Module for Package Hub 15 SP5 Affected
SUSE Linux Enterprise Module for Package Hub 15 SP6 Affected
openSUSE Leap 15.5 Affected

Share

CVE-2026-52804 vulnerability details – vuln.today

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy