PT-2026-50136 · Go · Code.Gitea.Io/Gitea
Published
2026-06-16
·
Updated
2026-06-16
·
CVE-2026-26231
CVSS v3.1
8.5
High
| Vector | AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:H/A:N |
Summary
Any authenticated low-privilege user with read access to a repository can push arbitrary commits directly to that repository, bypassing all write-access checks.
Vulnerability
Gitea's "Allow edits from maintainers" PR option can be abused via reverse-fork PRs:
- The web UI PR-create endpoint binds
allow maintainer edit=truewithout verifying that the submitter has write access to the HEAD repository. - Gitea allows creating a PR where BASE = attacker's fork and HEAD = upstream target. The attacker is "maintainer" of the BASE (their own fork), so the flag is set against the upstream HEAD.
- On
git pushover HTTP/SSH, Gitea relaxes the required access mode toReadwhenSupportProcReceiveis enabled (routers/web/repo/githttp.go,routers/private/serv.go) and defers enforcement to the pre-receive hook. - The pre-receive hook calls [
CanMaintainerWriteToBranch](https://github.com/go-gitea/gitea/blob/v1.25.5/models/issues/pull list.go#L72) (models/issues/pull list.go), which finds the malicious PR, seesAllowMaintainerEdit=true, and checks whether the pusher has write access to the BASE repo. Since BASE is the attacker's own fork, the check passes and the push is authorized against the upstream.
Exploitation
- Attacker forks the target repository.
- Attacker visits the web compare endpoint and creates a PR with
BASE = their fork,HEAD = upstream, and "Allow edits from maintainers" checked. - Attacker clones their fork, makes a commit, and runs
git push <upstream url> <branch>— the push is accepted.
Reproduction
bash
python3 poc.py --repo http://gitea:3000/victim/repo --user attacker --password attacker passExpected output:
[+] target: victim/my repo default branch: main
[*] forking -> attacker/my repo pocfork (202)
[+] fork ready
[+] malicious PR created (BASE=attacker fork, HEAD=upstream)
remote: . Processing 1 references
remote: Processed 1 references in total
To http://192.168.101.20:3000/victim/my repo.git
e5c07b3..9a0b884 main -> main
[+] latest commit on victim/my repo@main: 'PoC: unauthorized commit via maintainer-edit bypass'
[+] CONFIRMED: unauthorized push to upstream succeeded.A
PWNED.txt file will appear on the target repo's default branch, committed by the attacker who has no write access.Impact
Full repository compromise. Any logged-in user can backdoor any repository they can read, including all public repositories on the instance.
Suggested Fix
Two independent checks are missing; both should be added for defense in depth:
- At PR creation: before setting
AllowMaintainerEdit = true, verify the submitter has write access to the HEAD repository. - In
CanMaintainerWriteToBranch: verify that the PR's HEAD repo matches the repository being pushed to, and that the PR was opened by a legitimate owner/writer of the HEAD repository. Do not trustAllowMaintainerEditsolely based on BASE write access.
Fix
Incorrect Authorization
Found an issue in the description? Have something to add? Feel free to write us 👾
Weakness Enumeration
Related Identifiers
Affected Products
Code.Gitea.Io/Gitea