
Write-up and Go lab PoC for CVE-2026-125423, a Gitea auto-init race that turns a symlinked README into a server-side Git hook overwrite and RCE. Fixed in 28.4.0.
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 next 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: <= 28.3.0
Fixed: 28.4.0
Access needed: a regular account that can create a repository and push to it
No admin, SSH, Actions, or runner needed
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:
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/<owner>/<repo>.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.
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.
The default README starts with a Markdown heading:
# <repository-name>
To a shell, that is just a comment. 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.
I used three markers:
GITEA_HOOK_RCE in a server-side file;id in another file;GITEA_AUTO_CONFIRMED at a fresh, run-specific /avatars/<run-id>.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:
GITEA_AUTO_CONFIRMED
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.
I did not claim any of these:
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:
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.
go build -o poc ./autoinit_hook_race.go
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.
./poc \
-base 'http://127.0.0.1:3000' \
-user 'labuser' \
-password '<disposable-lab-password>' \
-auto
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:
./poc \
-proof-only \
-proof-url 'http://127.0.0.1:3000/avatars/<run-id>.txt'
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.
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 next step is not running the PoC. It is upgrading to 28.4.0 or later.