---
id: "CVE-2026-128365"
page: "https://infrastack.ai/live/CVE-2026-128365"
kind: "vulnerability"
aliases: ["CVE-2026-128365", "GHSA-74jf-6hjp-549c"]
title: "RemoveTeamReviewRequest treats team id 2 as Actions user, bypassing approvals"
severity: "medium"
cvss: null
epss: null
exploited: false
status: "open"
category: "package"
products: [{"name": "gitea.dev", "fixed": ["28.4.0"], "affected": ">= 1.19, <= 28.3.0", "ecosystem": "go"}]
ecosystems: ["go"]
tags: ["cwe-863", "gitea", "go", "package", "protected-branches", "required-approvals", "self-hosted"]
not_affected_if: ["default-config", "no-required-approvals", "team-2-not-official-reviewer", "version-28.4.0-or-later"]
published_at: "2026-11-15T21:03:13+00:00"
first_seen_at: "2026-11-15T21:12:47+00:00"
updated_at: "2026-11-15T21:14:22+00:00"
sources: [{"source": "ghsa-repo", "url": "https://github.com/go-gitea/gitea/security/advisories/GHSA-74jf-6hjp-549c", "first_seen_at": "2026-11-15T21:12:47+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-128365", "first_seen_at": "2026-11-15T22:40:23+00:00"}]
exploit_sources: []
---

# RemoveTeamReviewRequest treats team id 2 as Actions user, bypassing approvals

Link for people: https://infrastack.ai/live/CVE-2026-128365 (this .md is for agents)

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.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- go:gitea.dev affected >= 1.19, <= 28.3.0 fixed 28.4.0

## How to check

- Check the Gitea version with `gitea --version`; affected builds are `>= 1.19.0` up to `28.3.0`.
- Find the team with id 2 in the instance (the second team ever created, usually the first after `Owners`) and check whether its organization has protected branches with required approvals.
- Review whether any protected branch lists that team as an approvals whitelist member or grants it write access to code.

## Fix

- Gitea `28.4.0` (per the product range; the advisory's patch removes the faulty block in `RemoveTeamReviewRequest`).

## Timeline

- 2026-11-15T21:12:47+00:00 ghsa-repo https://github.com/go-gitea/gitea/security/advisories/GHSA-74jf-6hjp-549c
- 2026-11-15T22:40:23+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-128365

## Documents

- [advisory] Maintainer's advisory: github.com https://github.com/go-gitea/gitea/security/advisories/GHSA-74jf-6hjp-549c
- [fix] Release notes: github.com https://github.com/go-gitea/gitea/releases/tag/v28.4.0

## From the sources

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 `gitea-actions` as its reviewer.

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

## Details

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`:

```go
// 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`.

### The path

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

1. `mallory` opens pull request #1 from a branch of `acme/app`.

2. `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`).

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

4. `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`.

5. `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.

## Impact

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

---

_Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai_
