---
id: "CVE-2026-129337"
page: "https://infrastack.ai/live/CVE-2026-129337"
kind: "vulnerability"
aliases: ["CVE-2026-129337", "GHSA-8cjj-9p56-j54f"]
title: "Read-only users can push over HTTP to repositories being migrated"
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", "gitea", "http-git", "package", "self-hosted"]
not_affected_if: ["gitea-28.4.0-or-later", "no-migrations", "pull-mirror-only"]
published_at: "2026-11-15T21:03:14+00:00"
first_seen_at: "2026-11-15T21:12:47+00:00"
updated_at: "2026-11-15T21:14:21+00:00"
sources: [{"source": "ghsa-repo", "url": "https://github.com/go-gitea/gitea/security/advisories/GHSA-8cjj-9p56-j54f", "first_seen_at": "2026-11-15T21:12:47+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-129337", "first_seen_at": "2026-11-15T22:40:23+00:00"}]
exploit_sources: []
---

# Read-only users can push over HTTP to repositories being migrated

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

While a repository is being imported, the HTTP git route does not check write permission, so a user with only read access can push branches and tags into it. The pushed commits look like imported history and leave no activity-feed entry.

_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

- Run `gitea --version` or check the Gitea version in the admin dashboard and compare it with `28.4.0`
- Look for repositories in the being-migrated state (the migration status in the database) that have no hooks directory content besides `*.sample` files
- Review recent pushes in repositories that were imported recently for commits not tied to a user action

## Fix

- Gitea: upgrade to `28.4.0` or later (affected from `1.16.0-rc1` through `28.3.0`)

## Timeline

- 2026-11-15T21:12:47+00:00 ghsa-repo https://github.com/go-gitea/gitea/security/advisories/GHSA-8cjj-9p56-j54f
- 2026-11-15T22:40:23+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-129337

## Documents

- [advisory] Maintainer's advisory: github.com https://github.com/go-gitea/gitea/security/advisories/GHSA-8cjj-9p56-j54f
- [fix] Release notes: github.com https://github.com/go-gitea/gitea/releases/tag/v28.4.0

## From the sources

A user with only read access to a repository can push to it over HTTP while it is being imported. The pushed commits create or overwrite its branches and tags, become part of the imported repository, and leave no entry in its activity feed. For a public repository this is any registered user; for a private one it is anyone with read access, such as a read-only team member. The attached reproducer has an unrelated read-only user overwrite `main` of another user's repository during a migration, and shows the identical push being refused with "User permission denied for writing" once the import has finished.

The cause is in `httpBase` (`routers/web/repo/githttp.go`). Since the AGit support added in 370516883717 (#14295, first released in v1.16.0-rc1), it lowers the required mode for `git-receive-pack` on an existing code repository to read and leaves the write check to the `pre-receive` hook. Unlike the SSH path (`routers/private/serv.go`) and the web routes, it never refuses a repository whose status is `RepositoryBeingMigrated`. Meanwhile, `MigrateRepositoryGitData` (`services/repository/migrate.go`) places a plain `git clone --mirror` with no Gitea hooks at the served location. The delegate hooks are only written by `CleanUpMigrateInfo` after the clone, wiki clone, branch sync and LFS download, so during that time `git receive-pack` runs with no write check at all.

The attacker has to push inside this window, but does not need a slow or cooperating import source. Against a one-commit import that finished in 0.12 s, a blind push loop landed a branch in 4 of 5 runs. If the import fails before the hooks are installed (for example a wiki clone or LFS download error), the repository stays in the being-migrated state without hooks, and readers can keep pushing until the owner deletes or retries it. Imports created as pull mirrors are not affected. The bug grants write access only: nothing becomes readable that was not already, and no code runs on the server.

## Details

Scanned commit `31626de2a6cdd3e1fe93216e4ac80f511297f1e7`. Attacker: a regular user who can read the repository (any
registered user for a public one, a read-only team member for a private one). Configuration: default. Entry point: `git push`
over HTTP, i.e. `POST /{owner}/{repo}.git/git-receive-pack`.

Two things combine. First, git over HTTP does not check write permission for a push to an existing code repository. It
lowers the required mode to read (so that readers can push AGit `refs/for/*`) and leaves the decision to the `pre-receive`
hook (`routers/web/repo/githttp.go:184-204`):

```go
if repoExist {
	// Only the main code repo accepts refs/for pushes, so wiki pushes must keep write checks.
	if !isWiki {
		accessMode = perm.AccessModeRead
	}
	…
	if !p.CanAccess(accessMode, unitType) {
		ctx.PlainText(http.StatusNotFound, "Repository not found")
		return nil
	}

	if !isPull && repo.IsMirror {
```

`httpBase` never looks at `repo.Status`. The SSH path does (`routers/private/serv.go:161`), and so do the web routes
(`services/context/repo.go:711`):

```go
if repo.IsBeingCreated() {
	ctx.PrivateUserErrorf(http.StatusForbidden, "Repository is being created, you could retry after it finished")
	return
}
```

The lowering to read was introduced in `370516883717` ("Add agit flow support in gitea (#14295)", 2021-07-28), first
released in v1.16.0-rc1; before it, `httpBase` refused the same push with 403 before git ran.

Second, a repository that is being migrated has no Gitea hooks for most of the import. The database row already exists with
`Status: RepositoryBeingMigrated` (`routers/api/v1/repo/migrate.go:179`, `services/task/task.go:117`), so the repository
resolves on the git routes and the usual read permission applies. `MigrateRepositoryGitData` then replaces its directory with
a plain clone at the final, served location (`services/repository/migrate.go:88-102`):

```go
if err := git.DeleteRepository(ctx, repo); err != nil {
	…
}

if err := git.CloneExternalRepo(ctx, opts.CloneAddr, repo, git.CloneRepoOptions{
	Mirror:        true,
	…
```

`CloneExternalRepo` (`modules/git/clone.go:13`) is `git clone --mirror -- <url> <RepoLocalPath(repo)>`; what it creates
contains git's `*.sample` hooks only. The delegate hooks are written by `CleanUpMigrateInfo` → `git.CreateDelegateHooks`
(`migrate.go:240`, `:264`), the last step of the function. Between the two lie the clone itself, `WriteCommitGraph` (`:104`),
the wiki probe and wiki clone (`:109`), the branch and tag sync (`:147-157`) and the download of all LFS objects (`:165`).
If the import fails in between (wiki clone error, LFS download error, clone timeout), the repository is left with status
`RepositoryBeingMigrated` and without hooks, and readers can still push to it after the failed import.

So mallory's request passes `httpBase` with read permission, `git receive-pack` runs in a directory without `pre-receive`,
and git updates the ref. The write check (`routers/private/hook_pre_receive.go:60`) never runs. `post-receive` is missing
as well: after mallory's push the repository's activity feed stayed empty, while a later push by alice added a
`commit_repo` entry. `SyncRepoBranchesWithRepo` (`migrate.go:147`) then records whatever the refs point to as the imported
state.

The window opens as soon as `git clone` has initialised the directory, before any object has arrived. With the remote
holding back its pack, mallory's push of a new root commit to `refs/heads/evil` was accepted and the finished import had the
branches `evil` and `main`. A push to `refs/heads/main` in that phase is accepted as well, but Gitea's own
`git clone --mirror` then aborts (`initial ref transaction called with existing refs`, git 2.47.3) and the import fails
with 422, which leaves the repository in the hookless state described above. Overwriting `main` works once the clone has
written its refs, which is what the reproducer does.

Imports created as pull mirrors are not affected: their row has `IsMirror` set from the start and `githttp.go:201` answers
the same push with `mirror repository is read-only`.

## Impact

A user with read access to a repository can write to any of its branches and tags while it is being imported (default
settings, stock `git` client, the user's own password), and the result looks like imported history: the push leaves no
entry in the activity feed. For a public repository that is every registered user; for a private one it is anyone who has read access from the moment the repository is created. That case
was checked as well: a member of an organization team with read permission on all repositories pushed to `main` and
created a tag in a private repository of that organization while an owner imported it. The precondition is timing. The
victim must be running an import, and the attacker must push before its git phase ends, which lasts as long as the clone,
the wiki clone and the LFS download take. The repository answers API and git requests of its readers during that time, so
the start of an import can be watched for. No slow or cooperating import source is needed: against a one-commit import
that finished in 0.12 s, a blind loop of pushes landed a branch in 4 of 5 runs. The window does not always close either:
an import that fails between the clone and the hook installation leaves a repository that readers can keep pushing to
until the owner deletes or retries it, and a push to `main` during the clone is one way to make the import fail. Once an
import has finished, the same user cannot push. Nothing becomes readable that was not before, and no code runs on the
server.


_Reported by the Anthropic OSS scanner, finding ANT-2026-2TN6AY02 (scan gitea-20261022-004), commit 31626de2a6cdd3e1fe93216e4ac80f511297f1e7._

---

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