GITEA.DEV · CVE-2026-129337 · Package
FIX → 28.4.0
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.
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.
Gitea servers from 1.16.0-rc1 through 28.3.0 with repository migrations enabled on the default configuration. Exposure exists only during an import, or after an import that failed before the hooks were installed; instances that never migrate repositories, or that use pull mirrors, are not affected.
Not affected if gitea-28.4.0-or-later, no-migrations, pull-mirror-only
Who cares gitea, http-git, self-hosted
gitea --version or check the Gitea version in the admin dashboard and compare it with 28.4.0*.sample filesUpgrade to 28.4.0
28.4.0 or later (affected from through )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 after the clone, wiki clone, branch sync and LFS download, so during that time runs with no write check at all.
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.
1.16.0-rc128.3.0CleanUpMigrateInfogit receive-packThe 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.
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):
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):
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):
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.
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.
NVD data is provided by NIST and is public domain. Posts quoted belong to their authors.