{"id":"CVE-2026-25232","aliases":["CVE-2026-25232","GHSA-2c6v-8r3v-gh6p","GO-2026-4498"],"related":[],"kind":"vulnerability","state":"published","title":"Gogs has a Protected Branch Deletion Bypass in Web Interface","summary":"Gogs is an open source self-hosted Git service. Versions 0.13.4 and below have an access control bypass vulnerability which 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 in the DeleteBranchPost function eenables 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. In oder to exploit this vulnerability, attackers must have write permissions to the target repository, protected branches configured to the target repository and access to the Gogs web interface. This issue has been fixed in version 0.14.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Gogs is an open source self-hosted Git service. Versions 0.13.4 and below have an access control bypass vulnerability which 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 in the DeleteBranchPost function eenables 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. In oder to exploit this vulnerability, attackers must have write permissions to the target repository, protected branches configured to the target repository and access to the Gogs web interface. This issue has been fixed in version 0.14.1.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nAn 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.\n\nAlthough 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.\n\n## Details\n\n### Affected Component\n\n- **File**: `internal/route/repo/branch.go`\n- **Function**: `DeleteBranchPost` (lines 110-155)\n- **Route Configuration**: `internal/cmd/web.go:589`\n  ```go\n  m.Post(\"/delete/*\", reqSignIn, reqRepoWriter, repo.DeleteBranchPost)\n  ```\n\n### Root Cause\n\nThe `DeleteBranchPost` function performs the following checks when deleting a branch:\n1. ✅ User authentication (`reqSignIn`)\n2. ✅ Write permission check (`reqRepoWriter`)\n3. ✅ Branch existence verification\n4. ✅ CommitID matching (optional parameter)\n5. ❌ **Missing protected branch check**\n6. ❌ **Missing default branch check**\n\nWhile 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.\n\n### Vulnerable Code\n\n**Vulnerable implementation** (`internal/route/repo/branch.go:110-155`):\n\n```110:155:internal/route/repo/branch.go\nfunc DeleteBranchPost(c *context.Context) {\n\tbranchName := c.Params(\"*\")\n\tcommitID := c.Query(\"commit\")\n\n\tdefer func() {\n\t\tredirectTo := c.Query(\"redirect_to\")\n\t\tif !tool.IsSameSiteURLPath(redirectTo) {\n\t\t\tredirectTo = c.Repo.RepoLink\n\t\t}\n\t\tc.Redirect(redirectTo)\n\t}()\n\n\tif !c.Repo.GitRepo.HasBranch(branchName) {\n\t\treturn\n\t}\n\tif len(commitID) > 0 {\n\t\tbranchCommitID, err := c.Repo.GitRepo.BranchCommitID(branchName)\n\t\tif err != nil {\n\t\t\tlog.Error(\"Failed to get commit ID of branch %q: %v\", branchName, err)\n\t\t\treturn\n\t\t}\n\n\t\tif branchCommitID != commitID {\n\t\t\tc.Flash.Error(c.Tr(\"repo.pulls.delete_branch_has_new_commits\"))\n\t\t\treturn\n\t\t}\n\t}\n\n\t// 🔴 Vulnerability: Missing protected branch check here\n\t// Should add check like:\n\t// protectBranch, err := database.GetProtectBranchOfRepoByName(c.Repo.Repository.ID, branchName)\n\t// if protectBranch != nil && protectBranch.Protected { ... }\n\n\tif err := c.Repo.GitRepo.DeleteBranch(branchName, git.DeleteBranchOptions{\n\t\tForce: true,\n\t}); err != nil {\n\t\tlog.Error(\"Failed to delete branch %q: %v\", branchName, err)\n\t\treturn\n\t}\n\n\tif err := database.PrepareWebhooks(c.Repo.Repository, database.HookEventTypeDelete, &api.DeletePayload{\n\t\tRef:        branchName,\n\t\tRefType:    \"branch\",\n\t\tPusherType: api.PUSHER_TYPE_USER,\n\t\tRepo:       c.Repo.Repository.APIFormatLegacy(nil),\n\t\tSender:     c.User.APIFormat(),\n\t}); err != nil {\n\t\tlog.Error(\"Failed to prepare webhooks for %q: %v\", database.HookEventTypeDelete, err)\n\t\treturn\n\t}\n}\n```\n\n**Correct implementation in Git Hook** (`internal/cmd/hook.go:122-125`):\n\n```go\n// check and deletion\nif newCommitID == git.EmptyID {\n    fail(fmt.Sprintf(\"Branch '%s' is protected from deletion\", branchName), \"\")\n}\n```\n\n**Correct UI layer check** (`internal/route/repo/issue.go:646-658`):\n\n```go\nprotectBranch, err := database.GetProtectBranchOfRepoByName(pull.BaseRepoID, pull.HeadBranch)\nif err != nil {\n\tif !database.IsErrBranchNotExist(err) {\n\t\tc.Error(err, \"get protect branch of repository by name\")\n\t\treturn\n\t}\n} else {\n\tbranchProtected = protectBranch.Protected\n}\n\nc.Data[\"IsPullBranchDeletable\"] = pull.BaseRepoID == pull.HeadRepoID &&\n\tc.Repo.IsWriter() && c.Repo.GitRepo.HasBranch(pull.HeadBranch) &&\n\t!branchProtected  // UI layer has check, but backend doesn't\n```\n## PoC\n\n### Prerequisites\n\n1. Have Write permissions to the target repository (collaborator or team member)\n2. Target repository has protected branches configured (e.g., main, master, develop)\n3. Access to Gogs web interface\n\n#### Send Malicious POST Request\n```bash\n# Directly send DELETE request bypassing UI protection\ncurl -X POST \\\n  -b cookies.txt \\\n  -H \"Content-Type: application/x-www-form-urlencoded\" \\\n  -d \"_csrf=YOUR_CSRF_TOKEN\" \\\n  \"https://gogs.example.com/username/repo/branches/delete/main\"\n```\n<img width=\"1218\" height=\"518\" alt=\"image\" src=\"https://github.com/user-attachments/assets/745da7c3-6139-408c-9747-ccbe9ea8548f\" />\n\n## Impact\n- **Bypass branch protection mechanism**: The core function of protected branches is to prevent deletion, and this vulnerability completely undermines this mechanism\n- **Delete default branch**: Can cause repository to become inaccessible (git clone/pull failures)\n- **Bypass code review**: After deleting protected branch, can push new branch bypassing Pull Request requirements\n- **Privilege escalation**: Writer permission users can perform operations that should only be allowed for Admins","format":"markdown","source":"ghsa"},{"lang":"en","text":"Gogs has a Protected Branch Deletion Bypass in Web Interface in gogs.io/gogs.\n\nNOTE: The source advisory for this report contains additional versions that could not be automatically mapped to standard Go module versions.\n\n(If this is causing false-positive reports from vulnerability scanners, please suggest an edit to the report.)\n\nThe additional affected modules and versions are: gogs.io/gogs before v0.14.1.","format":"markdown","source":"go"},{"lang":"es","text":"Gogs es un servicio Git de código abierto autoalojado. Las versiones 0.13.4 e inferiores tienen una vulnerabilidad de omisión de control de acceso que permite a cualquier colaborador del repositorio con permisos de escritura eliminar ramas protegidas (incluida la rama predeterminada) enviando una solicitud POST directa, omitiendo completamente el mecanismo de protección de ramas. Esta vulnerabilidad en la función DeleteBranchPost permite la escalada de privilegios de nivel de escritura a nivel de administrador, permitiendo a usuarios con pocos privilegios realizar operaciones peligrosas que deberían estar restringidas solo a administradores. Aunque la capa de Git Hook previene correctamente la eliminación de ramas protegidas a través de push SSH, la operación de eliminación de la interfaz web no activa los Git Hooks, lo que resulta en una omisión completa de los mecanismos de protección. Para explotar esta vulnerabilidad, los atacantes deben tener permisos de escritura en el repositorio objetivo, ramas protegidas configuradas en el repositorio objetivo y acceso a la interfaz web de Gogs. Este problema ha sido solucionado en la versión 0.14.1.","source":"nvd"}],"published":"2026-02-17T18:43:00.000Z","modified":"2026-06-17T10:24:20.827Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","score":7.1,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","score":7.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"}],"cwes":["CWE-863"],"affected":[{"ranges":[{"version":"< 0.14.1","status":"affected"}],"vendor":"gogs","product":"gogs","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.14.1"}],"ecosystem":"Go","package":"gogs.io/gogs","purl":"pkg:golang/gogs.io/gogs","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"gogs.io/gogs","purl":"pkg:golang/gogs.io/gogs","source":"go"},{"ranges":[{"status":"affected","fixed":"0.14.1"}],"vendor":"gogs","product":"gogs","cpe":"cpe:2.3:a:gogs:gogs:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/gogs/gogs/security/advisories/GHSA-2c6v-8r3v-gh6p","tags":["advisory","exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/gogs/gogs/pull/8124","tags":["issue-tracking","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/gogs/gogs/commit/7b7e38c88007a7c482dbf31efff896185fd9b79c","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/gogs/gogs/releases/tag/v0.14.1","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-25232","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/gogs/gogs","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-02-19T17:04:55.043Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-25232","url":"https://www.cve.org/CVERecord?id=CVE-2026-25232","licence":"CVE Terms of Use","modified":"2026-02-19T17:44:52.867Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-2c6v-8r3v-gh6p","url":"https://github.com/advisories/GHSA-2c6v-8r3v-gh6p","licence":"CC-BY-4.0","modified":"2026-02-23T19:41:08.669Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-4498","url":"https://pkg.go.dev/vuln/GO-2026-4498","licence":"CC-BY-4.0","modified":"2026-02-23T19:41:08.669Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-25232","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-25232","licence":"Public domain","modified":"2026-06-17T10:24:20.827Z"}],"updatedAt":"2026-11-25T22:59:14.072Z","epss":{"score":0.00474,"percentile":0.42623,"date":"2026-12-02T12:00:21.000Z"}}