---
id: "CVE-2026-123642"
page: "https://infrastack.ai/live/CVE-2026-123642"
kind: "vulnerability"
aliases: ["CVE-2026-123642", "GHSA-9827-6wh6-634q"]
title: "AGit proc-receive lets users without PR access create pull requests"
severity: "medium"
cvss: null
epss: null
exploited: false
status: "open"
category: "package"
products: [{"name": "gitea.dev", "fixed": ["28.4.0"], "affected": ">= 1.16, <= 28.3.0", "ecosystem": "go"}]
ecosystems: ["go"]
tags: ["cwe-862", "git-hosting", "gitea", "package", "self-hosted"]
not_affected_if: ["gitea-28.4.0-or-later", "gitea-before-1.16", "managed-hosting"]
published_at: "2026-11-15T21:03:17+00:00"
first_seen_at: "2026-11-15T21:12:46+00:00"
updated_at: "2026-11-15T21:14:17+00:00"
sources: [{"source": "ghsa-repo", "url": "https://github.com/go-gitea/gitea/security/advisories/GHSA-9827-6wh6-634q", "first_seen_at": "2026-11-15T21:12:46+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-123642", "first_seen_at": "2026-11-15T22:40:23+00:00"}]
exploit_sources: []
---

# AGit proc-receive lets users without PR access create pull requests

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

Gitea's AGit push handling skips the pull-request permission check, so users with only code read access, such as read-only deploy keys or tokens, can open pull requests and write refs/pull/N/head. They cannot write branches or tags, merge, or read data they could not already read.

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

## Affected

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

## How to check

- Check the Gitea version with `gitea --version` and compare it to the affected range `>= 1.16, <= 28.3.0`.
- Look at the instance's `[log]` output for `POST /api/internal/hook/proc-receive/...` requests from read-only credentials.
- Review `pull` requests created by deploy keys or read-only tokens (author `gitea:deploy-key`).

## Fix

- Gitea `28.4.0` (fixed version in the product ranges).

## Timeline

- 2026-11-15T21:12:46+00:00 ghsa-repo https://github.com/go-gitea/gitea/security/advisories/GHSA-9827-6wh6-634q
- 2026-11-15T22:40:23+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-123642

## Documents

- [advisory] Maintainer's advisory: github.com https://github.com/go-gitea/gitea/security/advisories/GHSA-9827-6wh6-634q
- [fix] Release notes: github.com https://github.com/go-gitea/gitea/releases/tag/v28.4.0

## From the sources

A missing permission check in Gitea's AGit flow lets anyone who can only read a repository's code open pull requests in it, even when they have no access to its pull requests. This includes a read-only deploy key or token, a team member granted `repo.code: read` only, or any signed-in user on a public repository whose pull-request unit is disabled. The pull request is created normally, with notifications, and a `refs/pull/N/head` ref pointing at the attacker's commit is written into the repository. The attached reproducer shows this in the default configuration over HTTP: a read-only deploy token on a private repository opens pull request #1, authored by `gitea:deploy-key`.

`HookProcReceive` (`routers/private/hook_proc_receive.go`) loads the doer's permission but never checks it or the `IsWiki` flag. `pull_service.NewPullRequest` also skips its own access check for AGit pull requests (`services/pull/pull.go:69`), so the pre-receive hook is the only gate. `runHookPreReceive` in `cmd/hook.go` lets commands slip past that gate in two ways:

- **A ref name containing a space (HTTP or SSH).** The hook silently skips any stdin line that does not split into exactly three fields. `gitea hook proc-receive` parses the same line with `SplitN(..., 3)` and acts on it, and git does not validate ref names it routes to proc-receive. So a push to `refs/for/main/topic x` never reaches the internal pre-receive API but still becomes a pull request.
- **Any push to the wiki repository over SSH.** The hook skips every ref of a wiki push, while `gitea serv` hands the hooks the main repository's name. A principal with wiki write access but no pull-request access can therefore run `git push owner/repo.wiki.git <commit>:refs/for/main/topic` and open a pull request in the main repository. On this route the head must be a commit that already exists in the main repository.

The impact has firm limits. No branch or tag can be written this way and nothing is disclosed. Nothing merges without a writer. Actions treats AGit pull requests like fork pull requests, so they get no secrets and no run without approval.

The behavior dates from "Add agit flow support in gitea" (#14295, commit 370516883717), first released in v1.16.0-rc1. A one-check fix in `HookProcReceive` closes both routes and is included in the attached patch.

## Details

**Root cause.** `HookProcReceive` (`routers/private/hook_proc_receive.go:19-31`), the internal handler that turns an AGit
push (`refs/for/<base>/<topic>`) into a pull request, checks neither the permission it has just loaded nor the `IsWiki` flag,
and `pull_service.NewPullRequest` waives its own access check for the AGit flow (`services/pull/pull.go:69`). The only gate is
the pre-receive hook (`HookPreReceive` → `preReceiveFor`), and `gitea hook pre-receive` does not show every command to it. Two
adjacent `continue`s in the loop of `runHookPreReceive` keep a `refs/for/*` command away from the gate, and each is a separate
way to reach the unchecked handler:

1. **a ref name containing a space** (`cmd/hook.go:230-233`), over HTTP or SSH, for anyone with code read access. This is the
   route described first and the one the reproducer exercises;
2. **any push to the wiki repository over SSH** (`cmd/hook.go:226-228`), for anyone with wiki write access. See "Second way
   in" below.

One check in `HookProcReceive` closes both (see "Suggested fix").

Scanned commit `31626de2a6cdd3e1fe93216e4ac80f511297f1e7`, default configuration. For the first route the attacker is any
principal that may
*start* a `git-receive-pack` on the repository (`POST /{owner}/{repo}.git/git-receive-pack`, or `git-receive-pack` over SSH),
which means read access to the code unit. A push to an AGit ref whose name contains a space is never shown to the pre-receive
permission check, yet `gitea hook proc-receive` still turns it into a pull request.

With a **read-only deploy token** for the private repository `owner/secret`, this receive-pack command is refused with
`pre-receive hook declined` and the hook message "User permission denied for creating pull-request.":

    0000000000000000000000000000000000000000 <commit> refs/for/main/topic

The same request with a space in the ref name creates pull request #1, authored by `gitea:deploy-key`, and `refs/pull/1/head` points at
the pushed commit:

    0000000000000000000000000000000000000000 <commit> refs/for/main/topic x

With `[log] LEVEL = info` the router log shows `POST /api/internal/hook/pre-receive/owner/secret` → 403 for the first push. For
the second there is no pre-receive request at all, only `POST /api/internal/hook/proc-receive/owner/secret` → 200.

**Why a reader gets this far.** Both transports deliberately let readers start a push and leave the decision to pre-receive:
`routers/web/repo/githttp.go:185-188` lowers the required mode to read for the code repository, and
`routers/private/serv.go:246-252` does the same with the comment "The real permission check is done in HookPreReceive".

**Benign path.** For `refs/for/main/topic`, `gitea hook pre-receive` posts the command to `HookPreReceive`, which dispatches to
`preReceiveFor` → `AssertCreatePullRequest` → `Permission.CanRead(unit.TypePullRequests)`
(`routers/private/hook_pre_receive.go:110`, `:343`, `:67-84`). A deploy key has access to the code and wiki units only
(`models/perm/access/repo_permission.go:403-407`), so the answer is 403 and git refuses the push.

**Buggy path.** The pre-receive hook reads git's `old new ref` lines and skips whatever is not exactly three fields:

```go
// cmd/hook.go:163
func parseGitHookCommitRefLine(line string) (...) {
	fields := strings.Split(line, " ")
	if len(fields) != 3 {
		return "", "", "", false
	}
…
// cmd/hook.go:230
		oldCommitID, newCommitID, refFullName, ok := parseGitHookCommitRefLine(scanner.Text())
		if !ok {
			continue
		}
```

`old new refs/for/main/topic x` has four fields. It is the only line, so `count` stays 0, the `if count > 0` block that calls
`private.HookPreReceive` (`cmd/hook.go:259-270`) is not entered, and the hook exits 0. The skipped command is neither checked nor
rejected.

Nothing else rejects it. Gitea sets `receive.procReceiveRefs = refs/for` (`modules/git/config.go:77`), and git hands such
commands to the proc-receive hook without validating the ref name. Observed with the image's git 2.47.3: the owner pushing
`refs/heads/x y` gets `ng refs/heads/x y funny refname`, while `refs/for/main/topic x` reaches the hook. `gitea hook
proc-receive` parses the same command differently and keeps everything after the second space as the ref name:

```go
// cmd/hook.go:544
		t := strings.SplitN(string(rs.Data), " ", 3)
		…
		hookOptions.RefFullNames = append(hookOptions.RefFullNames, git.RefName(t[2]))
```

`HookProcReceive` loads the doer's permission but never consults it (`routers/private/hook_proc_receive.go:19-31`).
`agit.ProcReceive` resolves `main/topic x` to base branch `main` and topic `topic x` (`services/agit/agit.go:37-60`, `:110`)
and calls `pull_service.NewPullRequest` (`services/agit/agit.go:196`), which waives its own access check for this flow
(`services/pull/pull.go:69`: `canCreate := issue.Poster.IsAdmin || pr.Flow == issues_model.PullRequestFlowAGit`) and writes
`refs/pull/N/head` through `UpdateRefForAgit` (`services/pull/pull.go:138`).

The hook then answers `ok refs/for/main/topic x`. git cuts that at the space ("proc-receive reported status on unknown ref:
refs/for/main/topic") and tells the client `proc-receive failed to report status`. The pull request already exists at that point.

**Second way in: AGit push to the wiki over SSH.** The same unchecked handler is reached with a well-formed ref name and a
stock `git push`, by a principal that may write the wiki but has no access to the pull-request unit:

```
$ git push -o title=… -o description=… ssh://git@host/acme/product.git origin/dev:refs/for/main/topic
remote: error: User permission denied for creating pull-request.
 ! [remote reject

---

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