CVE-2026-25120
JSON

5.1medium

Gogs Allows Cross-Repository Comment Deletion via DeleteComment

Severity
5.1medium CVSS:4.0 by GitHub_M
Exploit likelihood
0.30% (higher than 24% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-jj5m-h57j-5gv7GO-2026-4501

Description

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.

Affected

Product or packageVersionsReported by
gogs gogs< 0.14.0, before 0.14.0CVE List, NVD
gogs.io/gogs (Go)before 0.14.0, all versionsGitHub Advisory Database, Go Vulnerability Database

All scores

GitHub_M5.1medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
NVD2.7low CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:N

Classification

CWE-639

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

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.

GitHub Advisory Database

IDOR: Cross-Repository Comment Deletion via DeleteComment

Summary

The 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.

Vulnerability Details

FieldValue
Affected Fileinternal/route/repo/issue.go
Affected FunctionDeleteComment (lines 955-968)
Secondary Fileinternal/database/comment.go
Secondary FunctionDeleteCommentByID (lines 505-520)

Root Cause

The vulnerability exists due to insufficient authorization validation in the comment deletion flow:

1. Missing Repository Ownership Check in DeleteComment

In internal/route/repo/issue.go, the function retrieves a comment by ID without verifying repository ownership:

func DeleteComment(c *context.Context) {
    comment, err := database.GetCommentByID(c.ParamsInt64(":id"))
    if err != nil {
        c.NotFoundOrError(err, "get comment by ID")
        return
    }

    // Only checks if user is comment poster OR admin of the CURRENT repo (from URL)
    if c.UserID() != comment.PosterID && !c.Repo.IsAdmin() {
        c.NotFound()
        return
    } else if comment.Type != database.CommentTypeComment {
        c.Status(http.StatusNoContent)
        return
    }

    // No verification that comment.IssueID belongs to c.Repo.Repository.ID!
    if err = database.DeleteCommentByID(c.User, comment.ID); err != nil {
        c.Error(err, "delete comment by ID")
        return
    }

    c.Status(http.StatusOK)
}
2. Database Layer Performs No Authorization

In internal/database/comment.go, the deletion function performs no repository validation:

func DeleteCommentByID(doer *User, id int64) error {
    comment, err := GetCommentByID(id)
    if err != nil {
        if IsErrCommentNotExist(err) {
            return nil
        }
        return err
    }

    // Directly deletes without checking repository ownership
    sess := x.NewSession()
    defer sess.Close()
    if err = sess.Begin(); err != nil {
        return err
    }

    if _, err = sess.ID(comment.ID).Delete(new(Comment)); err != nil {
        // ...
    }
    // ...
}

Proof of Concept

Prerequisites
  1. Two users: Alice (attacker) and Bob (victim)
  2. Alice is admin of alice/attacker-repo
  3. Bob has created an issue with a comment on bob/victim-repo
  4. Attacker needs to obtain the comment ID from victim's repository (e.g., ID: 42)
HTTP Request
POST /alice/attacker-repo/issues/comments/42/delete HTTP/1.1
Host: gogs.example.com
Cookie: i_like_gogs=<alice_session_token>

Go Vulnerability Database

Gogs Allows Cross-Repository Comment Deletion via DeleteComment in gogs.io/gogs.

NOTE: The source advisory for this report contains additional versions that could not be automatically mapped to standard Go module versions.

(If this is causing false-positive reports from vulnerability scanners, please suggest an edit to the report.)

The additional affected modules and versions are: gogs.io/gogs before v0.14.0.

NVD (es)

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.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-25120 changed 2026-02-19CVE Terms of Use
GitHub Advisory DatabaseGHSA-jj5m-h57j-5gv7 changed 2026-02-23CC-BY-4.0
Go Vulnerability DatabaseGO-2026-4501 changed 2026-02-23CC-BY-4.0
NVDCVE-2026-25120 changed 2026-06-17Public domain