Skip to main content

Boteraser | Website and Server Security Solutions

🛡️ CVE-2026-25232 — gogs

🟠 CVSS 8.8 — High ⚠️ Exploit Public CWE-863 NVD
8.8
CVSS Score
0 Low4 Medium7 High9 Critical10

Description

Gogs has a Protected Branch Deletion Bypass in Web Interface

Summary

An access control bypass vulnerability in Gogs web interface allows any repository collaborator with Write permissions to delete protected branches (including the default branch) by sending a direct POST request, completely bypassing the branch protection mechanism. This vulnerability enables privilege escalation from Write to Admin level, allowing low-privilege users to perform dangerous operations that should be restricted to administrators only.

Although Git Hook layer correctly prevents protected branch deletion via SSH push, the web interface deletion operation does not trigger Git Hooks, resulting in complete bypass of protection mechanisms.

Details

Affected Component

  • File: internal/route/repo/branch.go
  • Function: DeleteBranchPost (lines 110-155)
  • Route Configuration: internal/cmd/web.go:589

```go

m.Post("/delete/*", reqSignIn, reqRepoWriter, repo.DeleteBranchPost)

```

Root Cause

The DeleteBranchPost function performs the following checks when deleting a branch:

1. ✅ User authentication (reqSignIn)

2. ✅ Write permission check (reqRepoWriter)

3. ✅ Branch existence verification

4. ✅ CommitID matching (optional parameter)

5. ❌ Missing protected branch check

6. ❌ Missing default branch check

While the UI layer (internal/route/repo/issue.go:646-658) correctly checks protected branch status and hides the delete button, attackers can directly construct POST requests to bypass UI restrictions.

Vulnerable Code

Vulnerable implementation (internal/route/repo/branch.go:110-155):

```110:155:internal/route/repo/branch.go

func DeleteBranchPost(c *context.Context) {

branchName := c.Params("*")

commitID := c.Query("commit")

defer func() {

redirectTo := c.Query("redirect_to")

if !tool.IsSameSiteURLPath(redirectTo) {

redirectTo = c.Repo.RepoLink

}

c.Redirect(redirectTo)

}()

if !c.Repo.GitRepo.HasBranch(branchName) {

return

}

if len(commitID) > 0 {

branchCommitID, err := c.Repo.GitRepo.BranchCommitID(branchName)

if err != nil {

log.Error("Failed to get commit ID of branch %q: %v", branchName, err)

return

}

if branchCommitID != commitID {

c.Flash.Error(c.Tr("repo.pulls.delete_branch_has_new_commits"))

return

}

}

// 🔴 Vulnerability: Missing protected branch check here

// Should add check like:

// protectBranch, err := database.GetProtectBranchOfRepoByName(c.Repo.Repository.ID, branchName)

// if protectBranch != nil && protectBranch.Protected { ... }

if err := c.Repo.GitRepo.DeleteBranch(branchName, git.DeleteBranchOptions{

Force: true,

}); err != nil {

log.Error("Failed to delete branch %q: %v", branchName, err)

return

}

if err := database.PrepareWebhooks(c.Repo.Repository, database.HookEventTypeDelete, &api.DeletePayload{

Ref: branchName,

RefType: "branch",

PusherType: api.PUSHER_TYPE_USER,

Repo: c.Repo.Repository.APIFormatLegacy(nil),

Sender: c.User.APIFormat(),

}); err != nil {

log.Error("Failed to prepare webhooks for %q: %v", database.HookEventTypeDelete, err)

return

}

}

```

Correct implementation in Git Hook (internal/cmd/hook.go:122-125):

```go

// check and deletion

if newCommitID == git.EmptyID {

fail(fmt.Sprintf("Branch '%s' is protected from deletion", branchName), "")

}

```

Correct UI layer check (internal/route/repo/issue.go:646-658):

```go

protectBranch, err := database.GetProtectBranchOfRepoByName(pull.BaseRepoID, pull.HeadBranch)

if err != nil {

if !database.IsErrBranchNotExist(err) {

c.Error(err, "get protect branch of repository by name")

return

}

} else {

branchProtected = protectBranch.Protected

}

c.Data["IsPullBranchDeletable"] = pull.BaseRepoID == pull.HeadRepoID &&

c.Repo.IsWriter() && c.Repo.GitRepo.HasBranch(pull.HeadBranch) &&

!branchProtected // UI layer has check, but backend doesn't

```

PoC

Prerequisites

1. Have Write permissions to the target repository (collaborator or team member)

2. Target repository has protected branches configured (e.g., main, master, develop)

3. Access to Gogs web interface

Send Malicious POST Request

```bash

# Directly send DELETE request bypassing UI protection

curl -X POST \

-b cookies.txt \

-H "Content-Type: application/x-www-form-urlencoded" \

-d "_csrf=YOUR_CSRF_TOKEN" \

"https://gogs.example.com/username/repo/branches/delete/main"

```

<img width="1218" height="518" alt="image" src="https://github.com/user-attachments/assets/745da7c3-6139-408c-9747-ccbe9ea8548f" />

Impact

  • Bypass branch protection mechanism: The core function of protected branches is to prevent deletion, and this vulnerability completely undermines this mechanism
  • Delete default branch: Can cause repository to become inaccessible (git clone/pull failures)
  • Bypass code review: After deleting protected branch, can push new branch bypassing Pull Request requirements
  • **Privilege escala

How this vulnerability can be exploited

This issue can be reached over the network, attack complexity is low, an attacker needs low-level privileges on the target. No user interaction is required. The scope is unchanged, so the impact stays within the vulnerable component. Rated impact: confidentiality high, integrity high, availability high.

CVSS metrics in full

The score comes from this vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

  • Attack vector: Network — reachable from anywhere that can route to the service.
  • Attack complexity: Low — the attack works reliably, with no preparation.
  • Privileges required: Low — an ordinary user account is enough.
  • User interaction: None — nobody has to be tricked into anything.
  • Scope: Unchanged — the damage stays inside the vulnerable component.
  • Confidentiality impact: High — total loss, or loss the attacker controls.
  • Integrity impact: High — total loss, or loss the attacker controls.
  • Availability impact: High — total loss, or loss the attacker controls.

Weakness class

CVE-2026-25232 is classified as CWE-863: Incorrect Authorization. An authorisation check runs but reaches the wrong conclusion, permitting actions it should refuse.

Affected software

CVE-2026-25232 is recorded against 2 packages.

  • gogs (fixed in 0.14.1)
  • gogs.io/gogs

Timeline and source

Published on 19 February 2026 and last revised on 17 June 2026. A public exploit is known to exist, which raises the urgency of patching considerably. A vendor advisory or fix has been published. Record sourced from NVD.

References

github.com
github.com
github.com
github.com

Other advisories for this package

gogs has other advisories on record. If you are patching this one, these are worth checking on the same host:

Same weakness in other software

These advisories are the same class of weakness (CWE-863: Incorrect Authorization) in other software:

Details

Severity HIGH
CVSS Score 8.8
CVSS Vector CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
CWE CWE-863
Public Exploit ⚠️ Yes
Source NVD
Published 2026-02-19
Updated 2026-08-20
Modified 2026-06-17

Affected Packages

Software From version Fixed in
gogs 0.14.1
gogs.io/gogs

Similar Threats

Exploit Protection

Are you running gogs?

CVE-2026-25232 carries CVSS 8.8 High rating and a public exploit already exists. BotEraser checks your installation against this and other known CVE records, and blocks IPs associated with exploit activity.

Check My Site For CVE-2026-25232 →

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.

Browse related advisories

All advisoriesCVECVE 2026