Gogs Authenticated RCE via Argument Injection in git rebase --exec (Unpatched, CVSSv4 9.4, GHSA-qf6p-p7ww-cwr9)
Gogs Authenticated RCE via Argument Injection in git rebase (TL-2026-0615), also tracked as GHSA-qf6p-p7ww-cwr9, is a critical-severity software vulnerability scored CVSS 9.4, first published 2026-05-28. It has no confirmed attribution, affects Gogs Gogs, maps to 31 MITRE ATT&CK techniques (T1005, T1021, T1027), and is covered by 9 detection rules and 18 indicators of compromise.
Key facts for TL-2026-0615
- Threat ID
- TL-2026-0615
- Also known as
- GHSA-qf6p-p7ww-cwr9, Gogs rebase --exec argument injection
- Severity
- CRITICAL
- CVSS
- 9.4 (CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H)
- Status
- ACTIVE
- Category
- VULNERABILITY
- First published
- 2026-05-28
- Last reviewed
- 2026-05-28
- Attribution confidence
- NONE
- Motivation
- UNKNOWN
- Target sectors
- technology, software-development, education, open-source, financial, government, research
- Target regions
- Global, North America, Europe, Asia-Pacific
- Detection rules
- 9
- Indicators of compromise
- 18
Malware and tooling in Gogs Authenticated RCE via Argument Injection in git rebase
Malware and tooling: Metasploit Framework — exploit/multi/http/gogs_rebase_argument_injection (Rapid7-published module)
Rapid7 Labs disclosed an unpatched CWE-88 argument injection (CVSSv4 9.4) in Gogs self-hosted Git service. An authenticated user crafts a malicious branch name beginning with --exec= that is passed unsanitized to git rebase during the 'Rebase before merging' merge operation, yielding arbitrary command execution as the Gogs process user (typically the git account). On default-configured instances (DISABLE_REGISTRATION=false, MAX_CREATION_LIMIT=-1) an unauthenticated attacker can self-register, create their own repository, enable rebase merging, and execute the full chain without any other-user interaction; a public Metasploit module fully automates exploitation for Linux and Windows targets.
How Gogs Authenticated RCE via Argument Injection in git rebase works
Overview
Rapid7 Labs senior security researcher Jonah Burgess (CryptoCat) disclosed an unpatched argument injection vulnerability in Gogs, a Go-based self-hosted Git service with roughly 50,000 GitHub stars and over 5,000 forks. The vulnerability — tracked as GHSA-qf6p-p7ww-cwr9 and rated CVSSv4 9.4 (Critical) — allows any authenticated user to achieve remote code execution (RCE) by submitting a pull request with a malicious base branch name that injects the --exec flag into the underlying git rebase invocation. The latest release at the time of research, Gogs 0.14.2, and the development tip 0.15.0+dev (commit b53d3162) are both confirmed vulnerable; all prior versions supporting the 'Rebase before merging' merge style are likely affected. At the time of public disclosure (May 28, 2026) no vendor patch exists, despite responsible disclosure on March 17, 2026 and multiple follow-ups through May 2026.
Root cause
The Merge() function in internal/database/pull.go executes the rebase merge style by directly invoking git rebase via process.ExecDir (a thin wrapper over exec.Command), passing the pull request's base branch as a positional argument WITHOUT the POSIX `--` end-of-options separator:
process.ExecDir(-1, tmpBasePath, fmt.Sprintf("PullRequest.Merge (git rebase): %s", tmpBasePath), "git", "rebase", "--quiet", pr.BaseBranch, remoteHeadBranch)
pr.BaseBranch is taken from the user-controlled URL parameter in internal/route/repo/pull.go (parsed from the `*` catch-all via strings.Split(c.Params("*"), "...")). Both base and head refs are validated through RevParse (which calls git rev-parse --verify <ref>) before the PR is created; RevParse rejects refs that do not resolve to a valid Git object but does NOT sanitize against argument injection. Because the attacker first pushes a real branch with the malicious name, RevParse succeeds, the value is persisted, and is later passed verbatim to git rebase. Git's argument parser then interprets the leading `--exec=...` token as the --exec flag rather than a branch name, and git rebase executes the supplied value through `sh -c` after each replayed commit.
Exploit primitive
Git branch names may legally contain `$`, `{`, `}`, `=`, and `-`. The attacker creates a branch named e.g.:
--exec=touch${IFS}/tmp/rce_proof
When used as pr.BaseBranch the resulting command becomes:
git rebase --quiet '--exec=touch${IFS}/tmp/rce_proof' 'head_repo/feature'
`${IFS}` is expanded by the shell to a space at sh -c execution time, sidestepping Git's prohibition on literal spaces in branch names. For payloads requiring characters illegal in Git refs (`:`, `~`, `^`, `?`, `*`, `[`, `\`, `//`), the attacker base64-encodes the command and decodes inline:
--exec=echo${IFS}<b64>|base64${IFS}-d|sh
On Windows, the `|` character is forbidden in NTFS filenames (Git stores refs as files under refs/heads/), so the public Metasploit module switches to file-based delivery: the attacker commits a small script (e.g. `.abcdef`) and `.abcdef.bat` to the repository and uses the short branch name `--exec=sh${IFS}.abcdef`. To bypass MSYS2 sh's mangling of `$`, `&`, and backticks in the payload, the script invokes `cmd.exe //c .abcdef.bat` so the PowerShell payload runs natively without shell metacharacter interpretation.
Execution flow during Merge()
The MergeStyleRebase code path runs these git commands sequentially in a temp directory: 1. git clone -b '<malicious>' <repo> <tmp> -> succeeds; `-b` consumes --exec=... as the branch value 2. git remote add head_repo <repo> && git fetch head_repo -> succeeds 3. git rebase --quiet '<malicious>' 'head_repo/feature' -> RCE fires here; --exec=<cmd> parsed as flag, command runs via sh -c 4. git checkout -b <tmpBranch> -> succeeds (server-generated timestamp branch) 5. git checkout '<malicious>' -> fails: git interprets --exec=... as an invalid option for checkout
Step 5 fails and Merge() returns HTTP 500, which is logged but does not undo the RCE that fired at step 3. The aborted merge leaves the target repository in a partial-rebase state, which limits each existing-repo target to a single firing of the exploit.
Mergeability race
For the merge button to be reachable, the PR must reach PullRequestStatusMergeable. Gogs's testPatch() calls UpdateLocalCopyBranch(pr.BaseBranch). On a fresh repository with no local copy, that function takes the Clone path which includes `--end-of-options`, so the malicious ref is treated as data and the patch test completes cleanly — promoting the PR to Mergeable. On subsequent re-tests by the background TestPullRequests goroutine, the local copy already exists so UpdateLocalCopyBranch takes the Checkout path, which is MISSING `--end-of-options`; the checkout fails and checkAndUpdateStatus() is skipped, leaving the PR stuck Mergeable forever. The PoC reliably hits the Clone path by always operating against a freshly created repository.
Why default configurations are trivially exploitable
Gogs ships with DISABLE_REGISTRATION=false (open registration) and MAX_CREATION_LIMIT=-1 (unlimited repository creation). Any registered user who creates a repo is automatically its owner and can toggle 'Rebase before merging' (PullsAllowRebase) in Settings > Advanced. The complete exploit chain — register, create repo, enable rebase merging, push malicious branch, open PR, click merge — is operable entirely within the attacker's own account with no interaction from other users. On instances with restricted registration or repo creation, exploitation still requires only write access to any repository that already has (or can have) rebase merging enabled.
Impact
The Gogs process user (commonly `git`, UID 1000 in the official Docker image) has direct filesystem read/write access to every repository on the instance under a single REPOSITORY_ROOT directory with no OS-level isolation between tenants. Successful exploitation yields: arbitrary command execution as the Gogs service user; cross-tenant data breach (read every private repository on the instance); credential theft from the Gogs database including password hashes, API tokens, SSH public keys, and 2FA secrets; lateral movement to other systems reachable from the server's network; and supply-chain attack capability via direct filesystem manipulation of any hosted repository (which bypasses Gogs's audit logging and is difficult to detect absent commit signing).
Relationship to prior argument-injection fixes
Gogs has patched related argument-injection issues across multiple advisories — CVE-2024-39933 (git tag), CVE-2024-39932 (git diff), CVE-2026-26194 (release tag deletion), and CVE-2024-39930 (built-in SSH server git upload-pack/receive-pack). The underlying git-module library was hardened with `--end-of-options` across Clone(), Push(), Fetch(), and 28 other call sites in v1.8.7. However, Merge() in internal/database/pull.go was never migrated to the safe git-module API and still uses raw process.ExecDir, leaving the git rebase code path unprotected.
Exploitation status and tooling
A fully weaponized Metasploit module accompanies the Rapid7 disclosure, supporting two operating modes: `own_repo` (default — creates a temporary repository under the attacker's account, exploits, and deletes the repo to minimize artifacts) and `existing_repo` (targets a repository the attacker already has write access to; only command payloads, since the partial-rebase corruption prevents multi-stage payload delivery). The module works against Linux and Windows targets and obtains a Meterpreter session in seconds. Because the public exploit is automated and no patch exists, mass exploitation of internet-facing Gogs instances is the expected near-term trajectory.
Remediation
No vendor patch is available. Administrators should restrict user registration (DISABLE_REGISTRATION=true in app.ini), restrict repository creation (MAX_CREATION_LIMIT=0), audit which repositories have 'Rebase before merging' enabled (Settings > Advanced > PullsAllowRebase), monitor server logs for ERROR entries matching `merge: git checkout '--exec=...'`, audit repository branch listings for refs beginning with `--`, and audit API tokens for names matching `msf_<hex>` (the Metasploit module's token-creation pattern, which persists after exploitation because Gogs exposes no token-deletion API endpoint).
MITRE ATT&CK techniques used in TL-2026-0615
Collection
T1005 Data from Local System; T1213 Data from Information Repositories
Lateral Movement
T1021 Remote Services; T1550 Use Alternate Authentication Material
Defense Evasion
T1027 Obfuscated Files or Information; T1070 Indicator Removal; T1140 Deobfuscate/Decode Files or Information
Exfiltration
T1041 Exfiltration Over C2 Channel
Execution
T1059 Command and Scripting Interpreter; T1203 Exploitation for Client Execution
Privilege Escalation
T1068 Exploitation for Privilege Escalation
Command and Control
T1071 Application Layer Protocol; T1105 Ingress Tool Transfer
Initial Access
T1078 Valid Accounts; T1190 Exploit Public-Facing Application
Discovery
T1082 System Information Discovery; T1083 File and Directory Discovery
Persistence
T1098 Account Manipulation; T1136 Create Account
Credential Access
T1111 Multi-Factor Authentication Interception; T1552 Unsecured Credentials; T1555 Credentials from Password Stores
initial-access
Impact
Resource Development
T1583 Acquire Infrastructure; T1585 Establish Accounts; T1587 Develop Capabilities; T1588 Obtain Capabilities
Reconnaissance
T1592 Gather Victim Host Information; T1593 Search Open Websites/Domains; T1595 Active Scanning
Affected products and versions in Gogs Authenticated RCE via Argument Injection in git rebase
- Gogs — Gogs
Vulnerable versions: 0.14.2; 0.15.0+dev (commit b53d3162); all prior versions supporting Rebase before merging
Remediation for Gogs Authenticated RCE via Argument Injection in git rebase
Patches
- No vendor patch available as of 2026-05-28; monitor https://github.com/gogs/gogs/security/advisories and the GHSA-qf6p-p7ww-cwr9 entry for updates
- Vendor was notified 2026-03-17, acknowledged receipt 2026-03-28, and provided no further response or fix through public disclosure
Immediate actions
- Set DISABLE_REGISTRATION=true in app.ini to prevent untrusted account creation (highest-impact mitigation since the exploit is self-contained in a single user's repository)
- Set MAX_CREATION_LIMIT=0 in app.ini (or per-user via Max Repo Creation in the admin panel) to block attacker-owned repository creation
- Audit all repositories for the 'Rebase before merging' (PullsAllowRebase) setting and disable on shared repos where untrusted users have write access
- Block Gogs web UI exposure to the public internet behind a VPN or IP allowlist until a patch ships
- Search Gogs server logs (ERROR level) for entries matching merge: git checkout '--exec=...' and audit any matched repositories
- Audit all repository branch listings for refs beginning with -- (administrators can script this against the bare repos under REPOSITORY_ROOT)
- Audit Gogs API tokens for names matching msf_<hex> and revoke; persistence path requires manual deletion from the database since Gogs exposes no token-deletion API endpoint
Workarounds
- Disable the rebase merge style globally by editing internal/database/pull.go and removing the MergeStyleRebase case (requires recompiling Gogs from source)
- Place a reverse proxy in front of Gogs that blocks POST requests to /<owner>/<repo>/pulls/<id>/merge when the merge_style parameter is 'rebase'
- Apply per-user repo-creation limits via the admin panel as a stopgap when DISABLE_REGISTRATION cannot be set
Longer-term hardening
- Migrate the Merge() function in internal/database/pull.go off raw process.ExecDir to the hardened git-module library API (which already enforces --end-of-options on Clone/Push/Fetch and 28 other call sites)
- Add an end-of-options or -- separator before user-controlled ref arguments on every direct git invocation across the codebase
- Enable commit signing on critical repositories so that forged commits written via direct filesystem manipulation (bypassing Gogs audit logging) become detectable
- Deploy file integrity monitoring on REPOSITORY_ROOT to detect direct filesystem writes by the Gogs process user outside of normal git operations
- Restrict the Gogs service user's outbound network access via egress filtering to slow lateral movement after initial RCE
- Audit and rotate all credentials, SSH keys, API tokens, and 2FA secrets that have been stored in the Gogs database since first deployment, treating any internet-exposed instance as potentially compromised
Weaknesses (CWE) in Gogs Authenticated RCE via Argument Injection in git rebase
CWE-88, CWE-77, CWE-78, CWE-94
Timeline of Gogs Authenticated RCE via Argument Injection in git rebase
- Jonah Burgess (CryptoCat) of Rapid7 Labs discovers and validates the argument injection vulnerability against Gogs 0.14.2 and 0.15.0+dev (commit b53d3162).
- Rapid7 Labs reports the vulnerability to Gogs maintainers via GitHub Security Advisory GHSA-qf6p-p7ww-cwr9.
- Gogs maintainer acknowledges receipt of the advisory; no patch or further response provided.
- Rapid7 contacts the Gogs maintainer for a status update; no response received.
- Rapid7 reminds the maintainer of the planned disclosure date and offers an extension if required; no response received.
- Rapid7 advises the maintainer that the public disclosure date is finalized for May 28, 2026; no response received.
- Metasploit module supporting own_repo (default) and existing_repo modes released, fully automating the exploit chain and obtaining command/Meterpreter sessions in seconds.
- Rapid7 publishes the full technical write-up and a weaponized Metasploit module covering Linux and Windows targets; no vendor patch available at publication.
- As of 2026-05-29, this Gogs git rebase --exec argument injection RCE (GHSA-qf6p-p7ww-cwr9, CVSSv4 9.4) remains unpatched: the maintainer is unresponsive since March 28 and Rapid7's fix PR is only awaiting review. A weaponized public Metasploit module (Linux/Windows) exists with no vendor patch, so internet-exposed instances stay live targets; not yet in CISA KEV (that entry is a separate Gogs CVE-2025-8110).
Sources cited for Gogs Authenticated RCE via Argument Injection in git rebase
- Authenticated RCE via Argument Injection in Gogs (NOT FIXED) — Rapid7 Labs
- GHSA-qf6p-p7ww-cwr9 — Gogs Security Advisory (private)
- Gogs source — internal/database/pull.go Merge()
- Gogs source — internal/route/repo/pull.go
- CWE-88: Improper Neutralization of Argument Delimiters in a Command (Argument Injection)
- Git documentation — git rebase --exec
- Git documentation — end-of-options sentinel and -- separator
- Prior Gogs argument injection — CVE-2024-39933 (git tag)
- Prior Gogs argument injection — CVE-2024-39932 (git diff)
- Prior Gogs argument injection — CVE-2024-39930 (built-in SSH server)
- Prior Gogs argument injection — CVE-2026-26194 (release tag deletion)
- Shodan dork — http.title:"Gogs" http.title:"Sign In"
Threats related to Gogs Authenticated RCE via Argument Injection in git rebase
- Cryptojacking Campaign Exploiting Gogs (CVE-2026-52806) and Argo Workflows (CVE-2026-42296/CVE-2026-42295) Targets Managed Kubernetes Clusters
- Multiple JetBrains Product Vulnerabilities: Account Takeover, Privilege Escalation, and RCE Across Hub, YouTrack, IntelliJ IDEA, Kotlin, GoLand, and TeamCity
- CVE-2025-67038: Critical Code Injection in Lantronix EDS5000 Series Under Active Exploitation
- GuardFall: Shell-Injection Guardrail Bypass Exposes Open-Source AI Coding Agents to Supply-Chain Attacks
- Gogs Critical RCE via Path Traversal in Organization Names (CVE-2026-52813)
Detection coverage for TL-2026-0615
As of 2026-05-28, Threadlinqs Intelligence publishes 9 detection rule(s) for TL-2026-0615 across Splunk SPL, Microsoft KQL and Sigma, covering 18 indicator(s) of compromise. The whole corpus is readable without an account; a free account unlocks full detection query text in Splunk SPL, Microsoft KQL and Sigma; paid tiers add raw indicator values, correlation and the MCP server. Threadlinqs MCP server · View plans.