{"id":"CVE-2026-25120","aliases":["CVE-2026-25120","GHSA-jj5m-h57j-5gv7","GO-2026-4501"],"related":[],"kind":"vulnerability","state":"published","title":"Gogs Allows Cross-Repository Comment Deletion via DeleteComment","summary":"Gogs is an open source self-hosted Git service. In versions 0.13.4 and below, the DeleteComment API does not verify that the comment belongs to the repository specified in the URL. This allows a repository administrator to delete comments from any other repository by supplying arbitrary comment IDs, bypassing authorization controls. The DeleteComment function retrieves a comment by ID without verifying repository ownership and the Database function DeleteCommentByID performs no repository validation. This issue has been fixed in version 0.14.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Gogs is an open source self-hosted Git service. In versions 0.13.4 and below, the DeleteComment API does not verify that the comment belongs to the repository specified in the URL. This allows a repository administrator to delete comments from any other repository by supplying arbitrary comment IDs, bypassing authorization controls. The DeleteComment function retrieves a comment by ID without verifying repository ownership and the Database function DeleteCommentByID performs no repository validation. This issue has been fixed in version 0.14.0.","source":"cvelist"},{"lang":"en","text":"# IDOR: Cross-Repository Comment Deletion via DeleteComment\n\n## Summary\n\nThe `POST /:owner/:repo/issues/comments/:id/delete` endpoint does not verify that the comment belongs to the repository specified in the URL. This allows a repository administrator to delete comments from any other repository by supplying arbitrary comment IDs, bypassing authorization controls.\n\n## Vulnerability Details\n\n| Field | Value |\n|-------|-------|\n| Affected File | `internal/route/repo/issue.go` |\n| Affected Function | `DeleteComment` (lines 955-968) |\n| Secondary File | `internal/database/comment.go` |\n| Secondary Function | `DeleteCommentByID` (lines 505-520) |\n\n## Root Cause\n\nThe vulnerability exists due to insufficient authorization validation in the comment deletion flow:\n\n### 1. Missing Repository Ownership Check in DeleteComment\n\nIn `internal/route/repo/issue.go`, the function retrieves a comment by ID without verifying repository ownership:\n\n```go\nfunc DeleteComment(c *context.Context) {\n    comment, err := database.GetCommentByID(c.ParamsInt64(\":id\"))\n    if err != nil {\n        c.NotFoundOrError(err, \"get comment by ID\")\n        return\n    }\n\n    // Only checks if user is comment poster OR admin of the CURRENT repo (from URL)\n    if c.UserID() != comment.PosterID && !c.Repo.IsAdmin() {\n        c.NotFound()\n        return\n    } else if comment.Type != database.CommentTypeComment {\n        c.Status(http.StatusNoContent)\n        return\n    }\n\n    // No verification that comment.IssueID belongs to c.Repo.Repository.ID!\n    if err = database.DeleteCommentByID(c.User, comment.ID); err != nil {\n        c.Error(err, \"delete comment by ID\")\n        return\n    }\n\n    c.Status(http.StatusOK)\n}\n```\n\n### 2. Database Layer Performs No Authorization\n\nIn `internal/database/comment.go`, the deletion function performs no repository validation:\n\n```go\nfunc DeleteCommentByID(doer *User, id int64) error {\n    comment, err := GetCommentByID(id)\n    if err != nil {\n        if IsErrCommentNotExist(err) {\n            return nil\n        }\n        return err\n    }\n\n    // Directly deletes without checking repository ownership\n    sess := x.NewSession()\n    defer sess.Close()\n    if err = sess.Begin(); err != nil {\n        return err\n    }\n\n    if _, err = sess.ID(comment.ID).Delete(new(Comment)); err != nil {\n        // ...\n    }\n    // ...\n}\n```\n\n## Proof of Concept\n\n### Prerequisites\n\n1. Two users: **Alice** (attacker) and **Bob** (victim)\n2. Alice is admin of `alice/attacker-repo`\n3. Bob has created an issue with a comment on `bob/victim-repo`\n4. Attacker needs to obtain the comment ID from victim's repository (e.g., ID: 42)\n\n### HTTP Request\n\n```http\nPOST /alice/attacker-repo/issues/comments/42/delete HTTP/1.1\nHost: gogs.example.com\nCookie: i_like_gogs=<alice_session_token>\n\n```","format":"markdown","source":"ghsa"},{"lang":"en","text":"Gogs Allows Cross-Repository Comment Deletion via DeleteComment 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.0.","format":"markdown","source":"go"},{"lang":"es","text":"Gogs es un servicio Git autoalojado de código abierto. En las versiones 0.13.4 e inferiores, la API DeleteComment no verifica que el comentario pertenece al repositorio especificado en la URL. Esto permite a un administrador de repositorio eliminar comentarios de cualquier otro repositorio proporcionando IDs de comentario arbitrarios, eludiendo los controles de autorización. La función DeleteComment recupera un comentario por ID sin verificar la propiedad del repositorio y la función de base de datos DeleteCommentByID no realiza ninguna validación de repositorio. Este problema ha sido solucionado en la versión 0.14.0.","source":"nvd"}],"published":"2026-02-17T18:40:44.000Z","modified":"2026-06-17T10:24:08.540Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","score":5.1,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","score":5.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:N","score":2.7,"rating":"LOW"}],"cwes":["CWE-639"],"affected":[{"ranges":[{"version":"< 0.14.0","status":"affected"}],"vendor":"gogs","product":"gogs","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.14.0"}],"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.0"}],"vendor":"gogs","product":"gogs","cpe":"cpe:2.3:a:gogs:gogs:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/gogs/gogs/security/advisories/GHSA-jj5m-h57j-5gv7","tags":["advisory","exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/gogs/gogs/commit/1b226ca48dc8b3e95cc1c41229d72819c960a1b7","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-25120","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:58.960Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-25120","url":"https://www.cve.org/CVERecord?id=CVE-2026-25120","licence":"CVE Terms of Use","modified":"2026-02-19T17:45:04.770Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-jj5m-h57j-5gv7","url":"https://github.com/advisories/GHSA-jj5m-h57j-5gv7","licence":"CC-BY-4.0","modified":"2026-02-23T19:41:02.818Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-4501","url":"https://pkg.go.dev/vuln/GO-2026-4501","licence":"CC-BY-4.0","modified":"2026-02-23T19:41:02.818Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-25120","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-25120","licence":"Public domain","modified":"2026-06-17T10:24:08.540Z"}],"updatedAt":"2026-11-25T22:59:14.069Z","epss":{"score":0.00301,"percentile":0.24579,"date":"2026-12-01T12:00:22.000Z"}}