Description
Sourcegraph is a code search and navigation engine. Sourcegraph prior to version 3.37 is vulnerable to remote code execution in the `gitserver` service. The service acts as a git exec proxy, and fails to properly restrict calling `git config`. This allows an attacker to set the git `core.sshCommand` option, which sets git to use the specified command instead of ssh when they need to connect to a remote system. Exploitation of this vulnerability depends on how Sourcegraph is deployed. An attacker able to make HTTP requests to internal services like gitserver is able to exploit it. This issue is patched in Sourcegraph version 3.37. As a workaround, ensure that requests to gitserver are properly protected.
Affected products
| Vendor | Product | Affected | Fixed |
|---|---|---|---|
| sourcegraph | sourcegraph | < 3.37 | — |
Public exploits
Exploit or proof-of-concept code for this vulnerability is publicly available, which lowers the bar for attackers. Treat it as a reason to patch sooner.
Metasploit 1 module
-
Sourcegraph gitserver sshCommand RCE
exploit/linux/http/sourcegraph_gitserver_sshcmd
Exploit-DB 1
- Sourcegraph Gitserver 3.36.3 - Remote Code Execution (RCE) EDB-50964 · remote · Jun 14, 2022
GitHub 1 repository
-
Altelus1/CVE-2022-23642 ★ 7 · Jun 10, 2022
PoC for Sourcegraph Gitserver < 3.37.0 RCE (CVE-2022-23642)
Sources: PoC-in-GitHub, Metasploit Framework, Exploit-DB — updated daily. Only links are listed; no exploit code is hosted here.
References
- https://github.com/sourcegraph/sourcegraph/security/advisories/GHSA-qcmp-fx72-q8q9
- https://github.com/sourcegraph/sourcegraph/pull/30833
- http://packetstormsecurity.com/files/167506/Sourcegraph-Gitserver-3.36.3-Remote-Code-Execution.html
- http://packetstormsecurity.com/files/167741/Sourcegraph-gitserver-sshCommand-Remote-Command-Execution.html