---
id: "CVE-2026-125423"
page: "https://infrastack.ai/live/CVE-2026-125423"
kind: "vulnerability"
aliases: ["CVE-2026-125423", "GHSA-6m4f-m9vc-7946"]
title: "Authenticated RCE during repository auto-initialization via a push race and README.md symlink"
severity: "high"
cvss: 8.5
epss: null
exploited: false
status: "open"
category: "package"
products: [{"name": "gitea.dev", "fixed": ["28.4.0"], "affected": "<= 28.3.0", "ecosystem": "go"}]
ecosystems: ["go"]
tags: ["cwe-362", "cwe-59", "git-hosting", "gitea", "package", "self-hosted"]
not_affected_if: ["auto-init-disabled", "fixed-version", "managed-hosting"]
published_at: "2026-11-15T21:03:02+00:00"
first_seen_at: "2026-11-15T21:12:49+00:00"
updated_at: "2026-11-15T21:14:01+00:00"
sources: [{"source": "ghsa-repo", "url": "https://github.com/go-gitea/gitea/security/advisories/GHSA-6m4f-m9vc-7946", "first_seen_at": "2026-11-15T21:12:49+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-125423", "first_seen_at": "2026-11-15T21:40:48+00:00"}]
exploit_sources: []
---

# Authenticated RCE during repository auto-initialization via a push race and README.md symlink

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

An authenticated user who can create and push to a repository can race repository creation with auto-init so that a symlinked README overwrites a server-side Git hook. The hook then runs commands as the operating-system account running Gitea.

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

## Affected

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

## How to check

- Run `gitea --version` or check the Gitea server version and compare it with `28.4.0`.
- Check whether Gitea runs with `DISABLE_GIT_HOOKS` set; the sources say this setting does not close the chain.
- Confirm whether `auto_init` is used with the Default README template on repository creation.

## Fix

- Gitea `28.4.0` (affected up to and including `28.3.0`).

## Timeline

- 2026-11-15T21:12:49+00:00 ghsa-repo https://github.com/go-gitea/gitea/security/advisories/GHSA-6m4f-m9vc-7946
- 2026-11-15T21:40:48+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-125423

## Documents

- [advisory] Maintainer's advisory: github.com https://github.com/go-gitea/gitea/security/advisories/GHSA-6m4f-m9vc-7946
- [fix] Release notes: github.com https://github.com/go-gitea/gitea/releases/tag/v28.4.0

## From the sources

### Summary

An authenticated, non-administrative user who can create a repository and push to it can execute commands as the operating-system account running Gitea by racing repository creation with auto_init=true.
The new repository can accept an external push before its initialization has finished. If the attacker’s ref becomes visible before Gitea clones the repository for initial-commit generation, Gitea checks out the attacker-controlled tree into a temporary directory. In the tested scenario, README.md is a Git symlink with mode 120000, pointing to the existing server-side hooks/post-receive.d/gitea file.
Gitea subsequently writes the generated README using os.WriteFile, which follows the symlink and overwrites the executable delegate hook. The generated README contains the user-controlled repository description. Gitea’s internal initialization push then invokes post-receive, causing the overwritten hook to be executed.
I confirmed command execution in an isolated laboratory on Gitea 28.3.0, 28.2.0, 1.27.1, 1.25.5 with SQLite, MySQL and PostgreSQL. Exploitation requires winning the race and a compatible server-side filesystem layout. It does not require an administrator account, SSH access, Actions, a runner, or permission to edit Git hooks through Gitea.
I am not claiming unauthenticated exploitation, root access, container escape, or compromise of the underlying host.

### Details

The issue affects the interaction between:
- repository creation with auto_init=true;
- the temporary checkout used to prepare the initial commit;
- generation of the default README.md;
- server-side post-receive.d delegate hooks.

1. The repository accepts pushes before initialization finishes
CreateRepositoryDirectly creates the repository database record before calling initRepository:
services/repository/create.go:254-260 - repository record creation;
services/repository/create.go:276-295 - storage validation and initialization;
services/repository/create.go:145-180 - bare repository, hooks, and initial-content initialization.
A concurrent HTTP push is handled independently. The Git HTTP path in routers/web/repo/githttp.go loads the newly created repository and checks permissions, but does not wait for auto_init to complete before starting git receive-pack.
This does not rely on push-to-create. The push happens after the repository record has been created but before initialization has finished.

2. The pushed tree contains a symlink as README.md

The object is constructed using Git plumbing commands, so the client operating system does not need to create a local symlink. This is a valid Git symlink entry rather than a malformed object.

3. auto_init clones the concurrently modified repository
prepareRepoCommit calls CloneRepoToLocal, which performs a local clone into the temporary directory:
 - services/repository/create.go:72-78;
 - modules/git/clone.go:17-20;
 - modules/git/repo.go:176-220.
The clone does not use NoCheckout, and it does not select a fixed trusted branch. If the attacker’s ref has become the repository’s current HEAD, Git checks out its tree and materializes README.md as a symlink in the temporary worktree.
If the ref appears too late, that particular attempt does not follow this path. This timing dependency explains why exploitation is not deterministic.

4. README generation follows the symlink
For the default README template, Gitea inserts the repository description into the generated content and writes it with:
os.WriteFile(filepath.Join(tmpDir, "README.md"), []byte(res), 0o644)

Relevant locations:
services/repository/create.go:80-94 - description substitution;
options/readme/Default:1-3 - default README template;
services/repository/create.go:99-102 - file write.
Because README.md already exists as a symlink, os.WriteFile opens its target for writing and truncates it. There is no check that the existing path is a regular file and no descriptor-based protection against following symlinks.
The 0644 mode does not remove permissions from an existing target. The delegate hook was previously created with its executable bit, so it remains executable after being overwritten.

5. The repository description becomes the hook body
The default README starts with a Markdown heading such as # <repository-name>
The shell treats that line as a comment. The attacker-controlled repository description appears later in the file without shell escaping. Once this content has replaced the hook, the description is interpreted as shell commands.
This is not command injection into an existing shell command. The underlying problem is that user-controlled content is written through a symlink into an executable server-side file.

6. The internal initialization push executes the hook
initRepoCommit stages the files, creates the initial commit, and pushes it to the managed repository. During this push, Git invokes post-receive.
The normal dispatcher in modules/git/hooks.go iterates over executable files under hooks/post-receive.d/. At this point, however, the gitea delegate contains the overwritten README content rather than the normal gitea hook ... post-receive invocation.
GITEA_INTERNAL_PUSH=true does not prevent this execution. That check belongs to the normal Go hook implementation, while the overwritten shell hook is invoked by Git before such a check could run.

Required conditions:
 - an authenticated user who can create a repository;
 - permission to push to that repository;
 - auto_init=true with the Default README template;
 - the attacker’s ref becoming visible before clone/checkout;
 - server-side Git symlink support;
 - a relative symlink target that resolves to the writable post-receive.d/gitea file;
 - an internal push that updates the ref and invokes post-receive;
 - the configured hook interpreter, normally bash.

The current payload assumes the standard relative layout in which the temporary worktree and repository storage are located under the same application data hierarchy. Nonstandard temporary paths, repository roots, or disabled server-side symlink support may prevent this particular payload. I did not test whether those configurations are generally safe.
[security].DISABLE_GIT_HOOKS=true does not by itself close this chain: the internal delegate hooks are still created and used during repository initialization.


### Impact

A regular authenticated user who is permitted to create and push to a repository can cross the expected boundary between repository ownership and server-side command execution.
Successful exploitation provides command execution with the privileges of the operating-system account running Gitea. Within those privileges, this can affect the confidentiality, integrity, and availability of repositories, configuration, credentials, database contents, and other resources accessible to the service.
No victim interaction is required. Administrative privileges, Actions, and runner access are not required. However, exploitation depends on winning the race and on the server-side environment satisfying the conditions described above.

---

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