This is my write-up and lab PoC for [CVE-2026-125423]( also known as [GHSA-6m4f-m9vc-7946](
Short version: Gitea let a new repository accept pushes before auto-init was finished. If my push landed early enough, the initial-commit code cloned my tree. A symlinked `README.md` then redirected a file write into a server-side Git hook. The internal push ran that hook as the Gitea OS user.
Not bad for a file that is supposed to contain documentation.
**Severity:** High, 8.5 in the GitHub advisory
**Affected:** ` **Warning:** the PoC is active. It creates private test repositories, pushes Git objects, overwrites a server-side hook during exploitation, and writes marker files. Run it only in a disposable lab that you own. Do not point it at production or random internet targets.
Repository creation looks simple from the outside. You call the API with `auto_init=true`, Gitea creates the bare repo, adds a README, makes the first commit, and pushes it.
Under the hood, there was a small but useful gap:
1. The repository record and bare repo already existed.
4. Auto-init cloned the current repo instead of starting with a clean local repo.
So there was a race between my push and Gitea's clone. If my ref became visible at the right moment, my content ended up in the temporary worktree.
That alone should not be enough for RCE. The second bug made it interesting.
Git stores symlinks with mode `120000`. I created a valid Git tree where `README.md` pointed here:
../../../gitea-repositories//.git/hooks/post-receive.d/gitea
That path works with the standard relative layout used in my lab. No client-side symlink support was needed because the PoC builds the Git object directly.
`prepareRepoCommit` called `CloneRepoToLocal`. Checkout was enabled, and no fixed trusted branch was selected.
If the pushed ref won the race, Git checked out `README.md` as a symlink in the temporary worktree.
### 3. Turn the README write into a hook overwrite
Gitea generated the default README and wrote it with:
os.WriteFile(filepath.Join(tmpDir, "README.md"), []byte(res), 0o644)
The path already existed as my symlink. `os.WriteFile` followed it and truncated the target.
The `0644` mode did not help. It is used when creating a file, but it does not remove the executable bit from an existing hook.
### 4. Use the repository description as shell content
The default README starts with a Markdown heading:
To a shell, that is just a . The repository description comes after it, and the description was controlled by me.
After the overwrite, the hook contained the generated README, including my commands.
The internal initialization push triggered `post-receive`. Git ran the overwritten delegate hook as the Gitea service account.
No Actions runner or client-side trick was involved. The command ran through the server-side Git hook path.
- `GITEA_HOOK_RCE` in a server-side file;
- `GITEA_AUTO_CONFIRMED` at a fresh, run-specific `/avatars/.txt` URL.
For the HTTP check, status 200 alone was not enough. Gitea can return a fallback avatar with status 200. The body had to be exactly:
The URL was new for every run. That made the result much harder to explain away as an old file or a lucky response.
Local avatar storage was only needed for this HTTP proof. It was not part of the vulnerability itself.
This was a race, not a magic reliable RCE button.
An attempt could fail because the push arrived too late. The payload also depended on the server checking out symlinks and on the relative path resolving to the writable hook.
- one payload working on every possible installation.
The public advisory lists successful testing on Gitea 28.3.0, 28.2.0, 1.27.1, and 1.25.5, with SQLite, MySQL, and PostgreSQL included in the testing summary.
The maintainers fixed both sides of the problem:
- auto-init now builds the first commit in a fresh directory instead of cloning existing repo content;
- a new repository only becomes ready and accepts pushes after initialization is complete.
The main patch was [#40376]( with [#40383]( as the release backport.
The fix shipped in [Gitea 28.4.0]( If you run Gitea, upgrade. Disabling Actions or the hook editor does not fix this chain.
The included `autoinit_hook_race.go` is a cleaned-up version of my research harness.
The payload is fixed and non-destructive. It writes the marker, saves `id`, and creates the exact HTTP proof in auto mode.
The PoC uses basic auth with the disposable lab account. It cleans up tracked test repositories, but marker files still need to be checked and removed manually.
A recent Go toolchain and Git are required.
Use a vulnerable local version, a non-admin test account, and local avatar storage. The default marker paths assume `/var/lib/gitea/data`. Change them if your lab uses another data directory.
Auto mode prints a fresh proof URL and only reports success after the exact marker is returned. Manual mode is available without `-auto`; it defaults to eight sequential attempts and leaves confirmation to the server-side marker files.
To check an old HTTP marker without creating repositories or pushing:
-proof-url '
Do not reuse real passwords. Passing passwords on the command line can expose them through shell history or local process inspection.
I reported the issue privately. The maintainers reviewed it, prepared the patch, backported it, and published the advisory together with the fixed release.
- Reporter: [grigorovichvlad](
- Fix: [bircni]( and [lunny](
Thanks to the Gitea team for the quick and clean disclosure process.
NVD does its own processing and can lag behind the CVE record and vendor advisory. The official CVE record is already published.
This code is for education and authorized lab testing only. If you are looking at an actual Gitea server rather than a lab snapshot, the useful step is not running the PoC. It is upgrading to 28.4.0 or later.
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
