GITEA.DEV · CVE-2026-128365 · Package
FIX → 28.4.0
Gitea's RemoveTeamReviewRequest looks up reviews under a negated team id, which matches the Actions system user (id -2), and marks that user's review as official. A user with write access can therefore get a job-token approval counted toward required approvals and merge their own pull request.
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.
Only Gitea instances where a pull request on a protected branch with required approvals can be affected, and only in the organization that owns team id 2. The attacker needs write access to an organization repository, or can use a fork pull request against a public repository of that organization, and it still takes someone with merge rights to merge the fork pull request. Instances without required approvals, or whose team id 2 is not an official reviewer team, are not affected.
Not affected if default-config, no-required-approvals, team-2-not-official-reviewer, version-28.4.0-or-later
Who cares gitea, go, protected-branches, required-approvals, self-hosted
gitea --version; affected builds are >= 1.19.0 up to 28.3.0.Owners) and check whether its organization has protected branches with required approvals.A user with write access to an organization repository can merge their own pull request into a branch protected by "required approvals" without any human review. They approve the PR with an Actions job token, then request and withdraw a review from the team whose id is 2, which turns the gitea-actions approval into an official one. This only affects the one organization on the instance that owns team id 2, and only when that team counts as an official reviewer for the branch (write access to code, or listed in the approvals whitelist). The attacker does not need to be a member of that team.
The bug is in RemoveTeamReviewRequest (models/issues/review.go, around lines 895–912). When a team review request is withdrawn, it looks up "the latest review of the team" with GetReviewByIssueIDAndUserID(ctx, issue.ID, -reviewer.ID) and sets official=true on whatever row it finds. No review is ever stored under a negated team id. Negative reviewer ids are system users, though, and ActionsUserID = -2 is the identity behind every Actions job token. Any job token, including one from a runner the attacker registers on their own repository, can read a public repository and post a review. That review is normally stored as official=false and does not count toward required approvals. Once the team 2 request is withdrawn, GetGrantedApprovalsCount counts it and the merge goes through. The gain is limited to one approval per pull request, and the PR visibly shows as its reviewer.
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.
Upgrade to 28.4.0
28.4.0 (per the product range; the advisory's patch removes the faulty block in RemoveTeamReviewRequest).gitea-actionsThe attached reproducer runs a default sqlite instance. The merge is refused with 405 Does not have enough approvals, still refused after withdrawing an otherwise identical team with id 3, and accepted with 200 after withdrawing team id 2. A user with no access to the organization can flip the flag the same way from a fork PR, but cannot merge it themselves. The lookup dates from v1.13.0 and was harmless until the Actions user (id -2) arrived in 4011821c946e, first released in v1.19.0.
Scanned commit 31626de2a6cdd3e1fe93216e4ac80f511297f1e7, default configuration. Attacker: a regular user with write access
to an organization repository whose protected branch requires approvals. Entry point:
DELETE /api/v1/repos/{owner}/{repo}/pulls/{index}/requested_reviewers (or the web form POST /{owner}/{repo}/issues/request_review).
When a team review request is withdrawn, RemoveTeamReviewRequest tries to restore "the latest official review from that
team" and looks it up under the reviewer id -team.ID:
// models/issues/review.go:895
official, err := IsOfficialReviewerTeam(ctx, issue, reviewer)
…
if official {
// recalculate which is the latest official review from that team
review, err := GetReviewByIssueIDAndUserID(ctx, issue.ID, -reviewer.ID)
…
if review != nil {
if _, err := db.Exec(ctx, "UPDATE `review` SET official=? WHERE id=?", true, review.ID); err != nil {
No review is ever stored with reviewer_id = -teamID: a team request is a row with reviewer_team_id set
(AddTeamReviewRequest, models/issues/review.go:848), and reviews by team members carry the member's own id. Negative
reviewer_id values do exist, though. They are the system users of models/user/user_system.go:49-54, and
ActionsUserID = -2 is the doer behind every Actions job token. For the team with id 2 the lookup therefore returns the
latest approve/reject/request review of gitea-actions on that pull request, and the UPDATE marks it official. The
condition checked before it (IsOfficialReviewerTeam) is about the team, not about the author of the row being updated.
On a running instance: a pull request approved only by a job token is refused with 405 Does not have enough approvals;
after its author requests and withdraws a review from the team with id 2, the same merge returns 200.
mallory is a member of a team with write access in the organization acme. acme/app is public and its main branch
has a protection rule with required_approvals: 1. The team developers has id 2.
mallory opens pull request #1 from a branch of acme/app.
mallory obtains an Actions job token. All job tokens act as user -2, so any one will do; the simplest source is a
repository of mallory's own with a runner registered for it (POST /api/v1/repos/mallory/mine/actions/runners/registration-token).
A job token gets read access to other public repositories (GetActionsUserRepoPermission,
models/perm/access/repo_permission.go:337-367).
With the job token mallory sends POST /api/v1/repos/acme/app/pulls/1/reviews {"event":"APPROVED"}. The route needs
reqToken() and read access to code (routers/api/v1/api.go:1515-1517, group guards at :1535). SubmitReview
decides the official flag with IsOfficialReviewer (models/issues/review.go:494), which ends in
IsUserOfficialReviewer → HasAccessUnit(…, unit.TypeCode, AccessModeWrite) (models/git/protected_branch.go:264-276).
That helper evaluates user -2 as a plain user without write access, so the review is stored with official=false and
the merge is refused. Up to here everything works as intended.
mallory sends POST and then DELETE /api/v1/repos/acme/app/pulls/1/requested_reviewers {"team_reviewers":["developers"]}.
Both go through apiReviewRequest (routers/api/v1/repo/pull_review.go:867) to issue_service.TeamReviewRequest
(services/issue/review_request.go:180). Its only check, isValidTeamReviewRequest, accepts the poster of the pull
request (CanDoerChangeReviewRequests, services/issue/review_request.go:240). The DELETE reaches the code quoted
above. IsOfficialReviewerTeam (models/issues/review.go:308) is true because the team has write access to code (with
an approvals whitelist enabled it is true when the team is on the whitelist). The lookup with -2 finds the bot's
approval and sets official=true.
GetGrantedApprovalsCount (models/issues/pull.go:770) counts rows with type=approve AND official=true, now finds
one, and POST /api/v1/repos/acme/app/pulls/1/merge succeeds.
Doing step 4 with a second team that has the same permissions and members but id 3 leaves the review at official=false
and the merge refused, which isolates the id collision as the cause.
The web handler UpdatePullReviewRequest (routers/web/repo/pull_review.go:385-399, form fields id=-2&action=detach)
calls the same TeamReviewRequest; that route was read, not exercised.
The block dates from team review requests (8be3e439c2b3, "Add team support for review request (#12039)", 2020-10-13),
when no review could carry a negative reviewer id. It became harmful with the Actions user id -2, introduced in
4011821c946e ("Implement actions (#21937)", 2023-01-31), first released in v1.19.0 (Actions became enabled by
default in v1.21.0). This is from reading the history; older trees could not be built to bisect.
A user with write access who is subject to "required approvals" merges their own change into the protected branch with no
reviewer involved. The pull request shows a single approval, by gitea-actions.
The precondition that limits this is the id: the team must have id 2, the only negated team id that is a system user able
to submit reviews. Team ids are instance-wide and sequential, so this is the second team ever created on the instance,
and exactly one organization owns it. On an instance with a single organization that is usually the first team created
after Owners; if a second organization was created before any custom team, it is that organization's Owners team.
The team has to count as an official reviewer team for the branch (write access to code, or listed in the
approvals whitelist); the attacker does not need to be a member of it. Organizations that do not own team 2 are not
affected. Both points were checked in a separate run: with acme/Owners as team 2 (another orga
NVD data is provided by NIST and is public domain. Posts quoted belong to their authors.