/

CVE-2026-25232

Severity:

HIGH RISK

(8.8)

Access Control Bypass in Gogs Protected Branch Deletion

CVE-2026-25232

Analyzed

Vulnerability type

Category:

Access Control Bypass

CWE:

CWE-863

Impact:

Privilege Escalation and Integrity Compromise

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Gogs versions 0.13.4 and earlier contain an access control bypass that lets users with Write permissions delete protected branches, including the default branch, via a crafted POST request to the web interface.

Because the web-based branch deletion path does not enforce branch protection rules or trigger Git hooks, collaborators can effectively escalate their privileges from Write to Admin for destructive repository operations.

Affected context

This vulnerability affects Gogs instances where:

  • Protected branches (including the default branch) are configured for repositories
  • Users with Write permissions are present as collaborators
  • The Gogs web interface is exposed and used for repository management operations

The problem occurs specifically in the HTTP branch deletion flow, where the DeleteBranchPost handler does not fully enforce the same protection and hook logic that applies to operations performed via Git over SSH.

Exploit preconditions

  • Attack surface: Gogs web application HTTP endpoint handling branch deletion (DeleteBranchPost).
  • Required access: Valid authenticated user account with at least Write permissions on the target repository.
  • Configuration state: Protected branches configured on the repository, including any branch intended to be non-deletable (e.g., default branch).
  • Trigger point: Direct POST request to the branch deletion endpoint for a protected branch.
  • Why exploitation is possible: The web-based deletion flow bypasses branch protection checks and does not invoke Git hooks, so authorization logic that would normally block deletion is never executed for this code path.

Why this happens

The root cause is an inconsistent authorization model between different code paths that perform the same sensitive action.

In the DeleteBranchPost function, the application checks that the user can write to the repository, but it fails to apply branch protection rules that are enforced elsewhere (such as via Git hooks on SSH pushes).

This mismatch maps to CWE-863: Incorrect Authorization, where access control decisions are incomplete or applied to the wrong scope, letting users perform actions that should require a higher privilege level (Admin).

Conceptually, the bug is an authorization gap: a sensitive operation (protected branch deletion) is reachable through an alternative interface that does not enforce the intended policy.

Potential impact

  • Deletion of protected branches, including the default branch of critical repositories
  • Effective privilege escalation from Write to Admin-level destructive capabilities within a repository
  • Disruption of development workflows by removing active or release branches
  • Loss of important code history if backups or mirroring are not in place
  • Facilitation of malicious changes to repository state, such as removing review-enforced branches to weaken governance

General mitigation guidance

Mitigation typically focuses on enforcing consistent authorization for all paths that modify repository state and treating protected operations as privileged actions.

Helpful defensive patterns include:

  • Centralizing authorization checks for branch operations so all interfaces (web, API, SSH) share the same policy logic.
  • Treating branch protection as a hard policy layer that is evaluated for every branch mutation, regardless of protocol or UI flow.
  • Restricting the ability to delete branches, especially default or protected branches, to a clearly defined higher-privilege role and avoiding reliance solely on per-repository write permissions.
  • Designing web handlers so that any action equivalent to a Git operation reuses the same permission and hook pipelines as Git itself.
  • Implementing defense-in-depth by requiring confirmation steps or additional authorization (e.g., admin-only toggles) for destructive actions on protected resources.

How teams detect issues like this

Detection can focus on both behavioral and code-centric indicators:

  • Static analysis and code review:
  • Look for controller or handler functions that perform sensitive operations (like branch deletion, force pushes, configuration changes) but only check generic repository write access instead of explicit branch protection rules.
  • Identify duplicated authorization logic across interfaces; verify that all code paths use shared, centralized policy routines.
  • Flag endpoints that bypass or fail to invoke hook and validation pipelines associated with Git operations.
  • Policy and configuration checks:
  • Enforce policies that map protected branch operations to stricter roles and monitor code changes that relax those rules.
  • Use automated checks in CI to ensure new endpoints that manipulate branches call the same protection/authorization functions as existing, vetted paths.
  • Runtime monitoring:
  • Log all branch deletion events with actor identity and branch name; alert when protected branches are deleted by non-admin users.
  • Periodically audit repository events for anomalies, especially deletions or force updates involving designated protected branches.

Sources

SourceLink
github.comgithub.com/gogs/gogs/commit/7b7e38c88007a7c482dbf31efff896185fd9b79c
github.comgithub.com/gogs/gogs/pull/8124
github.comgithub.com/gogs/gogs/releases/tag/v0.14.1
github.comgithub.com/gogs/gogs/security/advisories/GHSA-2c6v-8r3v-gh6p

Frequently asked

questions

Yes, it can be exploited remotely through the Gogs web interface, provided the attacker has network access to the instance and valid credentials with Write permissions on the target repository.

The attacker must be an authenticated collaborator or user with Write access on the specific repository that has protected branches configured. Anonymous users or users without repository access cannot directly exploit this issue.

The safest pattern is to centralize branch protection and authorization checks and ensure that all branch modification or deletion operations—regardless of whether they originate from SSH, HTTP, or an API—invoke the same protection logic and, where applicable, Git hooks. Sensitive actions on protected branches should require explicit higher-privilege roles.

Design the authorization layer so that:

  • Policy is defined once and applied consistently across all interfaces.
  • Sensitive operations (like deleting protected branches) are guarded by explicit, role-based checks, not just generic write permissions.
  • Security reviews and automated tests cover alternate execution paths (web UI, APIs, background jobs) to detect any bypass of protection mechanisms.
Find out what's already
exploitable in your codebase.