Facebook Google Plus Twitter LinkedIn YouTube RSS Menu Search Resource - BlogResource - WebinarResource - ReportResource - Eventicons_066 icons_067icons_068icons_069icons_070

Gogs Cross-Repository Comment Deletion via DeleteComment

Medium

Synopsis

Tenable Research has identified and responsibly disclosed an Insecure Direct Object References (IDOR) vulnerability to Gogs. 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.

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 {
       // ...
   }
   // ...
}

Solution

Upgrade to Gogs version 0.14.1 or later.

Disclosure Timeline

Jan 29, 2026 : Initial contact - Report submitted via GitHub
Jan 29, 2026 : Vendor Acknowledgement
Jan 30, 2026 : Vulnerability fixed on `main`
Feb 01, 2026 : 0.14.1 released

All information within TRA advisories is provided “as is”, without warranty of any kind, including the implied warranties of merchantability and fitness for a particular purpose, and with no guarantee of completeness, accuracy, or timeliness. Individuals and organizations are responsible for assessing the impact of any actual or potential security vulnerability.

Tenable takes product security very seriously. If you believe you have found a vulnerability in one of our products, we ask that you please work with us to quickly resolve it in order to protect customers. Tenable believes in responding quickly to such reports, maintaining communication with researchers, and providing a solution in short order.

For more details on submitting vulnerability information, please see our Vulnerability Reporting Guidelines page.

If you have questions or corrections about this advisory, please email [email protected]