GITEA.DEV · CVE-2026-126338 · Package
FIX → 28.4.0
Gitea's code-comment reply path accepts a review ID from another repository and copies that review's stored diff hunk into the attacker's comment. A signed-in regular user can read up to four diff lines from pull requests in private repositories they cannot access.
first public Nov 15, 2026 · 2 sources
Check it with your coding agent
It reads this page and tells you if your code or app is affected.
Any self-hosted Gitea instance where regular users can open pull requests and comment on code. Exposure needs a signed-in account with comment access on at least one pull request, a known or guessed review ID, file path and line; private repositories on the same instance are the targets. Instances that disable pull request commenting for regular users or run only trusted users are lower risk.
Not affected if fixed-version, no-untrusted-users, pull-requests-disabled
Who cares gitea, pull-requests, self-hosted
gitea --version or the release shown in the admin dashboard; versions >= 1.14.0 and <= 28.3.0 are affected.28.4.0 or later.services/pull/review.go for an unbound FindComments call with ReviewID but no .A missing authorization check in Gitea's code-comment reply path lets any signed-in regular user read diff hunks from pull requests in private repositories they have no access to. By submitting a reply whose reply form field names a review from another repository, the attacker gets that review's stored diff hunk and commit SHA copied into a comment on a pull request they can comment on. The hunk is up to [ui] CODE_COMMENT_LINES diff lines, 4 by default, ending at the commented line. On default settings, the attached reproducer recovers a PASSWORD=s3cr3t-of-the-victim line from victim/private, while the same attacker gets 404 when asking the API for that review's comments directly.
The bug is in createCodeComment in services/pull/review.go. When reviewID != 0, it calls FindComments with only ReviewID, Line, TreePath and Type, with no or . It then copies the first match's , and into the new comment. The caller, , only checks that the caller's own pull request already has a code comment on that path and line. It never checks that belongs to that pull request. The attacker first comments on the matching path and line in a pull request they can comment on (they do not need a repository of their own). They then post the reply form to , and read the copied back by replying to the planted comment through the API. The leak is narrow. Each hit needs a review ID, which is sequential instance-wide but does not reveal its repository. It also needs the exact file path and line of a review comment on the new side of the diff, although the response status confirms guesses (200 for a hit, 500 for a wrong path or line, 404 for a nonexistent review). Pending reviews are affected too, but only the diff under a draft comment leaks, not the draft text. The unbound lookup was introduced in b091c994b593 ("Comments on review should have the same sha (#13448)") and first released in v1.14.0. The API reply route used here to read the hunk back exists only since v1.27.0, so on older releases the hunk is still copied but cannot be read back this way.
Are you affected?
Ask from here. InfraStack checks the affected versions against your stack and answers in your inbox.
InfraStack checks the affected versions against your stack and answers in Slack, with the evidence and the fix.
InfraStack checks it against your stack and answers on your report, with the evidence and the fix.
IssueIDUpgrade to 28.4.0
28.4.0>= 1.14.0, <= 28.3.0IssueIDRepoIDPatchCommitSHAInvalidatedpull_service.CreateCodeCommentreplyReviewIDPOST /{owner}/{repo}/pulls/{index}/files/reviews/commentsdiff_hunkWhen a code comment is posted as a reply, createCodeComment reuses the diff hunk stored with the first comment of the review
being replied to. The review ID is the form field reply, and the lookup is not limited to the pull request (or repository)
the request was authorized for:
// services/pull/review.go:218
if line > 0 {
if reviewID != 0 {
first, err := issues_model.FindComments(ctx, &issues_model.FindCommentsOptions{
ReviewID: reviewID, // request-controlled; no IssueID, no RepoID
Line: line,
TreePath: treePath,
Type: issues_model.CommentTypeCode,
…
})
if err == nil && len(first) > 0 {
commitID = first[0].CommitSHA
invalidated = first[0].Invalidated
patch = first[0].Patch // diff hunk of whatever repository that review belongs to
} …
Observed at commit 31626de2a6cdd3e1fe93216e4ac80f511297f1e7 with default settings: victim/private is a private repository whose
pull request changes line 3 of deploy/settings.env to PASSWORD=s3cr3t-of-the-victim; review 1 has a comment on that line.
The unrelated regular user attacker opens a pull request in their own attacker/scratch, comments on deploy/settings.env
line 3 there, and submits the reply form with reply=1. The API then hands the attacker a comment in attacker/scratch with
"diff_hunk": "@@ -1,4 +1,4 @@\n HOST=db.internal\n USER=app\n-PASSWORD=\n+PASSWORD=s3cr3t-of-the-victim"
and the commit_id of the victim's commit, while GET /api/v1/repos/victim/private/pulls/1/reviews/1/comments answers the
attacker 404.
The path from the request to the copy:
POST /{username}/{reponame}/pulls/{index}/files/reviews/comments (routers/web/web.go:1662) sits behind
context.RepoMustNotBeArchived() (:1664) and optSignIn, context.RepoAssignment, repo.MustAllowPulls, reqUnitPullsReader
(:1667). All of them look at the repository in the URL, which can be the attacker's own.repo.CreateCodeComment (routers/web/repo/pull_review.go:64) loads the pull request from the URL with GetActionIssue and
passes form.Reply (services/forms/repo_form.go:471) unchecked as replyReviewID (:98). In the UI the field is filled by
templates/repo/diff/comment_form.tmpl:34 with the review ID of the conversation being replied to.pull_service.CreateCodeComment (services/pull/review.go:119-125) asks only ReviewExists(ctx, issue, treePath, line)
(models/issues/review.go:451): does the caller's pull request already have a code comment on that path and line? The
attacker creates that comment first; the path does not have to exist in their pull request. replyReviewID is never
compared with issue.ID.createCodeComment(…, replyReviewID, …) runs the lookup quoted above. FindCommentsOptions.ToConds
(models/issues/comment.go:1094-1119) adds a repository or issue condition only when RepoID / IssueID are set, so the
query is review_id = ? AND line = ? AND tree_path = ? AND type = code over all repositories. The new comment is then
created on the caller's pull request with CommitSHA: commitID, ReviewID: reviewID, Patch: patch
(services/pull/review.go:287-300).diff_hunk / commit_id by convert.ToPullReviewComment (services/convert/pull_review.go:113-115).
POST /api/v1/repos/{owner}/{repo}/pulls/{index}/comments/{id}/replies (CreatePullReviewCommentReply,
routers/api/v1/repo/pull_review.go:209) returns that JSON for the reply it creates. This route cannot name a foreign
review by itself, because it loads the parent comment with GetCommentWithRepoID(ctx, ctx.Repo.Repository.ID, …) and takes
parent.ReviewID; but the comment planted in step 4 is in the attacker's repository and carries the foreign ReviewID, so
a reply to it goes through the same unbound lookup and returns the victim's hunk.The unbound lookup was introduced in b091c994b593 ("Comments on review should have the same sha (#13448)", 2020-11-09) and
first released in v1.14.0. The API reply route used in step 5 to read the hunk back only exists since v1.27.0 (331450b17a,
2026-04-27), so on older releases the hunk is still copied into the attacker's comment but this way of reading it back is not
available. The notification mail template (templates/mail/repo/issue/default.tmpl:56) also prints the stored hunk; that
channel was not tested (no mail offline).
Other users of a request-supplied review ID bind it: DismissReview compares review.Issue.RepoID with the repository
(services/pull/review.go:420-423), and the API's prepareSingleReview rejects review.IssueID != pr.IssueID and pending
reviews of other users (routers/api/v1/repo/pull_review.go:722-732).
A signed-in regular user on a default configuration reads diff hunks of pull requests in repositories they have no access to,
within narrow limits: each hit yields at most the last [ui] CODE_COMMENT_LINES (default 4) diff lines ending at a line that
carries a review comment, plus the commit SHA; only comments on the new side of the diff are reachable (the lookup runs for
line > 0); and for each hunk the attacker must supply the review ID, the exact file path and the line. They need one pull
request they can comment on. No repository of their own is needed: a third account with no repository got the same result
(HTTP 200) on somebody else's public pull request, once a code comment existed on that path and line there.
Review IDs are one auto-increment sequence for the whole instance, so the attacker's own r
NVD data is provided by NIST and is public domain. Posts quoted belong to their authors.